##// END OF EJS Templates
subrepo: normalize path in the specific way for problematic encodings...
FUJIWARA Katsunori -
r21568:8dd17b19 stable
parent child Browse files
Show More
@@ -142,3 +142,25 b' def canonpath(root, cwd, myname, auditor'
142 name = dirname
142 name = dirname
143
143
144 raise util.Abort(_("%s not under root '%s'") % (myname, root))
144 raise util.Abort(_("%s not under root '%s'") % (myname, root))
145
146 def normasprefix(path):
147 '''normalize the specified path as path prefix
148
149 Returned vaule can be used safely for "p.startswith(prefix)",
150 "p[len(prefix):]", and so on.
151
152 For efficiency, this expects "path" argument to be already
153 normalized by "os.path.normpath", "os.path.realpath", and so on.
154
155 See also issue3033 for detail about need of this function.
156
157 >>> normasprefix('/foo/bar').replace(os.sep, '/')
158 '/foo/bar/'
159 >>> normasprefix('/').replace(os.sep, '/')
160 '/'
161 '''
162 d, p = os.path.splitdrive(path)
163 if len(p) != len(os.sep):
164 return path + os.sep
165 else:
166 return path
@@ -276,8 +276,7 b' def reporelpath(repo):'
276 parent = repo
276 parent = repo
277 while util.safehasattr(parent, '_subparent'):
277 while util.safehasattr(parent, '_subparent'):
278 parent = parent._subparent
278 parent = parent._subparent
279 p = parent.root.rstrip(os.sep)
279 return repo.root[len(pathutil.normasprefix(parent.root)):]
280 return repo.root[len(p) + 1:]
281
280
282 def subrelpath(sub):
281 def subrelpath(sub):
283 """return path to this subrepo as seen from outermost repo"""
282 """return path to this subrepo as seen from outermost repo"""
@@ -19,6 +19,7 b" testmod('mercurial.hg')"
19 testmod('mercurial.hgweb.hgwebdir_mod')
19 testmod('mercurial.hgweb.hgwebdir_mod')
20 testmod('mercurial.match')
20 testmod('mercurial.match')
21 testmod('mercurial.minirst')
21 testmod('mercurial.minirst')
22 testmod('mercurial.pathutil')
22 testmod('mercurial.revset')
23 testmod('mercurial.revset')
23 testmod('mercurial.store')
24 testmod('mercurial.store')
24 testmod('mercurial.subrepo')
25 testmod('mercurial.subrepo')
General Comments 0
You need to be logged in to leave comments. Login now