# HG changeset patch # User Adrian Buehlmann # Date 2012-06-14 09:43:48 # Node ID 21e18c608b68e0c10c8a327537f9ceadbc8c3219 # Parent 6fc7fd72ba3ed85778aa3ef509038f23b5cda3ce scmutil: change canonpath to use util.samefile (issue2167) Fixes (on Windows in cmd.exe): $ hg -R v:\x\a status V:\x\a\bar abort: V:\x\a\bar not under root where v:\x\a is a valid repository with a checked-out file "bar" (Note the difference in casing: "v:\" versus "V:\") diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py --- a/mercurial/scmutil.py +++ b/mercurial/scmutil.py @@ -324,18 +324,16 @@ def canonpath(root, cwd, myname, auditor else: # Determine whether `name' is in the hierarchy at or beneath `root', # by iterating name=dirname(name) until that causes no change (can't - # check name == '/', because that doesn't work on windows). For each - # `name', compare dev/inode numbers. If they match, the list `rel' - # holds the reversed list of components making up the relative file - # name we want. - root_st = os.stat(root) + # check name == '/', because that doesn't work on windows). The list + # `rel' holds the reversed list of components making up the relative + # file name we want. rel = [] while True: try: - name_st = os.stat(name) + s = util.samefile(name, root) except OSError: - name_st = None - if name_st and util.samestat(name_st, root_st): + s = False + if s: if not rel: # name was actually the same as root (maybe a symlink) return ''