# HG changeset patch # User Bryan O'Sullivan # Date 1123888012 28800 # Node ID 509de8ab6f31e92c8d85d8d61399f28d9baf512d # Parent 087771ebe2e6166fb6001a5f3f229043ae868cd3 Fix walk path handling on Windows diff -r 087771ebe2e6 -r 509de8ab6f31 mercurial/commands.py --- a/mercurial/commands.py Fri Aug 12 11:16:58 2005 -0800 +++ b/mercurial/commands.py Fri Aug 12 15:06:52 2005 -0800 @@ -32,8 +32,7 @@ def relpath(repo, args): cwd = repo.getcwd() if cwd: - return [util.pconvert(os.path.normpath(os.path.join(cwd, x))) - for x in args] + return [util.normpath(os.path.join(cwd, x)) for x in args] return args def matchpats(repo, cwd, pats = [], opts = {}, head = ''): diff -r 087771ebe2e6 -r 509de8ab6f31 mercurial/hg.py --- a/mercurial/hg.py Fri Aug 12 11:16:58 2005 -0800 +++ b/mercurial/hg.py Fri Aug 12 15:06:52 2005 -0800 @@ -312,14 +312,14 @@ l = file(self.wjoin(".hgignore")) for pat in l: if pat != "\n": - p = util.pconvert(pat[:-1]) + p = pat[:-1] try: - r = re.compile(p) + re.compile(p) except: self.ui.warn("ignoring invalid ignore" + " regular expression '%s'\n" % p) else: - bigpat.append(util.pconvert(pat[:-1])) + bigpat.append(p) except IOError: pass if bigpat: @@ -501,7 +501,7 @@ if stat.S_ISDIR(st.st_mode): for dir, subdirs, fl in os.walk(f): d = dir[len(self.root) + 1:] - nd = os.path.normpath(d) + nd = util.normpath(d) if seen(nd): subdirs[:] = [] continue @@ -536,7 +536,7 @@ # not in .hgignore for src, fn in util.unique(traverse()): - fn = os.path.normpath(fn) + fn = util.normpath(fn) if seen(fn): continue if fn not in dc and self.ignore(fn): continue diff -r 087771ebe2e6 -r 509de8ab6f31 mercurial/util.py --- 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)