[PATCH STABLE] dirstate: fix some problems for recursive case normalization (issue3342)

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Sat Mar 31 02:01:50 CDT 2012


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1333176903 -32400
# Branch stable
# Node ID a14866b6fd378c0439f5e4ad94e813e44bf420f0
# Parent  80a6a68906bf7bdde30d13cbd56faf7dbb523dd5
dirstate: fix some problems for recursive case normalization (issue3342)

file in nested directory causes unexpected abort.

problems below should be fixed for recursive normalization route in
dirstate._normalize():

    1. rsplit() may cause unpacking into more than 2 elements.
       it should be called with 'maxsplit' argument to unpack
       into 'd, f'

    2. 'd' is replaced by normalized value prefixed with
       'self._root', but this makes 'folded' as absolute path,
       and it is unexpected one for caller of recursive
       normalization

diff -r 80a6a68906bf -r a14866b6fd37 mercurial/dirstate.py
--- a/mercurial/dirstate.py	Fri Mar 30 14:29:50 2012 -0500
+++ b/mercurial/dirstate.py	Sat Mar 31 15:55:03 2012 +0900
@@ -406,9 +406,10 @@
                 # recursively normalize leading directory components
                 # against dirstate
                 if '/' in normed:
-                    d, f = normed.rsplit('/')
-                    d = self._root + "/" + self._normalize(d, isknown)
-                    folded = d + "/" + util.fspath(f, d)
+                    d, f = normed.rsplit('/', 1)
+                    d = self._normalize(d, isknown)
+                    r = self._root + "/" + d
+                    folded = d + "/" + util.fspath(f, r)
                 else:
                     folded = util.fspath(normed, self._root)
                 self._foldmap[normed] = folded
diff -r 80a6a68906bf -r a14866b6fd37 tests/test-casefolding.t
--- a/tests/test-casefolding.t	Fri Mar 30 14:29:50 2012 -0500
+++ b/tests/test-casefolding.t	Sat Mar 31 15:55:03 2012 +0900
@@ -73,6 +73,17 @@
 
   $ cd ..
 
+issue 3342: file in nested directory causes unexpected abort
+
+  $ hg init issue3342
+  $ cd issue3342
+
+  $ mkdir -p a/B/c/D
+  $ echo e > a/B/c/D/e
+  $ hg add a/B/c/D/e
+
+  $ cd ..
+
 issue 3340: mq does not handle case changes correctly
 
 in addition to reported case, 'hg qrefresh' is also tested against


More information about the Mercurial-devel mailing list