Mercurial > hg
comparison 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 |
comparison
equal
deleted
inserted
replaced
883:63ca8a68d59e | 884:087771ebe2e6 |
---|---|
66 else: | 66 else: |
67 res += re.escape(c) | 67 res += re.escape(c) |
68 return head + res + tail | 68 return head + res + tail |
69 | 69 |
70 _globchars = {'[': 1, '{': 1, '*': 1, '?': 1} | 70 _globchars = {'[': 1, '{': 1, '*': 1, '?': 1} |
71 | |
72 def pathto(n1, n2): | |
73 '''return the relative path from one place to another''' | |
74 if not n1: return n2 | |
75 a, b = n1.split(os.sep), n2.split(os.sep) | |
76 a.reverse(), b.reverse() | |
77 while a and b and a[-1] == b[-1]: | |
78 a.pop(), b.pop() | |
79 b.reverse() | |
80 return os.sep.join((['..'] * len(a)) + b) | |
71 | 81 |
72 def canonpath(repo, cwd, myname): | 82 def canonpath(repo, cwd, myname): |
73 rootsep = repo.root + os.sep | 83 rootsep = repo.root + os.sep |
74 name = myname | 84 name = myname |
75 if not name.startswith(os.sep): | 85 if not name.startswith(os.sep): |