[PATCH] Check case-folding clashes during addremove

Andrei Vermel avermel at mail.ru
Wed Mar 14 01:41:52 CDT 2007


This is to fix an annoying problem caused by some windows tool change
case of a file or part of it's path. Addremove will then add the file with
the name clashing copy still in the repo.

Andrei

# HG changeset patch
# User Andrei Vermel <avermel at mail.ru>
# Date 1173853671 -10800
# Node ID 9eb57a48d30492968d762b541197da7f4a55b15a
# Parent  dbc3846c09a1d24c66acce3b5ab6d2d36b0160ea
Check case-folding clashes during addremove

diff -r dbc3846c09a1 -r 9eb57a48d304 mercurial/cmdutil.py
--- a/mercurial/cmdutil.py  Wed Mar 14 01:26:09 2007 -0500
+++ b/mercurial/cmdutil.py  Wed Mar 14 09:27:51 2007 +0300
@@ -186,6 +186,29 @@ def addremove(repo, pats=[], opts={}, wl
             mapping[abs] = rel, exact
             if repo.ui.verbose or not exact:
                 repo.ui.status(_('removing %s\n') % ((pats and rel) or 
abs))
+
+    if not util.checkfolding(repo.path):
+        fold_clash = None
+
+        fold_had = {}
+        for p in repo.workingctx().parents():
+            wm = p.manifest()
+            for fn in wm:
+                fold_had[fn.lower()] = fn
+
+        for fn in add:
+            fold=fn.lower()
+            if fold in fold_had:
+                if fold_clash is None:
+                    repo.ui.status(_('\nname case fold clashes found!\n'))
+
+                repo.ui.status(_('    was %s, now %s\n') %
+                           (fold_had[fold], fn))
+                fold_clash = True
+
+        if fold_clash:
+            raise util.Abort(_('addremove aborted'))
+
     if not dry_run:
         repo.add(add, wlock=wlock)
         repo.remove(remove, wlock=wlock)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: addremove_clashes
Type: application/octet-stream
Size: 1420 bytes
Desc: not available
Url : http://www.selenic.com/pipermail/mercurial-devel/attachments/20070314/f61b9bb0/addremove_clashes-0001.obj


More information about the Mercurial-devel mailing list