41 def diff(self, a, b): |
41 def diff(self, a, b): |
42 # this is sneaky, as we're not actually using a and b |
42 # this is sneaky, as we're not actually using a and b |
43 if self.listcache and self.addlist and self.listcache[0] == a: |
43 if self.listcache and self.addlist and self.listcache[0] == a: |
44 d = mdiff.diff(self.listcache[1], self.addlist, 1) |
44 d = mdiff.diff(self.listcache[1], self.addlist, 1) |
45 if mdiff.patch(a, d) != b: |
45 if mdiff.patch(a, d) != b: |
46 sys.stderr.write("*** sortdiff failed, falling back ***\n") |
46 raise AssertionError("sortdiff failed!") |
47 return mdiff.textdiff(a, b) |
|
48 return d |
47 return d |
49 else: |
48 else: |
50 return mdiff.textdiff(a, b) |
49 return mdiff.textdiff(a, b) |
51 |
50 |
52 def add(self, map, flags, transaction, link, p1=None, p2=None, |
51 def add(self, map, flags, transaction, link, p1=None, p2=None, |
142 start = bs |
141 start = bs |
143 if fn != f: |
142 if fn != f: |
144 # item not found, insert a new one |
143 # item not found, insert a new one |
145 end = bs |
144 end = bs |
146 if w[1] == 1: |
145 if w[1] == 1: |
147 sys.stderr.write("failed to remove %s from manifest\n" |
146 raise AssertionError( |
148 % f) |
147 "failed to remove %s from manifest\n" % f) |
149 sys.exit(1) |
|
150 else: |
148 else: |
151 # item is found, replace/delete the existing line |
149 # item is found, replace/delete the existing line |
152 end = bs + 1 |
150 end = bs + 1 |
153 delta.append([start, end, offsets[start], offsets[end], l]) |
151 delta.append([start, end, offsets[start], offsets[end], l]) |
154 |
152 |
158 else: |
156 else: |
159 cachedelta = None |
157 cachedelta = None |
160 |
158 |
161 text = "".join(self.addlist) |
159 text = "".join(self.addlist) |
162 if cachedelta and mdiff.patch(self.listcache[0], cachedelta) != text: |
160 if cachedelta and mdiff.patch(self.listcache[0], cachedelta) != text: |
163 sys.stderr.write("manifest delta failure\n") |
161 raise AssertionError("manifest delta failure\n") |
164 sys.exit(1) |
|
165 n = self.addrevision(text, transaction, link, p1, p2, cachedelta) |
162 n = self.addrevision(text, transaction, link, p1, p2, cachedelta) |
166 self.mapcache = (n, map, flags) |
163 self.mapcache = (n, map, flags) |
167 self.listcache = (text, self.addlist) |
164 self.listcache = (text, self.addlist) |
168 self.addlist = None |
165 self.addlist = None |
169 |
166 |