[PATCH 2 of 3 STABLE] windows: use normalized path to check repository nesting

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Sat Dec 24 04:09:58 CST 2011


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1324721125 -32400
# Branch stable
# Node ID 417127af399677e16b0ed9e555480b1e521a94ca
# Parent  4751d5133f15931407b6c8cb3af5aeaf4ca1aeb5
windows: use normalized path to check repository nesting

current "localrepository._checknested()" uses specified path itself to
compare against subrepo pathes.

it is invoked from "hgsubrepo.subrepo()" or pathauditor (as callback),
and both use "os.sep" as separator.

this causes unexpected nesting check result, if subrepo configuration
uses "/" as path separator for sub repo path.

this path uses "/" to join path components (or apply "util.pconvert()"
on path) to normalize.

diff -r 4751d5133f15 -r 417127af3996 mercurial/localrepo.py
--- a/mercurial/localrepo.py	Sat Dec 24 19:01:07 2011 +0900
+++ b/mercurial/localrepo.py	Sat Dec 24 19:05:25 2011 +0900
@@ -127,6 +127,7 @@
         if not path.startswith(self.root):
             return False
         subpath = path[len(self.root) + 1:]
+        normsubpath = util.pconvert(subpath)
 
         # XXX: Checking against the current working copy is wrong in
         # the sense that it can reject things like
@@ -148,9 +149,9 @@
         ctx = self[None]
         parts = util.splitpath(subpath)
         while parts:
-            prefix = os.sep.join(parts)
+            prefix = '/'.join(parts)
             if prefix in ctx.substate:
-                if prefix == subpath:
+                if prefix == normsubpath:
                     return True
                 else:
                     sub = ctx.sub(prefix)


More information about the Mercurial-devel mailing list