Issue2097

Title hg commit crashes after hg qpop -f of a file that has been moved
Priority bug Status resolved
Superseder localrepo._filecommit gets None in crev
View: 2484
Nosy List erh, kiilerix, mg, mpm, pmezard
Assigned To Topics mq

Created on 2010-03-16.17:28:00 by erh, last changed 2010-11-10.07:26:48 by mpm.

Messages
msg14347 (view) Author: mpm Date: 2010-11-10.07:26:48
Duplicate of issue2484
msg14206 (view) Author: pmezard Date: 2010-10-28.20:02:59
Uh, I meant issue2460, not issue2038
msg14205 (view) Author: pmezard Date: 2010-10-28.20:02:21
@kiilerix The qrename bug is unrelated to this issue. I moved it into
issue2038 and have a fix for it.
msg14163 (view) Author: kiilerix Date: 2010-10-26.18:00:56
Another way to trig exactly the same error:
  $ echo "[extensions]" >> $HGRCPATH
  $ echo "mq=" >> $HGRCPATH
  $ hg init
  $ hg qnew p0
  $ (cd .hg/patches && hg init)
  $ hg qren p0 p1
  p0 not tracked!
  $ hg ci --mq -mq0
msg14162 (view) Author: kiilerix Date: 2010-10-26.17:39:18
$ hg init
  $ echo 0 > f1
  $ hg add f1
  $ hg qnew -f p0
  $ hg mv f1 f2
  $ hg qpop -f
  popping p0
  patch queue now empty
  $ hg stat
  A f2
  $ cat f2
  0
  $ hg ci -m0
  ...
    File "/home/mk/src/hg/mercurial/localrepo.py", line 957, in commit
      ret = self.commitctx(cctx, True)
    File "/home/mk/src/hg/mercurial/localrepo.py", line 1004, in commitctx
      changed)
    File "/home/mk/src/hg/mercurial/localrepo.py", line 827, in _filecommit
      self.ui.debug(" %s: copy %s:%s\n" % (fname, cfname, hex(crev)))
  TypeError: must be string or buffer, not None
  [1]

For a starter we could abort instead of crashing...:

--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -823,6 +823,9 @@
                     if cfname in ancestor:
                         crev = ancestor[cfname].filenode()
                         break
+            if not crev:
+                raise util.Abort(_("%s: copy source %s not found") %
+                    (fname, cfname))
 
             self.ui.debug(" %s: copy %s:%s\n" % (fname, cfname, hex(crev)))
             meta["copy"] = cfname
msg12059 (view) Author: erh Date: 2010-03-16.17:30:37
One other thing I noticed is that after the qpop, running "hg stat" produces:

A src2/file1
A src2/file2
R src/file1

I expected the "A src2/file2" line to have gone away since it was part of a
move command on a file that no longer exists, not a plain add.
msg12058 (view) Author: erh Date: 2010-03-16.17:28:00
I get an error:
 TypeError: b2a_hex() argument 1 must be string or read-only buffer, not None
when running trying to commit after moving files around and then using qpop.

This bug might have the same underlying cause as
  http://mercurial.selenic.com/bts/issue2038
and might be related to
  http://mercurial.selenic.com/bts/issue1476
  http://mercurial.selenic.com/bts/issue1441
  http://www.selenic.com/pipermail/mercurial/2009-January/023270.html
but since I triggered the error with a different set of steps, I'm going to
report this anyway and let someone that knows more about hg figure out if
it's actually a duplicate.

The following set of steps cause an error:
hg init x
cd x
mkdir src
echo foo > src/file1
hg add src/file1
hg ci -m file1msg
echo bar > src/file2
hg add src/file2
hg qnew -f testmq
hg mv src src2
hg qpop
hg qpop -f
hg stat
hg ci -m testci


The full error is:

transaction abort!
rollback completed
** unknown exception encountered, details follow
** report bug details to http://mercurial.selenic.com/bts/
** or mercurial@selenic.com
** Mercurial Distributed SCM (version 1.5)
** Extensions loaded: convert, mq, hgk, extdiff
Traceback (most recent call last):
  File "/u/int5sys/opt/mercurial-1.5/bin/hg", line 27, in <module>
    mercurial.dispatch.run()
  File
"/u/int5sys/opt/mercurial-1.5/lib/python2.6/site-packages/mercurial/dispatch.py",
line 16, in run
    sys.exit(dispatch(sys.argv[1:]))
  File
"/u/int5sys/opt/mercurial-1.5/lib/python2.6/site-packages/mercurial/dispatch.py",
line 30, in dispatch
    return _runcatch(u, args)
  File
"/u/int5sys/opt/mercurial-1.5/lib/python2.6/site-packages/mercurial/dispatch.py",
line 47, in _runcatch
    return _dispatch(ui, args)
  File
"/u/int5sys/opt/mercurial-1.5/lib/python2.6/site-packages/mercurial/dispatch.py",
line 466, in _dispatch
    return runcommand(lui, repo, cmd, fullargs, ui, options, d)
  File
"/u/int5sys/opt/mercurial-1.5/lib/python2.6/site-packages/mercurial/dispatch.py",
line 336, in runcommand
    ret = _runcommand(ui, options, cmd, d)
  File
"/u/int5sys/opt/mercurial-1.5/lib/python2.6/site-packages/mercurial/dispatch.py",
line 517, in _runcommand
    return checkargs()
  File
"/u/int5sys/opt/mercurial-1.5/lib/python2.6/site-packages/mercurial/dispatch.py",
line 471, in checkargs
    return cmdfunc()
  File
"/u/int5sys/opt/mercurial-1.5/lib/python2.6/site-packages/mercurial/dispatch.py",
line 465, in <lambda>
    d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
  File
"/u/int5sys/opt/mercurial-1.5/lib/python2.6/site-packages/mercurial/util.py", line
401, in check
    return func(*args, **kwargs)
  File
"/u/int5sys/opt/mercurial-1.5/lib/python2.6/site-packages/mercurial/extensions.py",
line 116, in wrap
    util.checksignature(origfn), *args, **kwargs)
  File
"/u/int5sys/opt/mercurial-1.5/lib/python2.6/site-packages/mercurial/util.py", line
401, in check
    return func(*args, **kwargs)
  File
"/u/int5sys/opt/mercurial-1.5/lib/python2.6/site-packages/hgext/mq.py", line
2648, in mqcommand
    return orig(ui, repo, *args, **kwargs)
  File
"/u/int5sys/opt/mercurial-1.5/lib/python2.6/site-packages/mercurial/util.py", line
401, in check
    return func(*args, **kwargs)
  File
"/u/int5sys/opt/mercurial-1.5/lib/python2.6/site-packages/mercurial/commands.py",
line 708, in commit
    node = cmdutil.commit(ui, repo, commitfunc, pats, opts)
  File
"/u/int5sys/opt/mercurial-1.5/lib/python2.6/site-packages/mercurial/cmdutil.py",
line 1150, in commit
    return commitfunc(ui, repo, message, match(repo, pats, opts), opts)
  File
"/u/int5sys/opt/mercurial-1.5/lib/python2.6/site-packages/mercurial/commands.py",
line 706, in commitfunc
    editor=e, extra=extra)
  File
"/u/int5sys/opt/mercurial-1.5/lib/python2.6/site-packages/hgext/mq.py", line
2558, in commit
    editor, extra)
  File
"/u/int5sys/opt/mercurial-1.5/lib/python2.6/site-packages/mercurial/localrepo.py",
line 858, in commit
    ret = self.commitctx(cctx, True)
  File
"/u/int5sys/opt/mercurial-1.5/lib/python2.6/site-packages/mercurial/localrepo.py",
line 905, in commitctx
    changed)
  File
"/u/int5sys/opt/mercurial-1.5/lib/python2.6/site-packages/mercurial/localrepo.py",
line 734, in _filecommit
    self.ui.debug(" %s: copy %s:%s\n" % (fname, cfname, hex(crev)))
TypeError: b2a_hex() argument 1 must be string or read-only buffer, not None
History
Date User Action Args
2010-11-10 07:26:48mpmsetstatus: chatting -> resolved
superseder: + localrepo._filecommit gets None in crev
messages: + msg14347
nosy: + mpm
2010-10-28 20:02:59pmezardsetnosy: pmezard, kiilerix, mg, erh
messages: + msg14206
2010-10-28 20:02:22pmezardsettopic: + mq
nosy: + pmezard
messages: + msg14205
2010-10-26 18:00:56kiilerixsetnosy: kiilerix, mg, erh
messages: + msg14163
2010-10-26 17:39:18kiilerixsetnosy: + kiilerix
messages: + msg14162
title: hg commit crashes after hg mv + hg qpop -f -> hg commit crashes after hg qpop -f of a file that has been moved
2010-03-16 19:09:00mgsetnosy: + mg
2010-03-16 17:30:37erhsetstatus: unread -> chatting
messages: + msg12059
2010-03-16 17:28:00erhcreate