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

Goffredo Baroncelli kreijack at libero.it
Thu Jul 14 21:40:43 UTC 2005


# HG changeset patch
# User kreijack at inwind.REMOVEME.it
# Node ID 7ba8a2d1e67ce5bebe38e425facc3ec1d9f6a22c
# Parent  695dd9a491dad2a63fe7770149da096c194bf0da
[PATCH 1/3] Permit directories ending in *.d or *.i

With this patches, mercurial stores the directories adding a '.dir' as postfix, so the
conflicts are avoided; this is the core patch: it adds a  class named filelog1;
this class manages the new style of directories naming

diff -r 695dd9a491da -r 7ba8a2d1e67c mercurial/hg.py
--- a/mercurial/hg.py   Wed Jul 13 09:53:27 2005
+++ b/mercurial/hg.py   Thu Jul 14 21:31:05 2005
@@ -85,6 +85,20 @@
             hist[n] = curr

         return zip(hist[n][0], hist[n][1].splitlines(1))
+
+class filelog1(filelog):
+    def __init__(self, opener, path):
+
+        (dirs,name)=os.path.split(path)
+        rdir=""
+        while dirs:
+            (tail,head) = os.path.split(dirs)
+            rdir = os.path.join(head + ".dir" ,rdir )
+            dirs = tail
+
+        path1 = os.path.join(rdir,name)
+
+        filelog.__init__(self, opener, path1)

 class manifest(revlog):
     def __init__(self, opener):
@@ -487,6 +501,26 @@
         if create:
             os.mkdir(self.path)
             os.mkdir(self.join("data"))
+            f=file(self.join("version"),"w")
+            f.write("1\n")
+            f.close( )
+            self.revision = 1
+        else:
+            self.revision = 0
+            if os.path.isfile(self.join("version")):
+                f = file(self.join("version"))
+                self.revision = int(f.readline( ))
+                f.close( )
+
+            if self.revision > 1 or self.revision < 0:
+                ui.warn("incorrect repository version: ")
+                ui.warn("it's %s instead of 0 or 1\n"%(self.revision))
+                return
+
+            if self.revision < 1:
+                ui.warn("the repository version is old: ")
+                ui.warn("it's %s instead of 1\n"%(self.revision))
+                ui.warn("try hg repoupgrade\n")

         self.opener = opener(self.path)
         self.wopener = opener(self.root)
@@ -628,7 +662,10 @@

     def file(self, f):
         if f[0] == '/': f = f[1:]
-        return filelog(self.opener, f)
+        if self.revision == 1:
+            return filelog1(self.opener, f)
+        else:
+            return filelog(self.opener, f)

     def getcwd(self):
         cwd = os.getcwd()

-- 
gpg key@ keyserver.linux.it: Goffredo Baroncelli (ghigo) <kreijack AT inwind.it>
Key fingerprint = CE3C 7E01 6782 30A3 5B87  87C0 BB86 505C 6B2A CFF9
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.mercurial-scm.org/pipermail/mercurial/attachments/20050714/59db84f2/attachment-0001.asc>


More information about the Mercurial mailing list