changeset 786:902b12d55751

Fix the directory and revlog collision problem This adds escaping for directory names so that directory foo.i doesn't collide with the revision data for file foo.
author mpm@selenic.com
date Wed, 27 Jul 2005 18:50:32 -0800
parents 46a8dd3145cc
children f199e1887889
files mercurial/hg.py
diffstat 1 files changed, 16 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hg.py	Wed Jul 27 18:16:20 2005 -0800
+++ b/mercurial/hg.py	Wed Jul 27 18:50:32 2005 -0800
@@ -16,8 +16,22 @@
 class filelog(revlog):
     def __init__(self, opener, path):
         revlog.__init__(self, opener,
-                        os.path.join("data", path + ".i"),
-                        os.path.join("data", path + ".d"))
+                        os.path.join("data", self.encodedir(path + ".i")),
+                        os.path.join("data", self.encodedir(path + ".d")))
+
+    # This avoids a collision between a file named foo and a dir named
+    # foo.i or foo.d
+    def encodedir(self, path):
+        path.replace(".hg/", ".hg.hg/")
+        path.replace(".i/", ".i.hg/")
+        path.replace(".d/", ".i.hg/")
+        return path
+
+    def decodedir(self, path):
+        path.replace(".d.hg/", ".d/")
+        path.replace(".i.hg/", ".i/")
+        path.replace(".hg.hg/", ".hg/")
+        return path
 
     def read(self, node):
         t = self.revision(node)