mercurial/dirstate.py
changeset 4230 c93562fb12cc
parent 4229 24c22a3f2ef8
child 4232 0d51eb296fb9
child 4330 1b9fc3f48861
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -34,10 +34,14 @@ class dirstate(object):
         cwd = os.getcwd()
         if cwd == self.root: return ''
         # self.root ends with a path separator if self.root is '/' or 'C:\'
-        common_prefix_len = len(self.root)
-        if not self.root.endswith(os.sep):
-            common_prefix_len += 1
-        return cwd[common_prefix_len:]
+        rootsep = self.root
+        if not rootsep.endswith(os.sep):
+            rootsep += os.sep
+        if cwd.startswith(rootsep):
+            return cwd[len(rootsep):]
+        else:
+            # we're outside the repo. return an absolute path.
+            return cwd
 
     def hgignore(self):
         '''return the contents of .hgignore files as a list of patterns.