rebase: show resolve status when merge fails

timeless timeless at gmail.com
Fri Aug 6 10:42:51 CDT 2010


When I use hg pull --rebase, I often get a lot of output which is
painful to read, some of my patches are working to suppress the less
useful bits.

I'm also running w/ --traceback  (and hgext.color) which means that in
addition to noise from hg about divergent renames, I end up with a lot
of junk between my start, the theoretically useful (yet hard to read)
bits, and the error message.

This is the output I get with the below patch note that the
<RED>...</> lines are new, and are in red because they're hg resolve
-l --config extensions.color= (they wouldn't be in red if you didn't
have color enabled...)

timeless-mbp:mozilla-central timeless$ hg rebase --cont
warning: conflicts during merge.
merging embedding/browser/webBrowser/nsWebBrowser.cpp failed!
warning: conflicts during merge.
merging embedding/browser/webBrowser/nsWebBrowser.h failed!
<RED>U embedding/browser/webBrowser/nsWebBrowser.cpp</>
<RED>U embedding/browser/webBrowser/nsWebBrowser.h</>
Traceback (most recent call last):
  File "/Users/timeless/lib/python/mercurial/dispatch.py", line 58, in _runcatch
    return _dispatch(ui, args)
  File "/Users/timeless/lib/python/mercurial/dispatch.py", line 516,
in _dispatch
    cmdpats, cmdoptions)
  File "/Users/timeless/lib/python/mercurial/dispatch.py", line 377,
in runcommand
    ret = _runcommand(ui, options, cmd, d)
  File "/Users/timeless/lib/python/mercurial/extensions.py", line 174, in wrap
    return wrapper(origfn, *args, **kwargs)
  File "/Users/timeless/lib/python/hgext/color.py", line 211, in colorcmd
    return orig(ui_, opts, cmd, cmdfunc)
  File "/Users/timeless/lib/python/mercurial/dispatch.py", line 567,
in _runcommand
    return checkargs()
  File "/Users/timeless/lib/python/mercurial/dispatch.py", line 521,
in checkargs
    return cmdfunc()
  File "/Users/timeless/lib/python/mercurial/dispatch.py", line 514, in <lambda>
    d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
  File "/Users/timeless/lib/python/mercurial/util.py", line 426, in check
    return func(*args, **kwargs)
  File "/Users/timeless/lib/python/hgext/rebase.py", line 168, in rebase
    raise util.Abort(_('fix unresolved conflicts with hg '
Abort: fix unresolved conflicts with hg resolve then run hg rebase --continue
abort: fix unresolved conflicts with hg resolve then run hg rebase --continue

Is what I got one round through with this patch applied. Note that
while it is probably possible to add coloring to the warning and
merging lines, they're still painful to read/parse because of the
staggering between the two styles (and the fact that it repeats the
warning multiple time seems totally wasteful now that I try to read
it. -- I think the current format suffers from "tl;dr").

With my output (and the help of color), I immediately see the problem.
A quick survey of Mozilla people showed that most rely on merge tools,
in which case they wouldn't hit this case at all. I know that in
theory users could have lots of output (lines), which could make it
hard to see the relevant bits, but at least for the case of lots of
conflicts, one line per conflict with highlighting is much easier than
2 lines per conflict with painful scanning behavior.

hg resolve also takes a "-a" argument, and it might be the case that
it makes sense to supply it, however the documentation for it is
incredibly confusing. I've been meaning to deal w/ that too, but
that's an adventure for some other time -- specifically, there should
be easy, obvious and clear way to have hg resolve list only unresolved
changes, and "--all" is not a logical way to do that...

# HG changeset patch
# User timeless <timeless at gmail.com>
# Date 1281107222 -10800
# Node ID e40a92f457efccda53ed11c3b3756bff26e06e3a
# Parent  bca5b5fd3474df02478f05dcb22dd8c874d1a7ed
rebase: show resolve status when merge fails

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -164,6 +164,7 @@ def rebase(ui, repo, **opts):
                 else:
                     stats = rebasenode(repo, rev, p1, p2, state)
                     if stats and stats[3] > 0:
+                        commands.resolve(ui, repo, list=True)
                         raise util.Abort(_('fix unresolved conflicts with hg '
                                     'resolve then run hg rebase --continue'))
                 updatedirstate(repo, rev, target, p2)


More information about the Mercurial-devel mailing list