hg status issue on windows with tip?
Stephen Darnell
sdarnell at esmertec.com
Thu Aug 11 05:03:30 CDT 2005
Bryan,
Thanks for dusting off your windows setup (btw I'm using vanilla windows
without cygwin or mingw).
I have fixes for the new walking code (patch attached).
I've also added a util.normpath() that does a os.path.normpath()
followed by a pconvert(), but is more efficient on Unix.
I suspect it might be slightly more efficient to generate the
walk with target separators, and then do the final canonicalisation
on the yield. But I wanted to disturb things as little as possible.
The split('/\\') is ugly and may not work on every concievable platform,
but apart from adding os.sep I can't think of a better solution.
I'd appreciate if someone could review these changes and apply soon.
Thanks,
Stephen
-------------- next part --------------
# HG changeset patch
# User Stephen Darnell
# Node ID c3b0996919882bacb933a4257ac4b899d804c368
# Parent 6390c377a9e617e01061d33f3729948d72b6f54f
Fix the walking code to normalise paths consistently for Windows
Add a util.normpath() that should usually be used instead of os.path.normpath()
if the canonical / separators are needed.
diff -r 6390c377a9e6 -r c3b099691988 mercurial/commands.py
--- a/mercurial/commands.py Tue Aug 09 17:36:34 2005
+++ b/mercurial/commands.py Thu Aug 11 09:42:12 2005
@@ -35,7 +35,7 @@
def relpath(repo, args):
cwd = repo.getcwd()
if cwd:
- return [util.pconvert(os.path.normpath(os.path.join(cwd, x)))
+ return [util.normpath(os.path.join(cwd, x))
for x in args]
return args
@@ -46,12 +46,12 @@
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)
+ a, b = n1.split('/\\'), n2.split('/\\')
a.reverse(), b.reverse()
while a and b and a[-1] == b[-1]:
a.pop(), b.pop()
b.reverse()
- return os.sep.join((['..'] * len(a)) + b)
+ return '/'.join((['..'] * len(a)) + b)
def makewalk(repo, pats, opts, head = ''):
cwd = repo.getcwd()
diff -r 6390c377a9e6 -r c3b099691988 mercurial/hg.py
--- a/mercurial/hg.py Tue Aug 09 17:36:34 2005
+++ b/mercurial/hg.py Thu Aug 11 09:42:12 2005
@@ -450,7 +450,7 @@
if os.path.isdir(f):
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
@@ -475,7 +475,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 in dc:
del dc[fn]
diff -r 6390c377a9e6 -r c3b099691988 mercurial/util.py
--- a/mercurial/util.py Tue Aug 09 17:36:34 2005
+++ b/mercurial/util.py Thu Aug 11 09:42:12 2005
@@ -76,7 +76,7 @@
if c in _globchars: return 'glob', name
return 'relpath', name
- cwdsep = cwd + os.sep
+ cwdsep = cwd + '/'
def regex(name, tail):
'''convert a pattern into a regular expression'''
@@ -86,7 +86,7 @@
elif kind == 'path':
return '^' + re.escape(name) + '$'
if cwd: name = os.path.join(cwdsep, name)
- name = os.path.normpath(name)
+ name = normpath(name)
if name == '.': name = '**'
return head + globre(name, '', tail)
@@ -103,17 +103,17 @@
def globprefix(pat):
'''return the non-glob prefix of a path, e.g. foo/* -> foo'''
root = []
- for p in pat.split(os.sep):
+ for p in pat.split('/\\'):
if patkind(p)[0] == 'glob': break
root.append(p)
- return os.sep.join(root)
+ return '/'.join(root)
patkinds = map(patkind, names)
pats = [name for (kind, name) in patkinds if kind != 'relpath']
files = [name for (kind, name) in patkinds if kind == 'relpath']
roots = filter(None, map(globprefix, pats)) + files
if cwd: roots = [cwdsep + r for r in roots]
-
+
patmatch = matchfn(pats, '$') or always
filematch = matchfn(files, '(?:/|$)') or always
incmatch = matchfn(inc, '(?:/|$)') or always
@@ -165,7 +165,7 @@
def _readlock_file(pathname):
return file(pathname).read()
-# Platfor specific varients
+# Platform specific variants
if os.name == 'nt':
nulldev = 'NUL:'
@@ -177,6 +177,10 @@
def pconvert(path):
return path.replace("\\", "/")
+
+ def normpath(pathname):
+ """Normalise path and convert back to forward slashes"""
+ return pconvert(os.path.normpath(pathname))
makelock = _makelock_file
readlock = _readlock_file
@@ -206,6 +210,8 @@
def pconvert(path):
return path
+ normpath = os.path.normpath
+
def makelock(info, pathname):
try:
os.symlink(info, pathname)
More information about the Mercurial
mailing list