bug: repo at root of filesystem does not work correctly

Thomas Arendsen Hein thomas at intevation.de
Fri Nov 10 05:53:09 CST 2006


* Markus F.X.J. Oberhumer <markus at oberhumer.com> [20061110 12:05]:
> Thomas Arendsen Hein wrote:
> >* Robert Shaw <rshaw at dpkg4x.org> [20061107 19:34]:
> >>--- a/mercurial/dirstate.py	Sat Oct 28 11:00:59 2006 +0200
> >>+++ b/mercurial/dirstate.py	Tue Nov 07 09:45:04 2006 -0800
> >>@@ -32,7 +32,11 @@ class dirstate(object):
> >>     def getcwd(self):
> >>         cwd = os.getcwd()
> >>         if cwd == self.root: return ''
> >>-        return cwd[len(self.root) + 1:]
> >>+        # self.root may end with a path separator when self.root == '/'
> >>+        common_prefix_len = len(self.root)
> >>+        if not self.root.endswith('/'):
> >>+            common_prefix_len += 1
> >>+        return cwd[common_prefix_len:]
> >I pushed this patch with '/' replaced with os.sep to crew.
> 
> Please don't forget about handling os.altsep as well.

self.root gets filled with the result of os.path.realpath, so
os.altsep won't be used here. But are there systems for which os.sep
can have a length != 1?

Thomas

-- 
Email: thomas at intevation.de
http://intevation.de/~thomas/


More information about the Mercurial mailing list