[PATCH] merge: report file/directory collisions properly
Patrick Mezard
pmezard at gmail.com
Tue Aug 14 18:45:18 UTC 2007
# HG changeset patch
# User Patrick Mezard <pmezard at gmail.com>
# Date 1187116733 -7200
# Node ID 124f1f04a7fba43479e619f620fb5b520114604a
# Parent f0f22f1776bf2994d91a7b6f42c7109160aa6587
merge: report file/directory collisions properly
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -7,7 +7,7 @@
from node import *
from i18n import _
-import errno, util, os, tempfile, context, heapq
+import errno, util, os, tempfile, context, heapq, strutil
def filemerge(repo, fw, fd, fo, wctx, mctx):
"""perform a 3-way merge in the working directory
@@ -72,13 +72,26 @@ def checkunknown(wctx, mctx):
def checkcollision(mctx):
"check for case folding collisions in the destination context"
+ def reportcollision(p1, p2):
+ path1, type1 = p1
+ path2, type2 = p2
+ format = _("case-folding collision between %s %%s and %s %%s"
+ % (type1, type2))
+ raise util.Abort(format % (path1, path2))
+
folded = {}
for fn in mctx.manifest():
+ for c in strutil.findall(fn, '/'):
+ fnpart = fn[:c]
+ fold = fnpart.lower()
+ if fold in folded and folded[fold][0] != fnpart:
+ reportcollision(folded[fold], (fnpart, 'directory'))
+ folded[fold] = (fnpart, 'directory')
+
fold = fn.lower()
if fold in folded:
- raise util.Abort(_("case-folding collision between %s and %s")
- % (fn, folded[fold]))
- folded[fold] = fn
+ reportcollision(folded[fold], (fn, 'file'))
+ folded[fold] = (fn, 'file')
def forgetremoved(wctx, mctx):
"""
More information about the Mercurial-devel
mailing list