changeset 1678:b345cc4c22c0

reverting 11d12bd6e1dcd9610fa26e97d25e7ad553e8ffa5 passing local everywhere violate the layering
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Thu, 15 Dec 2005 18:04:05 +0100
parents 11d12bd6e1dc
children 675ca845c2f8
files mercurial/changelog.py mercurial/filelog.py mercurial/localrepo.py mercurial/manifest.py mercurial/revlog.py mercurial/statichttprepo.py
diffstat 6 files changed, 61 insertions(+), 77 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/changelog.py	Thu Dec 08 15:12:02 2005 +0100
+++ b/mercurial/changelog.py	Thu Dec 15 18:04:05 2005 +0100
@@ -11,9 +11,8 @@
 demandload(globals(), "os time util")
 
 class changelog(revlog):
-    def __init__(self, opener, local=True):
-        revlog.__init__(self, opener, "00changelog.i", "00changelog.d",
-                        local=local)
+    def __init__(self, opener):
+        revlog.__init__(self, opener, "00changelog.i", "00changelog.d")
 
     def extract(self, text):
         if not text:
--- a/mercurial/filelog.py	Thu Dec 08 15:12:02 2005 +0100
+++ b/mercurial/filelog.py	Thu Dec 15 18:04:05 2005 +0100
@@ -11,11 +11,10 @@
 demandload(globals(), "bdiff")
 
 class filelog(revlog):
-    def __init__(self, opener, path, local=True):
+    def __init__(self, opener, path):
         revlog.__init__(self, opener,
                         os.path.join("data", self.encodedir(path + ".i")),
-                        os.path.join("data", self.encodedir(path + ".d")),
-                        local=local)
+                        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
--- a/mercurial/localrepo.py	Thu Dec 08 15:12:02 2005 +0100
+++ b/mercurial/localrepo.py	Thu Dec 15 18:04:05 2005 +0100
@@ -30,8 +30,8 @@
         self.ui = ui
         self.opener = util.opener(self.path)
         self.wopener = util.opener(self.root)
-        self.manifest = manifest.manifest(self.opener, local=self.local())
-        self.changelog = changelog.changelog(self.opener, local=self.local())
+        self.manifest = manifest.manifest(self.opener)
+        self.changelog = changelog.changelog(self.opener)
         self.tagscache = None
         self.nodetagscache = None
         self.encodepats = None
@@ -161,7 +161,7 @@
 
     def file(self, f):
         if f[0] == '/': f = f[1:]
-        return filelog.filelog(self.opener, f, local=self.local())
+        return filelog.filelog(self.opener, f)
 
     def getcwd(self):
         return self.dirstate.getcwd()
--- a/mercurial/manifest.py	Thu Dec 08 15:12:02 2005 +0100
+++ b/mercurial/manifest.py	Thu Dec 15 18:04:05 2005 +0100
@@ -12,11 +12,10 @@
 demandload(globals(), "bisect array")
 
 class manifest(revlog):
-    def __init__(self, opener, local=True):
+    def __init__(self, opener):
         self.mapcache = None
         self.listcache = None
-        revlog.__init__(self, opener, "00manifest.i", "00manifest.d",
-                        local=local)
+        revlog.__init__(self, opener, "00manifest.i", "00manifest.d")
 
     def read(self, node):
         if node == nullid: return {} # don't upset local cache
--- a/mercurial/revlog.py	Thu Dec 08 15:12:02 2005 +0100
+++ b/mercurial/revlog.py	Thu Dec 15 18:04:05 2005 +0100
@@ -177,7 +177,7 @@
     remove data, and can use some simple techniques to avoid the need
     for locking while reading.
     """
-    def __init__(self, opener, indexfile, datafile, local=True):
+    def __init__(self, opener, indexfile, datafile):
         """
         create a revlog object
 
@@ -188,7 +188,6 @@
         self.datafile = datafile
         self.opener = opener
         self.cache = None
-        self.local = local # XXX only needed because statichttp
 
         try:
             i = self.opener(self.indexfile).read()
@@ -651,7 +650,7 @@
                 #print "next x"
                 gx = x.next()
 
-    def group(self, nodelist, lookup, infocollect=None):
+    def group(self, nodelist, lookup, infocollect = None):
         """calculate a delta group
 
         Given a list of changeset revs, return a set of deltas and
@@ -661,6 +660,7 @@
         changesets. parent is parent[0]
         """
         revs = [self.rev(n) for n in nodelist]
+        needed = dict.fromkeys(revs, 1)
 
         # if we don't have any revisions touched by these changesets, bail
         if not revs:
@@ -671,70 +671,59 @@
         p = self.parents(self.node(revs[0]))[0]
         revs.insert(0, self.rev(p))
 
-        if self.local:
-            mm = self.opener(self.datafile)
-            def chunk(r):
-                o = self.start(r)
-                l = self.length(r)
-                mm.seek(o)
-                return decompress(mm.read(l))
-        else:
-            # XXX: statichttp workaround
-            needed = dict.fromkeys(revs[1:], 1)
-            # for each delta that isn't contiguous in the log, we need to
-            # reconstruct the base, reconstruct the result, and then
-            # calculate the delta. We also need to do this where we've
-            # stored a full version and not a delta
-            for i in xrange(0, len(revs) - 1):
-                a, b = revs[i], revs[i + 1]
-                if a + 1 != b or self.base(b) == b:
-                    for j in xrange(self.base(a), a + 1):
-                        needed[j] = 1
-                    for j in xrange(self.base(b), b + 1):
-                        needed[j] = 1
+        # for each delta that isn't contiguous in the log, we need to
+        # reconstruct the base, reconstruct the result, and then
+        # calculate the delta. We also need to do this where we've
+        # stored a full version and not a delta
+        for i in xrange(0, len(revs) - 1):
+            a, b = revs[i], revs[i + 1]
+            if a + 1 != b or self.base(b) == b:
+                for j in xrange(self.base(a), a + 1):
+                    needed[j] = 1
+                for j in xrange(self.base(b), b + 1):
+                    needed[j] = 1
 
-            # calculate spans to retrieve from datafile
-            needed = needed.keys()
-            needed.sort()
-            spans = []
-            oo = -1
-            ol = 0
-            for n in needed:
-                if n < 0: continue
-                o = self.start(n)
-                l = self.length(n)
-                if oo + ol == o: # can we merge with the previous?
-                    nl = spans[-1][2]
-                    nl.append((n, l))
-                    ol += l
-                    spans[-1] = (oo, ol, nl)
-                else:
-                    oo = o
-                    ol = l
-                    spans.append((oo, ol, [(n, l)]))
+        # calculate spans to retrieve from datafile
+        needed = needed.keys()
+        needed.sort()
+        spans = []
+        oo = -1
+        ol = 0
+        for n in needed:
+            if n < 0: continue
+            o = self.start(n)
+            l = self.length(n)
+            if oo + ol == o: # can we merge with the previous?
+                nl = spans[-1][2]
+                nl.append((n, l))
+                ol += l
+                spans[-1] = (oo, ol, nl)
+            else:
+                oo = o
+                ol = l
+                spans.append((oo, ol, [(n, l)]))
 
-            # read spans in, divide up chunks
-            chunks = {}
-            for span in spans:
-                # we reopen the file for each span to make http happy for now
-                f = self.opener(self.datafile)
-                f.seek(span[0])
-                data = f.read(span[1])
+        # read spans in, divide up chunks
+        chunks = {}
+        for span in spans:
+            # we reopen the file for each span to make http happy for now
+            f = self.opener(self.datafile)
+            f.seek(span[0])
+            data = f.read(span[1])
 
-                # divide up the span
-                pos = 0
-                for r, l in span[2]:
-                    chunks[r] = decompress(data[pos: pos + l])
-                    pos += l
-            def chunk(r):
-                return chunks[r]
+            # divide up the span
+            pos = 0
+            for r, l in span[2]:
+                chunks[r] = decompress(data[pos: pos + l])
+                pos += l
 
         # helper to reconstruct intermediate versions
         def construct(text, base, rev):
-            bins = [chunk(r) for r in xrange(base + 1, rev + 1)]
+            bins = [chunks[r] for r in xrange(base + 1, rev + 1)]
             return mdiff.patches(text, bins)
 
         # build deltas
+        deltas = []
         for d in xrange(0, len(revs) - 1):
             a, b = revs[d], revs[d + 1]
             n = self.node(b)
@@ -746,7 +735,7 @@
             if a + 1 != b or self.base(b) == b:
                 if a >= 0:
                     base = self.base(a)
-                    ta = chunk(self.base(a))
+                    ta = chunks[self.base(a)]
                     ta = construct(ta, base, a)
                 else:
                     ta = ""
@@ -756,11 +745,11 @@
                     base = a
                     tb = ta
                 else:
-                    tb = chunk(self.base(b))
+                    tb = chunks[self.base(b)]
                 tb = construct(tb, base, b)
                 d = self.diff(ta, tb)
             else:
-                d = chunk(b)
+                d = chunks[b]
 
             p = self.parents(n)
             meta = n + p[0] + p[1] + lookup(n)
--- a/mercurial/statichttprepo.py	Thu Dec 08 15:12:02 2005 +0100
+++ b/mercurial/statichttprepo.py	Thu Dec 15 18:04:05 2005 +0100
@@ -31,12 +31,10 @@
         self.path = (path + "/.hg")
         self.ui = ui
         self.opener = opener(self.path)
-        self.manifest = manifest.manifest(self.opener, local=self.local())
-        self.changelog = changelog.changelog(self.opener, local=self.local())
+        self.manifest = manifest.manifest(self.opener)
+        self.changelog = changelog.changelog(self.opener)
         self.tagscache = None
         self.nodetagscache = None
-        self.encodepats = None
-        self.decodepats = None
 
     def dev(self):
         return -1