Bug 4683 - "branch(null)" and branch("wdir()") crash with a traceback
Summary: "branch(null)" and branch("wdir()") crash with a traceback
Status: RESOLVED FIXED
Alias: None
Product: Mercurial
Classification: Unclassified
Component: revset (show other bugs)
Version: 3.3
Hardware: PC Linux
: urgent bug
Assignee: Bugzilla
URL:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2015-05-21 14:49 UTC by Pierre-Yves David
Modified: 2015-06-05 00:01 UTC (History)
4 users (show)

See Also:
Python Version: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Pierre-Yves David 2015-05-21 14:49 UTC
There:

  % 13:48 pyd@marginatus ~/src/thg > hg log --rev "branch(null)"  
  ** Unknown exception encountered with possibly-broken third-party extension drophack
  ** which supports versions unknown of Mercurial.
  ** Please disable drophack and try your action again.
  ** If that fixes the bug please report it to the extension author.
  ** Python 2.7.9 (default, Mar  1 2015, 12:57:24) [GCC 4.9.2]
  ** Mercurial Distributed SCM (version 3.4+329-622cd02e393f)
  ** Extensions loaded: color, schemes, convert, rebase, churn, purge, progress, patchbomb, graphlog, shelve, blackbox, lighthg, smartlog, strip, histedit, share, evolve, drophack, cpydev, perf, chistedit, extdiff, remotenames, b2x, activity
  Traceback (most recent call last):
    File "/home/pyd/bin/hg", line 43, in <module>
      mercurial.dispatch.run()
    File "/home/pyd/lib/python/mercurial/dispatch.py", line 29, in run
      sys.exit((dispatch(request(sys.argv[1:])) or 0) & 255)
    File "/home/pyd/lib/python/mercurial/dispatch.py", line 91, in dispatch
      ret = _runcatch(req)
    File "/home/pyd/lib/python/mercurial/dispatch.py", line 160, in _runcatch
      return _dispatch(req)
    File "/home/pyd/lib/python/mercurial/dispatch.py", line 885, in _dispatch
      cmdpats, cmdoptions)
    File "/home/pyd/lib/python/mercurial/dispatch.py", line 646, in runcommand
      ret = _runcommand(ui, options, cmd, d)
    File "/home/pyd/lib/python/mercurial/extensions.py", line 168, in closure
      return func(*(args + a), **kw)
    File "/home/pyd/lib/python/hgext/color.py", line 525, in colorcmd
      return orig(ui_, opts, cmd, cmdfunc)
    File "/home/pyd/lib/python/mercurial/dispatch.py", line 1002, in _runcommand
      return checkargs()
    File "/home/pyd/lib/python/mercurial/dispatch.py", line 971, in checkargs
      return cmdfunc()
    File "/home/pyd/lib/python/mercurial/dispatch.py", line 882, in <lambda>
      d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
    File "/home/pyd/lib/python/mercurial/util.py", line 695, in check
      return func(*args, **kwargs)
    File "/home/pyd/lib/python/mercurial/extensions.py", line 168, in closure
      return func(*(args + a), **kw)
    File "/home/pyd/lib/python/mercurial/util.py", line 695, in check
      return func(*args, **kwargs)
    File "/home/pyd/src/hgremotenames/remotenames.py", line 358, in exlog
      res = orig(ui, repo, *args, **opts)
    File "/home/pyd/lib/python/mercurial/util.py", line 695, in check
      return func(*args, **kwargs)
    File "/home/pyd/lib/python/mercurial/commands.py", line 4564, in log
      revs, expr, filematcher = cmdutil.getlogrevs(repo, pats, opts)
    File "/home/pyd/lib/python/mercurial/cmdutil.py", line 2113, in getlogrevs
      revs = _logrevs(repo, opts)
    File "/home/pyd/lib/python/mercurial/cmdutil.py", line 2057, in _logrevs
      revs = scmutil.revrange(repo, opts['rev'])
    File "/home/pyd/lib/python/mercurial/scmutil.py", line 774, in revrange
      l = m(repo)
    File "/home/pyd/lib/python/mercurial/revset.py", line 2538, in mfunc
      result = getset(repo, subset, tree)
    File "/home/pyd/lib/python/mercurial/revset.py", line 313, in getset
      s = methods[x[0]](repo, subset, *x[1:])
    File "/home/pyd/lib/python/mercurial/revset.py", line 371, in func
      return symbols[a[1]](repo, subset, b)
    File "/home/pyd/lib/python/mercurial/revset.py", line 546, in branch
      b.add(getbi(r)[0])
    File "/home/pyd/lib/python/mercurial/branchmap.py", line 352, in branchinfo
      _rbcrecfmt, buffer(self._rbcrevs, rbcrevidx, _rbcrecsize))
  ValueError: offset must be zero or positive
  zsh: exit 1     hg log --rev "branch(null)"
  % 13:48 pyd@marginatus ~/src/thg > hg log --rev "branch(wdir())"
  ** Unknown exception encountered with possibly-broken third-party extension drophack
  ** which supports versions unknown of Mercurial.
  ** Please disable drophack and try your action again.
  ** If that fixes the bug please report it to the extension author.
  ** Python 2.7.9 (default, Mar  1 2015, 12:57:24) [GCC 4.9.2]
  ** Mercurial Distributed SCM (version 3.4+329-622cd02e393f)
  ** Extensions loaded: color, schemes, convert, rebase, churn, purge, progress, patchbomb, graphlog, shelve, blackbox, lighthg, smartlog, strip, histedit, share, evolve, drophack, cpydev, perf, chistedit, extdiff, remotenames, b2x, activity
  Traceback (most recent call last):
    File "/home/pyd/bin/hg", line 43, in <module>
      mercurial.dispatch.run()
    File "/home/pyd/lib/python/mercurial/dispatch.py", line 29, in run
      sys.exit((dispatch(request(sys.argv[1:])) or 0) & 255)
    File "/home/pyd/lib/python/mercurial/dispatch.py", line 91, in dispatch
      ret = _runcatch(req)
    File "/home/pyd/lib/python/mercurial/dispatch.py", line 160, in _runcatch
      return _dispatch(req)
    File "/home/pyd/lib/python/mercurial/dispatch.py", line 885, in _dispatch
      cmdpats, cmdoptions)
    File "/home/pyd/lib/python/mercurial/dispatch.py", line 646, in runcommand
      ret = _runcommand(ui, options, cmd, d)
    File "/home/pyd/lib/python/mercurial/extensions.py", line 168, in closure
      return func(*(args + a), **kw)
    File "/home/pyd/lib/python/hgext/color.py", line 525, in colorcmd
      return orig(ui_, opts, cmd, cmdfunc)
    File "/home/pyd/lib/python/mercurial/dispatch.py", line 1002, in _runcommand
      return checkargs()
    File "/home/pyd/lib/python/mercurial/dispatch.py", line 971, in checkargs
      return cmdfunc()
    File "/home/pyd/lib/python/mercurial/dispatch.py", line 882, in <lambda>
      d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
    File "/home/pyd/lib/python/mercurial/util.py", line 695, in check
      return func(*args, **kwargs)
    File "/home/pyd/lib/python/mercurial/extensions.py", line 168, in closure
      return func(*(args + a), **kw)
    File "/home/pyd/lib/python/mercurial/util.py", line 695, in check
      return func(*args, **kwargs)
    File "/home/pyd/src/hgremotenames/remotenames.py", line 358, in exlog
      res = orig(ui, repo, *args, **opts)
    File "/home/pyd/lib/python/mercurial/util.py", line 695, in check
      return func(*args, **kwargs)
    File "/home/pyd/lib/python/mercurial/commands.py", line 4564, in log
      revs, expr, filematcher = cmdutil.getlogrevs(repo, pats, opts)
    File "/home/pyd/lib/python/mercurial/cmdutil.py", line 2113, in getlogrevs
      revs = _logrevs(repo, opts)
    File "/home/pyd/lib/python/mercurial/cmdutil.py", line 2057, in _logrevs
      revs = scmutil.revrange(repo, opts['rev'])
    File "/home/pyd/lib/python/mercurial/scmutil.py", line 774, in revrange
      l = m(repo)
    File "/home/pyd/lib/python/mercurial/revset.py", line 2538, in mfunc
      result = getset(repo, subset, tree)
    File "/home/pyd/lib/python/mercurial/revset.py", line 313, in getset
      s = methods[x[0]](repo, subset, *x[1:])
    File "/home/pyd/lib/python/mercurial/revset.py", line 371, in func
      return symbols[a[1]](repo, subset, b)
    File "/home/pyd/lib/python/mercurial/revset.py", line 546, in branch
      b.add(getbi(r)[0])
    File "/home/pyd/lib/python/mercurial/branchmap.py", line 342, in branchinfo
      rbcrevidx = rev * _rbcrecsize
  TypeError: unsupported operand type(s) for *: 'NoneType' and 'int'
  zsh: exit 1     hg log --rev "branch(wdir())"
Comment 1 Pierre-Yves David 2015-05-21 14:50 UTC
the "branch(null)" part was "working fine" in 3.2.4. This a regression.
Comment 2 Yuya Nishihara 2015-05-21 19:01 UTC
bisect says the first bad revision is:

changeset:   23787:678f53865c68
user:        Mads Kiilerich <madski@unity3d.com>
date:        Thu Jan 08 00:01:03 2015 +0100
summary:     revset: use localrepo revbranchcache for branch name filtering
Comment 3 Matt Mackall 2015-05-22 12:48 UTC
I think we should teach the RBC to handle -1 = default to avoid this class of bugs in the future.
Comment 4 Bugzilla 2015-05-28 00:00 UTC
Bug marked urgent for 5 days, bumping
Comment 5 Yuya Nishihara 2015-05-28 08:27 UTC
Fixed by https://selenic.com/repo/hg/rev/38117278f295
revbranchcache: return uncached branchinfo for nullrev (issue4683)

This fixes the crash caused by "branch(null)" revset. No cache should be
necessary for nullrev because changelog.branchinfo(nullrev) does not involve
IO operation.

Note that the problem of "branch(wdir())" isn't addressed by this patch.
"wdir()" will raise TypeError in many places because of None. This is the
reason why "wdir()" is still experimental.

(I'm HG Bot)
Comment 6 Bugzilla 2015-06-05 00:01 UTC
Bug was set to TESTING for 7 days, resolving