[PATCH] merge: report all files in _checkunknown

Jordi Gutiérrez Hermoso jordigh at octave.org
Wed Jan 11 15:00:22 CST 2012


# HG changeset patch
# User Jordi Gutiérrez Hermoso <jordigh at octave.org>
# Date 1326315222 18000
# Node ID 9fe70ec6cb418daa14fed5f09f94c4f482d4d052
# Parent  c47d69ce5208d5b5cfd2fb2f0f1d7a2b4795fbf5
merge: report all files in _checkunknown

When doing hg up, if there is a file conflict with untracked files,
currently only the first such conflict is reported. With this patch,
all of them are listed.

Since this requires a list, makes sense to put this list as another
kwarg to the Abort exception. The hint kwarg is the wrong place for
it, since it doesn't get displayed correctly for this purpose. I
displayed this list along with the error in the relevant locations in
dispatch.py

With this patch error message is now reported as

    abort: untracked file(s) in working directory differ from file(s)
    in requested revision:
      a
      b

instead of

    abort: untracked file in working directory differs from file in
    requested revision: 'a'

This is a follow up to an old attempt to do this here:

    http://selenic.com/pipermail/mercurial-devel/2011-August/033625.html

diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -52,6 +52,8 @@
         ferr.write(_("abort: %s\n") % inst)
         if inst.hint:
             ferr.write(_("(%s)\n") % inst.hint)
+        if inst.errlist:
+            ui.warn("  " + "\n  ".join(inst.errlist) + "\n")
         return -1
     except error.ParseError, inst:
         if len(inst.args) > 1:
@@ -154,6 +156,8 @@
         ui.warn(_("abort: %s\n") % inst)
         if inst.hint:
             ui.warn(_("(%s)\n") % inst.hint)
+        if inst.errlist:
+            ui.warn("  " + "\n  ".join(inst.errlist) + "\n")
     except ImportError, inst:
         ui.warn(_("abort: %s!\n") % inst)
         m = str(inst).split()[-1]
diff --git a/mercurial/error.py b/mercurial/error.py
--- a/mercurial/error.py
+++ b/mercurial/error.py
@@ -35,6 +35,7 @@
     def __init__(self, *args, **kw):
         Exception.__init__(self, *args)
         self.hint = kw.get('hint')
+        self.errlist = kw.get('errlist')
 
 class ConfigError(Abort):
     'Exception raised when parsing config files'
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -90,11 +90,16 @@
     folded = {}
     for fn in mctx:
         folded[foldf(fn)] = fn
+
+    errlist = list()
     for fn in wctx.unknown():
         f = foldf(fn)
         if f in folded and mctx[folded[f]].cmp(wctx[f]):
-            raise util.Abort(_("untracked file in working directory differs"
-                               " from file in requested revision: '%s'") % fn)
+            errlist.append(fn)
+    if errlist:
+        raise util.Abort(_("untracked file(s) in working directory differ"
+                           " from file(s) in requested revision: "),
+                         errlist=errlist)
 
 def _checkcollision(mctx, wctx):
     "check for case folding collisions in the destination context"


More information about the Mercurial-devel mailing list