Bug 5748 - Unknown exception during commit
Summary: Unknown exception during commit
Status: RESOLVED FIXED
Alias: None
Product: Mercurial
Classification: Unclassified
Component: Mercurial (show other bugs)
Version: 4.4.1
Hardware: All All
: urgent bug
Assignee: Bugzilla
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-11-26 13:39 UTC by vit
Modified: 2018-05-13 00:00 UTC (History)
3 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 vit 2017-11-26 13:39 UTC
Hi, I'm getting following exception while trying to commit changes on fairly large repo. (simply running: hg commit -m "Commit foo")
Not sure what or why this is happening, would be great to get some help.

** unknown exception encountered, please report by visiting
** https://mercurial-scm.org/wiki/BugTracker
** Python 2.7.10 (default, Jul 15 2017, 17:16:57) [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)]
** Mercurial Distributed SCM (version 4.4.1)
** Extensions loaded: convert, purge
Traceback (most recent call last):
  File "/usr/local/bin/hg", line 41, in <module>
    dispatch.run()
  File "/Library/Python/2.7/site-packages/mercurial/dispatch.py", line 85, in run
    status = (dispatch(req) or 0) & 255
  File "/Library/Python/2.7/site-packages/mercurial/dispatch.py", line 173, in dispatch
    ret = _runcatch(req)
  File "/Library/Python/2.7/site-packages/mercurial/dispatch.py", line 313, in _runcatch
    return _callcatch(ui, _runcatchfunc)
  File "/Library/Python/2.7/site-packages/mercurial/dispatch.py", line 321, in _callcatch
    return scmutil.callcatch(ui, func)
  File "/Library/Python/2.7/site-packages/mercurial/scmutil.py", line 154, in callcatch
    return func()
  File "/Library/Python/2.7/site-packages/mercurial/dispatch.py", line 303, in _runcatchfunc
    return _dispatch(req)
  File "/Library/Python/2.7/site-packages/mercurial/dispatch.py", line 940, in _dispatch
    cmdpats, cmdoptions)
  File "/Library/Python/2.7/site-packages/mercurial/dispatch.py", line 701, in runcommand
    ret = _runcommand(ui, options, cmd, d)
  File "/Library/Python/2.7/site-packages/mercurial/dispatch.py", line 948, in _runcommand
    return cmdfunc()
  File "/Library/Python/2.7/site-packages/mercurial/dispatch.py", line 937, in <lambda>
    d = lambda: util.checksignature(func)(ui, *args, **strcmdopt)
  File "/Library/Python/2.7/site-packages/mercurial/util.py", line 1183, in check
    return func(*args, **kwargs)
  File "/Library/Python/2.7/site-packages/mercurial/commands.py", line 1501, in commit
    return _docommit(ui, repo, *pats, **opts)
  File "/Library/Python/2.7/site-packages/mercurial/commands.py", line 1584, in _docommit
    node = cmdutil.commit(ui, repo, commitfunc, pats, opts)
  File "/Library/Python/2.7/site-packages/mercurial/cmdutil.py", line 3090, in commit
    return commitfunc(ui, repo, message, matcher, opts)
  File "/Library/Python/2.7/site-packages/mercurial/commands.py", line 1582, in commitfunc
    extra=extra)
  File "/Library/Python/2.7/site-packages/mercurial/localrepo.py", line 142, in wrapper
    return orig(repo.unfiltered(), *args, **kwargs)
  File "/Library/Python/2.7/site-packages/mercurial/localrepo.py", line 1946, in commit
    ret = self.commitctx(cctx, True)
  File "/Library/Python/2.7/site-packages/mercurial/localrepo.py", line 142, in wrapper
    return orig(repo.unfiltered(), *args, **kwargs)
  File "/Library/Python/2.7/site-packages/mercurial/localrepo.py", line 2013, in commitctx
    trp, changed)
  File "/Library/Python/2.7/site-packages/mercurial/localrepo.py", line 1778, in _filecommit
    if fparent2 != nullid or flog.cmp(fparent1, text) or meta:
  File "/Library/Python/2.7/site-packages/mercurial/filelog.py", line 101, in cmp
    if self.renamed(node):
  File "/Library/Python/2.7/site-packages/mercurial/filelog.py", line 65, in renamed
    return (m["copy"], revlog.bin(m["copyrev"]))
KeyError: 'copyrev'
Comment 1 Gregory Szorc 2017-11-26 13:54 UTC
Failing code is:

    m = parsemeta(t)[0]
    if m and "copy" in m:
        return (m["copy"], revlog.bin(m["copyrev"]))

This code hasn't meaningfully changed in years. "copy" and "copyrev" are supposed to always occur with each other. So it looks like something changed and is producing "copy" without "copyrev." Alternatively, a 3rd party extension or possibly a bug in `hg convert` could be in play here. But whatever the root cause, "bad" changeset data was recorded somewhere.

Anyway, core code should be more defensive here. This should be an easy fix on the stable branch and can be in the 4.4.2 release.
Comment 2 vit 2017-11-26 15:29 UTC
Bug in convert is a possible root cause as this commit is done after pulling converted repo. Do you also track issues related to convert here (cause I have a few of those too) or is it a separate community?
Comment 3 Gregory Szorc 2017-11-26 18:59 UTC
`hg convert` is part of the official Mercurial distribution. So please file bugs in this bug tracker. Use the "convert" component.
Comment 4 vit 2017-11-27 19:13 UTC
Is it clear at this point what the issue is and how to fix it?
If so is there some work around or should we wait for a new binary?
Comment 5 Gregory Szorc 2017-11-30 21:22 UTC
Patch on the mailing list: https://www.mercurial-scm.org/pipermail/mercurial-devel/2017-November/108248.html
Comment 6 Bugzilla 2017-12-15 00:00 UTC
Bug was set to IN_PROGRESS for 14 days, moving back to confirmed
Comment 7 Bugzilla 2017-12-26 00:00 UTC
Bug marked urgent for 10 days, bumping
Comment 8 Bugzilla 2018-01-06 00:00 UTC
Bug marked urgent for 10 days, bumping
Comment 9 Bugzilla 2018-01-17 00:00 UTC
Bug marked urgent for 10 days, bumping
Comment 10 Bugzilla 2018-01-27 00:00 UTC
Bug marked urgent for 10 days, bumping
Comment 11 Bugzilla 2018-02-06 00:00 UTC
Bug marked urgent for 10 days, bumping
Comment 12 Bugzilla 2018-02-17 00:00 UTC
Bug marked urgent for 11 days, bumping
Comment 13 Bugzilla 2018-02-28 00:00 UTC
Bug marked urgent for 10 days, bumping
Comment 14 Bugzilla 2018-03-10 00:00 UTC
Bug marked urgent for 10 days, bumping
Comment 15 Bugzilla 2018-03-20 00:00 UTC
Bug marked urgent for 10 days, bumping
Comment 16 Bugzilla 2018-03-31 00:00 UTC
Bug marked urgent for 10 days, bumping
Comment 17 Bugzilla 2018-04-11 00:00 UTC
Bug marked urgent for 10 days, bumping
Comment 18 Bugzilla 2018-04-22 00:00 UTC
Bug marked urgent for 11 days, bumping
Comment 19 Bugzilla 2018-05-03 00:00 UTC
Bug marked urgent for 10 days, bumping
Comment 20 Kevin Bullock 2018-05-05 14:09 UTC
Looks like the patch for this fell thru the cracks. I just queued it for stable and it will go into the 4.6 release.
Comment 21 HG Bot 2018-05-05 21:00 UTC
Fixed by https://mercurial-scm.org/repo/hg/rev/6614cac550ae
Gregory Szorc <gregory.szorc@gmail.com>
filelog: don't crash on invalid copy metadata (issue5748)

"copy" and "copyrev" are both supposed to appear next to each other.
However, a user report demonstrated a crash that indicates that
something in the wild is producing "copy" without "copyrev"
(probably `hg convert`).

While we should definitely fix the source of the bad metadata,
the bad code causing the crash is already in the wild and who knows
how many repositories are impacted. So let's be more defensive
when accessing the file revision metadata.

(please test the fix)
Comment 22 Bugzilla 2018-05-13 00:00 UTC
Bug was set to TESTING for 7 days, resolving