[PATCH 1 of 1] add: warn when adding a file that would cause a case-folding collision
Kevin Gessner
kevin at fogcreek.com
Sat Apr 30 04:15:59 CDT 2011
# HG changeset patch
# User Kevin Gessner <kevin at kevingessner.com>
# Date 1304154504 -7200
# Node ID 4421446fa1a4cae3fbb54642d8004a9615ea565a
# Parent 92db9667d15ae7b5caf1a9653c2d45b5fdaf0e67
add: warn when adding a file that would cause a case-folding collision
On a case-sensitive file system, files can be added with names that differ
only in case (a "case collision"). This would cause an error on case-insensitive
filesystems. A warning is now given for such collisions:
$ touch file File
$ hg add file
$ hg add File
warning: possible case-folding collision for File
diff -r 92db9667d15a -r 4421446fa1a4 mercurial/cmdutil.py
--- a/mercurial/cmdutil.py Sat Apr 30 03:00:38 2011 -0500
+++ b/mercurial/cmdutil.py Sat Apr 30 11:08:24 2011 +0200
@@ -1314,9 +1314,15 @@
match.bad = lambda x, y: bad.append(x) or oldbad(x, y)
names = []
wctx = repo[None]
+ wctx.status(clean=True)
+ existing = dict([(fn.lower(), fn) for fn in
+ wctx.added() + wctx.clean() + wctx.modified()])
for f in repo.walk(match):
exact = match.exact(f)
if exact or f not in repo.dirstate:
+ if f.lower() in existing and existing[f.lower()] != f:
+ ui.warn(_('warning: possible case-folding collision for '
+ '%s\n') % join(f))
names.append(f)
if ui.verbose or not exact:
ui.status(_('adding %s\n') % match.rel(join(f)))
More information about the Mercurial-devel
mailing list