[PATCH 2 of 2 STABLE] icasefs: show detail about case-folding collision

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Sun Apr 15 11:27:33 CDT 2012


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1334506289 -32400
# Branch stable
# Node ID 540a990738f3ea874c45de23e18354e85f75337b
# Parent  97023ea8a634cb500b85767efe7dbf709d8a0dbe
icasefs: show detail about case-folding collision

current implementation shows only the first case-folding collision.

this patch shows all detected collisions to fix all together: if
collisions are detected in target context, this patch avoids
examination between target and working contexts, because collisions
may be resolved by renaming on target context.

this patch also adds hint to raised exception, especially for linear
updating.

diff -r 97023ea8a634 -r 540a990738f3 mercurial/merge.py
--- a/mercurial/merge.py	Mon Apr 16 01:11:29 2012 +0900
+++ b/mercurial/merge.py	Mon Apr 16 01:11:29 2012 +0900
@@ -101,15 +101,21 @@
         raise util.Abort(_("untracked files in working directory differ "
                            "from files in requested revision"))
 
-def _checkcollision(mctx, wctx):
+def _checkcollision(mctx, wctx, branchmerge):
     "check for case folding collisions in the destination context"
     folded = {}
+    error = False
     for fn in mctx:
         fold = util.normcase(fn)
         if fold in folded:
-            raise util.Abort(_("case-folding collision between %s and %s")
-                             % (fn, folded[fold]))
+            error = True
+            mctx._repo.ui.warn(_("case-folding collision between %s and %s\n")
+                               % (fn, folded[fold]))
         folded[fold] = fn
+    if error:
+        raise util.Abort(_("target context has files "
+                           "colliding with each other"),
+                         hint=_("rename files in target context"))
 
     if wctx:
         # class to delay looking up copy mapping
@@ -124,8 +130,18 @@
             fold = util.normcase(fn)
             mfn = folded.get(fold, None)
             if mfn and mfn != fn and pc.map.get(mfn) != fn:
-                raise util.Abort(_("case-folding collision between %s and %s")
-                                 % (mfn, fn))
+                error = True
+                mctx._repo.ui.warn(_("case-folding collision between "
+                                     "%s and %s\n") % (mfn, fn))
+
+        if error:
+            if branchmerge:
+                hint = _("rename files before merging")
+            else:
+                hint = _("use --check or --clean to update cleanly")
+            raise util.Abort(_("target context has files "
+                               "collding with ones in working context"),
+                             hint=hint)
 
 def _forgetremoved(wctx, mctx, branchmerge):
     """
@@ -578,9 +594,9 @@
         if folding:
             # collision check is not needed for clean update
             if not branchmerge and force:
-                _checkcollision(p2, None)
+                _checkcollision(p2, None, branchmerge)
             else:
-                _checkcollision(p2, wc)
+                _checkcollision(p2, wc, branchmerge)
         action += _forgetremoved(wc, p2, branchmerge)
         action += manifestmerge(repo, wc, p2, pa, overwrite, partial)
 
diff -r 97023ea8a634 -r 540a990738f3 tests/test-casecollision-merge.t
--- a/tests/test-casecollision-merge.t	Mon Apr 16 01:11:29 2012 +0900
+++ b/tests/test-casecollision-merge.t	Mon Apr 16 01:11:29 2012 +0900
@@ -71,7 +71,9 @@
   created new head
 
   $ hg merge
-  abort: case-folding collision between A and a
+  case-folding collision between A and a
+  abort: target context has files collding with ones in working context
+  (rename files before merging)
   [255]
   $ hg parents --template '{rev}\n'
   3
@@ -83,7 +85,9 @@
   $ hg update --clean 2
   1 files updated, 0 files merged, 1 files removed, 0 files unresolved
   $ hg merge
-  abort: case-folding collision between a and A
+  case-folding collision between a and A
+  abort: target context has files collding with ones in working context
+  (rename files before merging)
   [255]
   $ hg parents --template '{rev}\n'
   2
@@ -143,7 +147,9 @@
   $ hg commit -m '#2'
 
   $ hg update 0
-  abort: case-folding collision between a and A
+  case-folding collision between a and A
+  abort: target context has files collding with ones in working context
+  (use --check or --clean to update cleanly)
   [255]
   $ hg parents --template '{rev}\n'
   2
@@ -190,7 +196,9 @@
   $ hg status
   A B
   $ hg update
-  abort: case-folding collision between b and B
+  case-folding collision between b and B
+  abort: target context has files collding with ones in working context
+  (use --check or --clean to update cleanly)
   [255]
 
   $ hg update --check


More information about the Mercurial-devel mailing list