bug: repo at root of filesystem does not work correctly

Josef "Jeff" Sipek jeffpc at josefsipek.net
Tue Nov 7 00:01:28 CST 2006


Just a comment about the code...

--- mercurial-0.9/mercurial/dirstate.py.orig	2006-07-24 16:08:35.000000000 -0700
+++ mercurial-0.9/mercurial/dirstate.py	2006-11-06 14:55:24.000000000 -0800
@@ -32,7 +32,10 @@
     def getcwd(self):
         cwd = os.getcwd()
         if cwd == self.root: return ''
-        return cwd[len(self.root) + 1:]
+        if self.root == '/':
+            return cwd[len(self.root):]

If self.root == '/', then we know that len(self.root) == 1. Not sure if it
makes sense to "optimize."

@@ -352,7 +352,10 @@
                 names = os.listdir(top)
                 names.sort()
                 # nd is the top of the repository dir tree
-                nd = util.normpath(top[len(self.root) + 1:])
+                if self.root == '/':
+                    nd = util.normpath(top[len(self.root):])

Ditto.

Jeff.

-- 
Don't drink and derive. Alcohol and algebra don't mix.


More information about the Mercurial mailing list