Mercurial > public > mercurial-scm > hg
diff mercurial/util.py @ 886:509de8ab6f31
Fix walk path handling on Windows
author | Bryan O'Sullivan <bos@serpentine.com> |
---|---|
date | Fri, 12 Aug 2005 15:06:52 -0800 |
parents | 087771ebe2e6 |
children | 882756761433 e7a943e8c52b |
line wrap: on
line diff
--- a/mercurial/util.py Fri Aug 12 11:16:58 2005 -0800 +++ b/mercurial/util.py Fri Aug 12 15:06:52 2005 -0800 @@ -70,9 +70,10 @@ _globchars = {'[': 1, '{': 1, '*': 1, '?': 1} def pathto(n1, n2): - '''return the relative path from one place to another''' - if not n1: return n2 - a, b = n1.split(os.sep), n2.split(os.sep) + '''return the relative path from one place to another. + this returns a path in the form used by the local filesystem, not hg.''' + if not n1: return localpath(n2) + a, b = n1.split('/'), n2.split('/') a.reverse(), b.reverse() while a and b and a[-1] == b[-1]: a.pop(), b.pop() @@ -86,7 +87,7 @@ name = os.path.join(repo.root, cwd, name) name = os.path.normpath(name) if name.startswith(rootsep): - return name[len(rootsep):] + return pconvert(name[len(rootsep):]) elif name == repo.root: return '' else: @@ -121,7 +122,7 @@ for p in pat.split(os.sep): if patkind(p)[0] == 'glob': break root.append(p) - return os.sep.join(root) + return '/'.join(root) pats = [] files = [] @@ -204,6 +205,12 @@ def pconvert(path): return path.replace("\\", "/") + def localpath(path): + return path.replace('/', '\\') + + def normpath(path): + return pconvert(os.path.normpath(path)) + makelock = _makelock_file readlock = _readlock_file @@ -232,6 +239,11 @@ def pconvert(path): return path + def localpath(path): + return path + + normpath = os.path.normpath + def makelock(info, pathname): try: os.symlink(info, pathname)