[issue2388] Crash with hg qmv when patches have same name

contingencyplan bugs at mercurial.selenic.com
Sun Sep 19 18:09:47 CDT 2010

New submission from contingencyplan <contingencyplan at gmail.com>:

If I have two patches, a.patch and b.patch, and I rename them so I have
b.patch -> c.patch, a.patch -> b.patch, Mercurial + mq crashes upon the
second rename when the mq directory is versioned and a.patch and b.patch
have been committed. Furthermore, the crash leaves the mq directory in an
inconsistent state -- the series file still lists a.patch, but the rename of
a.patch -> b.patch occurred, so attempts to push a.patch will fail. On the
other hand, if I commit the rename b.patch -> c.patch to the mq repository,
I can then perform the a.patch -> b.patch rename without issue, thus
providing a workaround.

This is the minimum sequence of commands to cause the crash. In particular,
the patch directory must be versioned, and both a.patch and b.patch must be
committed to it before the renaming occurs.

In a clean directory:

% hg init

% hg qinit -c

% hg qnew a.patch

% hg qnew b.patch

% hg ci --mq -m "a.patch b.patch"

% hg qmv b.patch c.patch

% hg qmv a.patch b.patch
** unknown exception encountered, details follow
** report bug details to http://mercurial.selenic.com/bts/
** or mercurial at selenic.com
** Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41) [GCC 4.4.3]
** Mercurial Distributed SCM (version 1.6.3)
** Extensions loaded: bookmarks, churn, color, convert, eol, extdiff, fetch,
gpg, git, mq, graphlog, pager, progress, purge, rebase, record
Traceback (most recent call last):
  File "/usr/bin/hg", line 27, in <module>
  File "/usr/lib/pymodules/python2.6/mercurial/dispatch.py", line 16, in run
  File "/usr/lib/pymodules/python2.6/mercurial/dispatch.py", line 34, in
    return _runcatch(u, args)
  File "/usr/lib/pymodules/python2.6/mercurial/dispatch.py", line 54, in
    return _dispatch(ui, args)
  File "/usr/lib/pymodules/python2.6/mercurial/dispatch.py", line 494, in
    cmdpats, cmdoptions)
  File "/usr/lib/pymodules/python2.6/mercurial/dispatch.py", line 355, in
    ret = _runcommand(ui, options, cmd, d)
  File "/usr/lib/pymodules/python2.6/mercurial/extensions.py", line 174, in wrap
    return wrapper(origfn, *args, **kwargs)
  File "/usr/lib/pymodules/python2.6/hgext/pager.py", line 95, in pagecmd
    return orig(ui, options, cmd, cmdfunc)
  File "/usr/lib/pymodules/python2.6/mercurial/extensions.py", line 174, in wrap
    return wrapper(origfn, *args, **kwargs)
  File "/usr/lib/pymodules/python2.6/hgext/color.py", line 211, in colorcmd
    return orig(ui_, opts, cmd, cmdfunc)
  File "/usr/lib/pymodules/python2.6/mercurial/dispatch.py", line 545, in
    return checkargs()
  File "/usr/lib/pymodules/python2.6/mercurial/dispatch.py", line 499, in
    return cmdfunc()
  File "/usr/lib/pymodules/python2.6/mercurial/dispatch.py", line 492, in
    d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
  File "/usr/lib/pymodules/python2.6/mercurial/util.py", line 420, in check
    return func(*args, **kwargs)
  File "/usr/lib/pymodules/python2.6/hgext/mq.py", line 2336, in rename
  File "/usr/lib/pymodules/python2.6/mercurial/context.py", line 847, in
    t = fctx.data()
AttributeError: 'changectx' object has no attribute 'data'

% hg qseries

% hg qpop -a
popping c.patch
popping a.patch
patch queue now empty

% hg qpush
applying a.patch
unable to read a.patch

% ls .hg/patches
b.patch  c.patch  series  status

% hg status --mq
M series
A c.patch
R b.patch
! a.patch

According to kiilerix in IRC #mercurial, this issue was introduced via
http://www.selenic.com/hg/rev/a1aad8333864 .

messages: 13661
nosy: contingencyplan, djc, kiilerix
priority: bug
status: unread
title: Crash with hg qmv when patches have same name
topic: hg, mq

Mercurial issue tracker <bugs at mercurial.selenic.com>

More information about the Mercurial-devel mailing list