##// END OF EJS Templates
manifest: move addlistdelta to module-level...
Augie Fackler -
r22409:8f09b785 default
parent child Browse files
Show More
@@ -49,6 +49,28 b' def checkforbidden(l):'
49 _("'\\n' and '\\r' disallowed in filenames: %r") % f)
49 _("'\\n' and '\\r' disallowed in filenames: %r") % f)
50
50
51
51
52 # apply the changes collected during the bisect loop to our addlist
53 # return a delta suitable for addrevision
54 def addlistdelta(addlist, x):
55 # for large addlist arrays, building a new array is cheaper
56 # than repeatedly modifying the existing one
57 currentposition = 0
58 newaddlist = array.array('c')
59
60 for start, end, content in x:
61 newaddlist += addlist[currentposition:start]
62 if content:
63 newaddlist += array.array('c', content)
64
65 currentposition = end
66
67 newaddlist += addlist[currentposition:]
68
69 deltatext = "".join(struct.pack(">lll", start, end, len(content))
70 + content for start, end, content in x)
71 return deltatext, newaddlist
72
73
52 class manifest(revlog.revlog):
74 class manifest(revlog.revlog):
53 def __init__(self, opener):
75 def __init__(self, opener):
54 # we expect to deal with not more than four revs at a time,
76 # we expect to deal with not more than four revs at a time,
@@ -140,27 +162,6 b' class manifest(revlog.revlog):'
140
162
141 def add(self, map, transaction, link, p1=None, p2=None,
163 def add(self, map, transaction, link, p1=None, p2=None,
142 changed=None):
164 changed=None):
143 # apply the changes collected during the bisect loop to our addlist
144 # return a delta suitable for addrevision
145 def addlistdelta(addlist, x):
146 # for large addlist arrays, building a new array is cheaper
147 # than repeatedly modifying the existing one
148 currentposition = 0
149 newaddlist = array.array('c')
150
151 for start, end, content in x:
152 newaddlist += addlist[currentposition:start]
153 if content:
154 newaddlist += array.array('c', content)
155
156 currentposition = end
157
158 newaddlist += addlist[currentposition:]
159
160 deltatext = "".join(struct.pack(">lll", start, end, len(content))
161 + content for start, end, content in x)
162 return deltatext, newaddlist
163
164 # if we're using the cache, make sure it is valid and
165 # if we're using the cache, make sure it is valid and
165 # parented by the same node we're diffing against
166 # parented by the same node we're diffing against
166 if not (changed and p1 and (p1 in self._mancache)):
167 if not (changed and p1 and (p1 in self._mancache)):
General Comments 0
You need to be logged in to leave comments. Login now