##// END OF EJS Templates
manifest.add(): cleanup worklist construction and iteration
Benoit Boissinot -
r9415:e0cc9fa2 default
parent child Browse files
Show More
@@ -137,12 +137,15 b' class manifest(revlog.revlog):'
137 arraytext = array.array('c', "".join(text))
137 arraytext = array.array('c', "".join(text))
138 cachedelta = None
138 cachedelta = None
139 else:
139 else:
140 added, removed = changed
140 addlist = self._mancache[2]
141 addlist = self._mancache[2]
141
142
142 checkforbidden(changed[0])
143 checkforbidden(added)
143 # combine the changed lists into one list for sorting
144 # combine the changed lists into one list for sorting
144 work = [[x, 0] for x in changed[0]]
145 work = [(x, False) for x in added]
145 work[len(work):] = [[x, 1] for x in changed[1]]
146 work.extend((x, True) for x in removed)
147 # this could use heapq.merge() (from python2.6+) or equivalent
148 # since the lists are already sorted
146 work.sort()
149 work.sort()
147
150
148 delta = []
151 delta = []
@@ -155,18 +158,17 b' class manifest(revlog.revlog):'
155
158
156 # start with a readonly loop that finds the offset of
159 # start with a readonly loop that finds the offset of
157 # each line and creates the deltas
160 # each line and creates the deltas
158 for w in work:
161 for f, todelete in work:
159 f = w[0]
160 # bs will either be the index of the item or the insert point
162 # bs will either be the index of the item or the insert point
161 start, end = self._search(addbuf, f, start)
163 start, end = self._search(addbuf, f, start)
162 if w[1] == 0:
164 if not todelete:
163 l = "%s\000%s%s\n" % (f, revlog.hex(map[f]), map.flags(f))
165 l = "%s\000%s%s\n" % (f, revlog.hex(map[f]), map.flags(f))
164 else:
166 else:
167 if start == end:
168 # item we want to delete was not found, error out
169 raise AssertionError(
170 _("failed to remove %s from manifest") % f)
165 l = ""
171 l = ""
166 if start == end and w[1] == 1:
167 # item we want to delete was not found, error out
168 raise AssertionError(
169 _("failed to remove %s from manifest") % f)
170 if dstart != None and dstart <= start and dend >= start:
172 if dstart != None and dstart <= start and dend >= start:
171 if dend < end:
173 if dend < end:
172 dend = end
174 dend = end
General Comments 0
You need to be logged in to leave comments. Login now