[Bug 5220] New: Histedit has unexpected behaviors on changing the commit message of an **empty** commit.

mercurial-bugs at selenic.com mercurial-bugs at selenic.com
Tue Apr 26 04:34:17 UTC 2016


https://bz.mercurial-scm.org/show_bug.cgi?id=5220

            Bug ID: 5220
           Summary: Histedit has unexpected behaviors on changing the
                    commit message of an **empty** commit.
           Product: Mercurial
           Version: unspecified
          Hardware: All
                OS: All
            Status: UNCONFIRMED
          Severity: bug
          Priority: wish
         Component: histedit
          Assignee: bugzilla at selenic.com
          Reporter: lydxlx at gmail.com
                CC: mercurial-devel at selenic.com

The extension histedit has unexpected behaviors on changing the commit message
of an **empty** commit.
The behavior differs across different operating systems, i.e.,
1) on windows, the histedit command can go through, but the empty commit is
just gone;
2) on mac/ubuntu, a fatal error will be triggered.
I give more details as follows.


On Windows, though no error occurs, there is no new editor window popped out to
let me change the commit message of the empty changeset. The commit is just
gone. 
To repro, try the following commands.

hg init
hg branch hello
hg commit -m "Init hello"
echo hello > hello
hg commit -Am "Adding hello"
echo hello >> hello
hg commit -m "More hello"
hg histedit 0

The system editor pops out, and I modify its content as follows, save and quit.
mess 53434a450f64 0 Init hello
pick 753aa251a3ab 1 Adding hello
pick 55e68de11063 2 More hello

Now, I am expecting another editor pops out for changing the commit message for
the first (empty) changeset. But it doesn't happen and only gives me the
following information.

0 files updated, 0 files merged, 1 files removed, 0 files unresolved
53434a450f64: empty changeset
saved backup bundle to ...

Now, if I do hg log, I find that my initial empty commit is completely gone.

changeset:   1:87f9366aafe5
branch:      hello
tag:         tip
summary:     More hello

changeset:   0:d833179aec59
branch:      hello
summary:     Adding hello

---------------------------------------------------------

On Mac, the commands above will create a fatal error (after step 8, hg histedit
0) shown as follows.

** unknown exception encountered, please report by visiting
** http://mercurial.selenic.com/wiki/BugTracker
** Python 2.7.10 (default, Oct 23 2015, 19:19:21) [GCC 4.2.1 Compatible Apple
LLVM 7.0.0 (clang-700.0.59.5)]
** Mercurial Distributed SCM (version 3.3)
** Extensions loaded: extdiff, strip, rebase, shelve, histedit
Traceback (most recent call last):
  File "/usr/local/bin/hg", line 43, in <module>
    mercurial.dispatch.run()
  File
"/usr/local/Cellar/mercurial/3.3/lib/python2.7/site-packages/mercurial/dispatch.py",
line 28, in run
    sys.exit((dispatch(request(sys.argv[1:])) or 0) & 255)
  File
"/usr/local/Cellar/mercurial/3.3/lib/python2.7/site-packages/mercurial/dispatch.py",
line 71, in dispatch
    ret = _runcatch(req)
  File
"/usr/local/Cellar/mercurial/3.3/lib/python2.7/site-packages/mercurial/dispatch.py",
line 140, in _runcatch
    return _dispatch(req)
  File
"/usr/local/Cellar/mercurial/3.3/lib/python2.7/site-packages/mercurial/dispatch.py",
line 860, in _dispatch
    cmdpats, cmdoptions)
  File
"/usr/local/Cellar/mercurial/3.3/lib/python2.7/site-packages/mercurial/dispatch.py",
line 621, in runcommand
    ret = _runcommand(ui, options, cmd, d)
  File
"/usr/local/Cellar/mercurial/3.3/lib/python2.7/site-packages/mercurial/dispatch.py",
line 951, in _runcommand
    return checkargs()
  File
"/usr/local/Cellar/mercurial/3.3/lib/python2.7/site-packages/mercurial/dispatch.py",
line 922, in checkargs
    return cmdfunc()
  File
"/usr/local/Cellar/mercurial/3.3/lib/python2.7/site-packages/mercurial/dispatch.py",
line 857, in <lambda>
    d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
  File
"/usr/local/Cellar/mercurial/3.3/lib/python2.7/site-packages/mercurial/util.py",
line 711, in check
    return func(*args, **kwargs)
  File
"/usr/local/Cellar/mercurial/3.3/lib/python2.7/site-packages/hgext/histedit.py",
line 541, in histedit
    _histedit(ui, repo, state, *freeargs, **opts)
  File
"/usr/local/Cellar/mercurial/3.3/lib/python2.7/site-packages/hgext/histedit.py",
line 676, in _histedit
    mapping, tmpnodes, created, ntm = processreplacement(state)
  File
"/usr/local/Cellar/mercurial/3.3/lib/python2.7/site-packages/hgext/histedit.py",
line 896, in processreplacement
    final[prec] = sorted(succs, key=nm.get)
TypeError: expected string or Unicode object, NoneType found

---------------------------------------------------------

The situation is slightly different on Ubuntu. After step 8, another editor
window successfully popped out letting me change the commit message of the
empty changeset.
However, when I happily modify the file, save and exit, I get the following
error message again.

** unknown exception encountered, please report by visiting
** http://mercurial.selenic.com/wiki/BugTracker
** Python 2.7.6 (default, Jun 22 2015, 17:58:13) [GCC 4.8.2]
** Mercurial Distributed SCM (version 2.8.2)
** Extensions loaded: color, histedit
Traceback (most recent call last):
  File "/usr/bin/hg", line 38, in <module>
    mercurial.dispatch.run()
  File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 28, in
run
    sys.exit((dispatch(request(sys.argv[1:])) or 0) & 255)
  File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 69, in
dispatch
    ret = _runcatch(req)
  File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 133, in
_runcatch
    return _dispatch(req)
  File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 806, in
_dispatch
    cmdpats, cmdoptions)
  File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 585, in
runcommand
    ret = _runcommand(ui, options, cmd, d)
  File "/usr/lib/python2.7/dist-packages/mercurial/extensions.py", line 196, in
wrap
    return wrapper(origfn, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/hgext/color.py", line 417, in colorcmd
    return orig(ui_, opts, cmd, cmdfunc)
  File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 897, in
_runcommand
    return checkargs()
  File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 868, in
checkargs
    return cmdfunc()
  File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 803, in
<lambda>
    d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
  File "/usr/lib/python2.7/dist-packages/mercurial/util.py", line 512, in check
    return func(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/hgext/histedit.py", line 484, in
histedit
    _histedit(ui, repo, *freeargs, **opts)
  File "/usr/lib/python2.7/dist-packages/hgext/histedit.py", line 610, in
_histedit
    mapping, tmpnodes, created, ntm = processreplacement(repo, replacements)
  File "/usr/lib/python2.7/dist-packages/hgext/histedit.py", line 829, in
processreplacement
    final[prec] = sorted(succs, key=nm.get)
TypeError: expected string or Unicode object, NoneType found

---------------------------------------------------------

What's worse, in the Mac/Ubuntu case, this fatal error will trigger another
error if I do hg histedit --continue or hg histedit --abort, which means I
cannot get rid of this deadly loop. 
I was so frustrated and thought my repo was permanently dead until I attempted
deleting the following files.

rm .hg/histedit-last-edit.txt .hg/histedit-state

Though this remedy is cruel and ugly, it indeed helped me...

I know, typically, mercurial won't allow one to commit an empty changeset. But
this could happen (and is common?) when we create new branches.
I encountered this issue since I was unsatisfactory about the initial commit
message of one of my branches.

---------------------------------------------------------
Mercurial Version:
Windows: 3.7.3
Mac: 3.3
Ubuntu: 2.8.2

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the Mercurial-devel mailing list