# HG changeset patch
# User Jordi Gutiérrez Hermoso <jordigh@octave.org>
# Date 1326315222 18000
#      Wed Jan 11 15:53:42 2012 -0500
# Node ID 44fa047cef57706d9d1c0e355e1740b736cb2a1c
# Parent  eb6867b982233da2a61262bff4cde94fe17b0719
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.

With this patch error message is now reported as

    a: untracked file differs
    b: untracked file differs
    abort: untracked files in working directory conflict with files in
    requested revision

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/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
+
+    error = False
     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)
+            error = True
+            wctx._repo.ui.warn(_("%s: untracked file differs\n") % fn)
+    if error:
+        raise util.Abort(_("untracked files in working directory differ "
+                           "from files in requested revision"))
 
 def _checkcollision(mctx, wctx):
     "check for case folding collisions in the destination context"
diff --git a/tests/test-casefolding.t b/tests/test-casefolding.t
--- a/tests/test-casefolding.t
+++ b/tests/test-casefolding.t
@@ -66,7 +66,8 @@
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
   $ echo gold > a
   $ hg up
-  abort: untracked file in working directory differs from file in requested revision: 'a'
+  a: untracked file differs
+  abort: untracked files in working directory differ from files in requested revision
   [255]
   $ cat a
   gold
diff --git a/tests/test-merge1.t b/tests/test-merge1.t
--- a/tests/test-merge1.t
+++ b/tests/test-merge1.t
@@ -66,7 +66,8 @@
   $ echo This is file b2 > b
 merge should fail
   $ hg merge 1
-  abort: untracked file in working directory differs from file in requested revision: 'b'
+  b: untracked file differs
+  abort: untracked files in working directory differ from files in requested revision
   [255]
 merge of b expected
   $ hg merge -f 1