mercurial/manifest.py
changeset 1402 9d2c2e6b32b5
parent 1400 cf9a1233738a
child 1451 54e4b187f69c
equal deleted inserted replaced
1401:fbf2b10011aa 1402:9d2c2e6b32b5
    42     def diff(self, a, b):
    42     def diff(self, a, b):
    43         # this is sneaky, as we're not actually using a and b
    43         # this is sneaky, as we're not actually using a and b
    44         if self.listcache and self.addlist and self.listcache[0] == a:
    44         if self.listcache and self.addlist and self.listcache[0] == a:
    45             d = mdiff.diff(self.listcache[1], self.addlist, 1)
    45             d = mdiff.diff(self.listcache[1], self.addlist, 1)
    46             if mdiff.patch(a, d) != b:
    46             if mdiff.patch(a, d) != b:
    47                 raise AssertionError("sortdiff failed!")
    47                 raise AssertionError(_("sortdiff failed!"))
    48             return d
    48             return d
    49         else:
    49         else:
    50             return mdiff.textdiff(a, b)
    50             return mdiff.textdiff(a, b)
    51 
    51 
    52     def add(self, map, flags, transaction, link, p1=None, p2=None,
    52     def add(self, map, flags, transaction, link, p1=None, p2=None,
   143                 if fn != f:
   143                 if fn != f:
   144                     # item not found, insert a new one
   144                     # item not found, insert a new one
   145                     end = bs
   145                     end = bs
   146                     if w[1] == 1:
   146                     if w[1] == 1:
   147                         raise AssertionError(
   147                         raise AssertionError(
   148                             "failed to remove %s from manifest\n" % f)
   148                             _("failed to remove %s from manifest\n") % f)
   149                 else:
   149                 else:
   150                     # item is found, replace/delete the existing line
   150                     # item is found, replace/delete the existing line
   151                     end = bs + 1
   151                     end = bs + 1
   152                 delta.append([start, end, offsets[start], offsets[end], l])
   152                 delta.append([start, end, offsets[start], offsets[end], l])
   153 
   153 
   157             else:
   157             else:
   158                 cachedelta = None
   158                 cachedelta = None
   159 
   159 
   160         text = "".join(self.addlist)
   160         text = "".join(self.addlist)
   161         if cachedelta and mdiff.patch(self.listcache[0], cachedelta) != text:
   161         if cachedelta and mdiff.patch(self.listcache[0], cachedelta) != text:
   162             raise AssertionError("manifest delta failure\n")
   162             raise AssertionError(_("manifest delta failure\n"))
   163         n = self.addrevision(text, transaction, link, p1, p2, cachedelta)
   163         n = self.addrevision(text, transaction, link, p1, p2, cachedelta)
   164         self.mapcache = (n, map, flags)
   164         self.mapcache = (n, map, flags)
   165         self.listcache = (text, self.addlist)
   165         self.listcache = (text, self.addlist)
   166         self.addlist = None
   166         self.addlist = None
   167 
   167