[PATCH 0/3] Permit directories ending in *.d or *.i

Thomas Arendsen Hein thomas at intevation.de
Sun Aug 7 11:48:22 CDT 2005


* Matt Mackall <mpm at selenic.com> [20050727 19:29]:
> On Thu, Jul 14, 2005 at 11:40:37PM +0200, Goffredo Baroncelli wrote:
> > due to the internal repository architecture, mercurial doesn't allow
> > the existence of directories ending in '.d' or '.i'. This patches
> > change how mercurial stores the file under directories. In fact the
> > file revlog of a file named 'a' is under '.hg/data/a.d' and
> > '.hg/data/a.i'. So if we add a file under a directory named 'a.d'
> > mercurial fails:
> 
> [catching up on my inbox, sorry for the delay]
> 
> I'd rather use an escaping scheme. Something likes:
> 
> def encodedir(dir):
>     if dir.endswith(".d") or dir.endswith(".i") or dir.endswith(".hg"):
>         dir += ".hg"
>     return dir
> 
> def decodedir(dir):
>     if dir.endswith(".hg"):
>         dir = dir[:-3]
>     return dir
> 
> I think this handles all the cases and should do so without breaking
> existing repos.

Your actual implementation had two bugs, one would have created a
directory with the wrong name, but fortunately the other rendered
encodedir and decodedir to have no effect at all.

Patch attached and pullable from me.

Thomas

-- 
Email: thomas at intevation.de
http://intevation.de/~thomas/
-------------- next part --------------
# HG changeset patch
# User Thomas Arendsen Hein <thomas at intevation.de>
# Node ID fbe964ae7325d1a0ee2d35682f33337b17eeec32
# Parent  a107c64c76bed4924b2543b1ab660f82582f26f6
Fixed encoding of directories ending in .d or .i:
One .d and .i was mixed up, and string replace method doesn't work in-place.

diff -r a107c64c76bed4924b2543b1ab660f82582f26f6 -r fbe964ae7325d1a0ee2d35682f33337b17eeec32 mercurial/hg.py
--- a/mercurial/hg.py	Sat Aug  6 20:59:22 2005
+++ b/mercurial/hg.py	Sun Aug  7 16:41:13 2005
@@ -22,16 +22,16 @@
     # 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
+        return (path
+                .replace(".hg/", ".hg.hg/")
+                .replace(".i/", ".i.hg/")
+                .replace(".d/", ".d.hg/"))
 
     def decodedir(self, path):
-        path.replace(".d.hg/", ".d/")
-        path.replace(".i.hg/", ".i/")
-        path.replace(".hg.hg/", ".hg/")
-        return path
+        return (path
+                .replace(".d.hg/", ".d/")
+                .replace(".i.hg/", ".i/")
+                .replace(".hg.hg/", ".hg/"))
 
     def read(self, node):
         t = self.revision(node)


More information about the Mercurial mailing list