[PATCH 2 of 2] dirstate: fold paths using the just added util.realpath() function

Dan Villiom Podlaski Christiansen danchr at gmail.com
Sun Jul 26 10:28:00 CDT 2009


# HG changeset patch
# User Dan Villiom Podlaski Christiansen <danchr at gmail.com>
# Date 1248622002 -7200
# Node ID c1ed0db61b7b565f16863c4b583fa9024838079c
# Parent  fd520b42a33e73cc3e47534335cdfccc359a01b6
dirstate: fold paths using the just added util.realpath() function.

Using the one true canonical path of a directory entry allows
equivalent paths to be treated gracefully. Equivalent means, in this
case, differing directory entries resulting in the same, unique file
system link to a file.

diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -59,7 +59,7 @@ class dirstate(object):
     def _foldmap(self):
         f = {}
         for name in self._map:
-            f[os.path.normcase(name)] = name
+            f[util.realpath(name)] = name
         return f
 
     @propertycache
@@ -340,7 +340,7 @@ class dirstate(object):
             self._ui.warn(_("not in dirstate: %s\n") % f)
 
     def _normalize(self, path, knownpath):
-        norm_path = os.path.normcase(path)
+        norm_path = util.realpath(path)
         fold_path = self._foldmap.get(norm_path, None)
         if fold_path is None:
             if knownpath or not os.path.exists(os.path.join(self._root, path)):
diff --git a/tests/test-path-normalization b/tests/test-path-normalization
new file mode 100755
--- /dev/null
+++ b/tests/test-path-normalization
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+hg clone --quiet $TESTDIR/test-path-normalization.hg t
+exec hg st -R t
diff --git a/tests/test-path-normalization.hg b/tests/test-path-normalization.hg
new file mode 100644
index 0000000000000000000000000000000000000000..73ea086c424d1d011310533a43f74582f1835ff5
GIT binary patch
literal 404
zc$@*00c-w9M=>x$T4*^jL0KkKStkp}5&!@R|Nq~TKxj-4f938JM*u(X-2nmwAP|az
z0s;&$10huyG9fSl8pgpYk?AI$L at -87ni^muCL`4J0s|%l+5^=wri4-IYGX{1noLQi
znWl!ON2!PgOcCl~44PyOG%$$N2*?4D0B8UJ05kv^001FOxrvJ)oInhWL;!$1gcJZN
zHZl at eeuSoK!cnRk*OImct{HOm*$28g5RV}0Q)qZk!TafYGR#&(9PZYW4Opx#oDjRt
zXR7Q0(0w=z^+uQ?2z9ZtxtUbzFjEt-rUu77!kqwjg{AlpOJ<rA)to$4`M at Q3CLPIr
z2tMnSAC^Yql68MDi2N`@n=Kfzs1UbRVQ&<f*+BjwM?_6n?kQx6tEGjftTqthPX<VU
zIZ5a_y=AUg(p at v0MO83}c}Q_o3h4|%DNO~$*6X at F!f%ZY7RZ-yut_j5z+MQPbzuV9
y)YKcl8)+f;{cSo!gJGv<(`jfj0`924OM$pI*#|fSE_%4gaTjt$I8cx$3&#@aQlq2*



More information about the Mercurial-devel mailing list