diff mercurial/util.py @ 4230:c93562fb12cc

Fix handling of paths when run outside the repo. The main problem was that dirstate.getcwd() returned just "", which was interpreted as "we're at the repo root". It now returns an absolute path. The util.pathto function was also changed to deal with the "cwd is an absolute path" case.
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Fri, 16 Mar 2007 00:22:58 -0300
parents 24c22a3f2ef8
children 0d51eb296fb9 5e3936eabe5d
line wrap: on
line diff
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -326,6 +326,10 @@ def pathto(root, n1, n2):
     n2 should always be relative to root.
     '''
     if not n1: return localpath(n2)
+    if os.path.isabs(n1):
+        if os.path.splitdrive(root)[0] != os.path.splitdrive(n1)[0]:
+            return os.path.join(root, localpath(n2))
+        n2 = '/'.join((pconvert(root), n2))
     a, b = n1.split(os.sep), n2.split('/')
     a.reverse()
     b.reverse()