diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -363,6 +363,9 @@ def canonpath(root, cwd, myname): except OSError: break if samestat(name_st, root_st): + if not rel: + # name was actually the same as root (maybe a symlink) + return '' rel.reverse() name = os.path.join(*rel) audit_path(name) diff --git a/tests/test-symlink-root b/tests/test-symlink-root new file mode 100755 --- /dev/null +++ b/tests/test-symlink-root @@ -0,0 +1,8 @@ +#!/bin/sh + +hg init a +ln -s a link +cd a +echo foo > foo +hg status +hg status ../link diff --git a/tests/test-symlink-root.out b/tests/test-symlink-root.out new file mode 100644 --- /dev/null +++ b/tests/test-symlink-root.out @@ -0,0 +1,2 @@ +? foo +? foo