Merge Windows path fixes.
--- a/mercurial/commands.py Fri Aug 12 11:18:41 2005 -0800
+++ b/mercurial/commands.py Fri Aug 12 15:10:09 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 = ''):
--- a/mercurial/hg.py Fri Aug 12 11:18:41 2005 -0800
+++ b/mercurial/hg.py Fri Aug 12 15:10:09 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
--- a/mercurial/util.py Fri Aug 12 11:18:41 2005 -0800
+++ b/mercurial/util.py Fri Aug 12 15:10:09 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)