[PATCH 1 of 1 STABLE] dirstate: avoid normalizing letter case on icasefs for exact match (issue3340)

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Fri Mar 30 10:31:48 CDT 2012


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1333119848 -32400
# Branch stable
# Node ID 2bc47774628fcbf697f6c300920b8905d4d4f0ca
# Parent  795d591b6ef5deddc102c8b0ec27fb6c5376131b
dirstate: avoid normalizing letter case on icasefs for exact match (issue3340)

on icasefs, "hg qnew" fails to import changing letter case of filename
already occurred in working directory, for example:

    $ hg rename a tmp
    $ hg rename tmp A
    $ hg qnew casechange
    $ hg status
    R a
    $

"hg qnew" invokes 'dirstate.walk()' via 'localrepository.commit()'
with 'exact match' matching object having exact filenames of targets
in ones 'files()'.

current implementation of 'dirstate.walk()' always normalizes letter
case of filenames from 'match.files()' on icasefs, even though exact
matching is required.

then, files only different in letter case are treated as one file.

this patch prevents 'dirstate.walk()' from normalizing, if exact
matching is required, even on icasefs.

filenames for 'exact matching' are given not from user command line,
but from dirstate walk result, manifest of changecontext, patch files
or fixed list for specific system files (e.g.: '.hgtags').

in such case, case normalization should not be done, so this patch
works well.

diff -r 795d591b6ef5 -r 2bc47774628f mercurial/dirstate.py
--- a/mercurial/dirstate.py	Tue Mar 27 16:13:59 2012 -0500
+++ b/mercurial/dirstate.py	Sat Mar 31 00:04:08 2012 +0900
@@ -548,7 +548,7 @@
         elif match.files() and not match.anypats(): # match.match, no patterns
             skipstep3 = True
 
-        if self._checkcase:
+        if not exact and self._checkcase:
             normalize = self._normalize
             skipstep3 = False
         else:
diff -r 795d591b6ef5 -r 2bc47774628f tests/test-casefolding.t
--- a/tests/test-casefolding.t	Tue Mar 27 16:13:59 2012 -0500
+++ b/tests/test-casefolding.t	Sat Mar 31 00:04:08 2012 +0900
@@ -72,3 +72,45 @@
   gold
 
   $ cd ..
+
+issue 3340: mq does not handle case changes correctly
+
+in addition to reported case, 'hg qrefresh' is also tested against
+case changes.
+
+  $ echo "[extensions]" >> $HGRCPATH
+  $ echo "mq=" >> $HGRCPATH
+
+  $ hg init issue3340
+  $ cd issue3340
+
+  $ echo a > mIxEdCaSe
+  $ hg add mIxEdCaSe
+  $ hg commit -m '#0'
+  $ hg rename mIxEdCaSe tmp
+  $ hg rename tmp MiXeDcAsE
+  $ hg status -A
+  A MiXeDcAsE
+    mIxEdCaSe
+  R mIxEdCaSe
+  $ hg qnew changecase
+  $ hg status -A
+  C MiXeDcAsE
+
+  $ hg qpop -a
+  popping changecase
+  patch queue now empty
+  $ hg qnew refresh-casechange
+  $ hg status -A
+  C mIxEdCaSe
+  $ hg rename mIxEdCaSe tmp
+  $ hg rename tmp MiXeDcAsE
+  $ hg status -A
+  A MiXeDcAsE
+    mIxEdCaSe
+  R mIxEdCaSe
+  $ hg qrefresh
+  $ hg status -A
+  C MiXeDcAsE
+
+  $ cd ..


More information about the Mercurial-devel mailing list