[PATCH 2 of 2] manifest: move addlistdelta to module-level
Augie Fackler
raf at durin42.com
Wed Sep 10 18:45:51 UTC 2014
# HG changeset patch
# User Augie Fackler <raf at durin42.com>
# Date 1407430040 14400
# Thu Aug 07 12:47:20 2014 -0400
# Node ID be53282bd69c489b3ad8909be0391fb04d6b512a
# Parent 9c62e343f996d00e90614f42b7148760974201f2
manifest: move addlistdelta to module-level
Again, there's no reason for this to be inside manifest.add, so we'll
define it only once.
diff --git a/mercurial/manifest.py b/mercurial/manifest.py
--- a/mercurial/manifest.py
+++ b/mercurial/manifest.py
@@ -49,6 +49,28 @@
_("'\\n' and '\\r' disallowed in filenames: %r") % f)
+# apply the changes collected during the bisect loop to our addlist
+# return a delta suitable for addrevision
+def addlistdelta(addlist, x):
+ # for large addlist arrays, building a new array is cheaper
+ # than repeatedly modifying the existing one
+ currentposition = 0
+ newaddlist = array.array('c')
+
+ for start, end, content in x:
+ newaddlist += addlist[currentposition:start]
+ if content:
+ newaddlist += array.array('c', content)
+
+ currentposition = end
+
+ newaddlist += addlist[currentposition:]
+
+ deltatext = "".join(struct.pack(">lll", start, end, len(content))
+ + content for start, end, content in x)
+ return deltatext, newaddlist
+
+
class manifest(revlog.revlog):
def __init__(self, opener):
# we expect to deal with not more than four revs at a time,
@@ -140,27 +162,6 @@
def add(self, map, transaction, link, p1=None, p2=None,
changed=None):
- # apply the changes collected during the bisect loop to our addlist
- # return a delta suitable for addrevision
- def addlistdelta(addlist, x):
- # for large addlist arrays, building a new array is cheaper
- # than repeatedly modifying the existing one
- currentposition = 0
- newaddlist = array.array('c')
-
- for start, end, content in x:
- newaddlist += addlist[currentposition:start]
- if content:
- newaddlist += array.array('c', content)
-
- currentposition = end
-
- newaddlist += addlist[currentposition:]
-
- deltatext = "".join(struct.pack(">lll", start, end, len(content))
- + content for start, end, content in x)
- return deltatext, newaddlist
-
# if we're using the cache, make sure it is valid and
# parented by the same node we're diffing against
if not (changed and p1 and (p1 in self._mancache)):
More information about the Mercurial-devel
mailing list