Issue1152

Title mq corrupts dirstate on file rename
Priority critical Status resolved
Superseder KeyError for copy in commit
View: 1175
Nosy List cgudrian, djc, jsgf, mpm, pmezard
Assigned To Topics mq

Created on 2008-06-02.09:10:39 by cgudrian, last changed 2008-07-23.16:59:43 by mpm.

Messages
msg6559 (view) Author: mpm Date: 2008-07-23.16:59:43
Duplicate of issue1175, closing
msg6297 (view) Author: jsgf Date: 2008-06-16.17:31:03
+1 - I was just about to report this.

There is a simple way to recover, however:
$ hg qnew X
$ hg qren X Y
$ cd .hg/patches
$ hg commit  # fails
$ hg revert Y
$ hg add Y
$ hg commit  # works

(Assuming that you did "hg qinit -c"; this bug report seems to concern the case
where the mq directory isn't under hg control.)
msg6173 (view) Author: mpm Date: 2008-06-04.20:17:14
Correcting title.
msg6167 (view) Author: pmezard Date: 2008-06-04.11:55:59
I probably introduced that with http://hg.intevation.org/mercurial/rev/93e140dbcd44.

I still believe my fix is correct, this is an MQ bug.
msg6139 (view) Author: cgudrian Date: 2008-06-02.16:11:41
Thanks.  I wasn't aware that I had to turn git diffs on.  Thank God I had a backup 
of the repository since I haven't so far been able to recover it.
msg6138 (view) Author: djc Date: 2008-06-02.12:15:37
For one thing, you must have git diffs enabled for qrefresh to pick up on
renames. Though it still shouldn't die in such an ugly way.
msg6134 (view) Author: cgudrian Date: 2008-06-02.09:10:36
The mq extension seems to corrupt the repository when trying to refresh a patch 
after having renamed files.  Here are the steps to reproduce this error:

gn@quintus:~/test$ hg init
gn@quintus:~/test$ hg qinit
gn@quintus:~/test$ hg qnew test.patch
gn@quintus:~/test$ echo "Hello, World" > test
gn@quintus:~/test$ hg add test
gn@quintus:~/test$ hg qrefresh
gn@quintus:~/test$ hg rename test old_test
gn@quintus:~/test$ hg qrefresh
** unknown exception encountered, details follow
** report bug details to http://www.selenic.com/mercurial/bts
** or mercurial@selenic.com
** Mercurial Distributed SCM (version 1.0.1)
Traceback (most recent call last):
  File "/usr/local/bin/hg", line 20, in ?
    mercurial.dispatch.run()
  File "/usr/local/lib/python2.4/site-packages/mercurial/dispatch.py", line 20, 
in run
    sys.exit(dispatch(sys.argv[1:]))
  File "/usr/local/lib/python2.4/site-packages/mercurial/dispatch.py", line 29, 
in dispatch
    return _runcatch(u, args)
  File "/usr/local/lib/python2.4/site-packages/mercurial/dispatch.py", line 45, 
in _runcatch
    return _dispatch(ui, args)
  File "/usr/local/lib/python2.4/site-packages/mercurial/dispatch.py", line 364, 
in _dispatch
    ret = _runcommand(ui, options, cmd, d)
  File "/usr/local/lib/python2.4/site-packages/mercurial/dispatch.py", line 417, 
in _runcommand
    return checkargs()
  File "/usr/local/lib/python2.4/site-packages/mercurial/dispatch.py", line 373, 
in checkargs
    return cmdfunc()
  File "/usr/local/lib/python2.4/site-packages/mercurial/dispatch.py", line 356, 
in <lambda>
    d = lambda: func(ui, repo, *args, **cmdoptions)
  File "/usr/local/lib/python2.4/site-packages/hgext/mq.py", line 1743, in 
refresh
    ret = q.refresh(repo, pats, msg=message, **opts)
  File "/usr/local/lib/python2.4/site-packages/hgext/mq.py", line 1150, in 
refresh
    force=1)
  File "/usr/local/lib/python2.4/site-packages/hgext/mq.py", line 2189, in 
commit
    return super(mqrepo, self).commit(*args, **opts)
  File "/usr/local/lib/python2.4/site-packages/mercurial/localrepo.py", line 
832, in commit
    new[f] = self.filecommit(f, m1, m2, linkrev, trp, changed)
  File "/usr/local/lib/python2.4/site-packages/mercurial/localrepo.py", line 
712, in filecommit
    meta["copyrev"] = hex(manifest1[cp])
KeyError: 'test'
gn@quintus:~/test$ hg revert --all
abort: 00changelog.i@54387fe543f0: no node!
gn@quintus:~/test$ hg qrefresh
abort: 00changelog.i@54387fe543f0: no node!
gn@quintus:~/test$ hg qpop -f
abort: 00changelog.i@54387fe543f0: no node!
gn@quintus:~/test$ hg --version
Mercurial Distributed SCM (version 1.0.1)

Copyright (C) 2005-2008 Matt Mackall <mpm@selenic.com> and others
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
gn@quintus:~/test$

Obviously the repository remains in an unusable state.

This behaviour occurs on Linux, Windows and Mac OS.
History
Date User Action Args
2008-07-23 16:59:43mpmsetstatus: chatting -> resolved
nosy: mpm, jsgf, pmezard, djc, cgudrian
superseder: + KeyError for copy in commit
messages: + msg6559
2008-06-16 17:31:04jsgfsetnosy: + jsgf
messages: + msg6297
2008-06-04 20:17:38mpmsetnosy: + mpm
messages: + msg6173
title: mq corrupts repository on file rename -> mq corrupts dirstate on file rename
2008-06-04 11:56:01pmezardsetnosy: + pmezard
messages: + msg6167
2008-06-02 16:11:42cgudriansetnosy: djc, cgudrian
messages: + msg6139
2008-06-02 12:15:37djcsetstatus: unread -> chatting
nosy: + djc
messages: + msg6138
2008-06-02 09:10:39cgudriancreate