diff mercurial/util.py @ 884:087771ebe2e6

Fix walk code for files that do not exist anywhere, and unhandled types. Prior to this, a file that did not exist was reported as showing up in the filesystem, as were files of unsupported types (such as fifos). Now, an error message is printed and nothing is returned in such cases. This change also moves the commands.pathto function to the util module, as the walk code needs it to print non-confusing error messages.
author Bryan O'Sullivan <bos@serpentine.com>
date Fri, 12 Aug 2005 11:16:58 -0800
parents 63ca8a68d59e
children 6594ba2a0f51 509de8ab6f31
line wrap: on
line diff
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -69,6 +69,16 @@ def globre(pat, head = '^', tail = '$'):
 
 _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)
+    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)
+
 def canonpath(repo, cwd, myname):
     rootsep = repo.root + os.sep
     name = myname