comparison mercurial/localrepo.py @ 15722:417127af3996 stable

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.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Sat, 24 Dec 2011 19:05:25 +0900
parents b8d8599410da
children 5b384b7f48d5
comparison
equal deleted inserted replaced
15721:4751d5133f15 15722:417127af3996
125 def _checknested(self, path): 125 def _checknested(self, path):
126 """Determine if path is a legal nested repository.""" 126 """Determine if path is a legal nested repository."""
127 if not path.startswith(self.root): 127 if not path.startswith(self.root):
128 return False 128 return False
129 subpath = path[len(self.root) + 1:] 129 subpath = path[len(self.root) + 1:]
130 normsubpath = util.pconvert(subpath)
130 131
131 # XXX: Checking against the current working copy is wrong in 132 # XXX: Checking against the current working copy is wrong in
132 # the sense that it can reject things like 133 # the sense that it can reject things like
133 # 134 #
134 # $ hg cat -r 10 sub/x.txt 135 # $ hg cat -r 10 sub/x.txt
146 # since we want to prevent access to nested repositories on 147 # since we want to prevent access to nested repositories on
147 # the filesystem *now*. 148 # the filesystem *now*.
148 ctx = self[None] 149 ctx = self[None]
149 parts = util.splitpath(subpath) 150 parts = util.splitpath(subpath)
150 while parts: 151 while parts:
151 prefix = os.sep.join(parts) 152 prefix = '/'.join(parts)
152 if prefix in ctx.substate: 153 if prefix in ctx.substate:
153 if prefix == subpath: 154 if prefix == normsubpath:
154 return True 155 return True
155 else: 156 else:
156 sub = ctx.sub(prefix) 157 sub = ctx.sub(prefix)
157 return sub.checknested(subpath[len(prefix) + 1:]) 158 return sub.checknested(subpath[len(prefix) + 1:])
158 else: 159 else: