comparison mercurial/util.py @ 2115:fd77b7ee4aac

Fix issue 165: `hg status' with abs path containing a symlink-to-dir fails
author Jim Meyering <list+hg@meyering.net>
date Fri, 21 Apr 2006 16:09:43 -0700
parents f5ebe964c6be
children 760339ccc799
comparison
equal deleted inserted replaced
2114:98cc126f9f3f 2115:fd77b7ee4aac
213 audit_path(name) 213 audit_path(name)
214 return pconvert(name) 214 return pconvert(name)
215 elif name == root: 215 elif name == root:
216 return '' 216 return ''
217 else: 217 else:
218 # Determine whether `name' is in the hierarchy at or beneath `root',
219 # by iterating name=dirname(name) until that causes no change (can't
220 # check name == '/', because that doesn't work on windows). For each
221 # `name', compare dev/inode numbers. If they match, the list `rel'
222 # holds the reversed list of components making up the relative file
223 # name we want.
224 root_st = os.stat(root)
225 rel = []
226 while True:
227 try:
228 name_st = os.stat(name)
229 except OSError:
230 break
231 if os.path.samestat(name_st, root_st):
232 rel.reverse()
233 name = os.path.join(*rel)
234 audit_path(name)
235 return pconvert(name)
236 dirname, basename = os.path.split(name)
237 rel.append(basename)
238 if dirname == name:
239 break
240 name = dirname
241
218 raise Abort('%s not under root' % myname) 242 raise Abort('%s not under root' % myname)
219 243
220 def matcher(canonroot, cwd='', names=['.'], inc=[], exc=[], head='', src=None): 244 def matcher(canonroot, cwd='', names=['.'], inc=[], exc=[], head='', src=None):
221 return _matcher(canonroot, cwd, names, inc, exc, head, 'glob', src) 245 return _matcher(canonroot, cwd, names, inc, exc, head, 'glob', src)
222 246