mdiff.patch(): add a special case for when the base text is empty
authorBenoit Boissinot <benoit.boissinot@ens-lyon.org>
Mon, 23 Aug 2010 13:28:04 +0200
changeset 12025 2315a95ee887
parent 12024 56a7721ee3ec
child 12027 e1a3d7ed478e
mdiff.patch(): add a special case for when the base text is empty remove the special casing from revlog.addgroup()
mercurial/mdiff.py
mercurial/revlog.py
--- a/mercurial/mdiff.py	Mon Aug 23 13:24:19 2010 +0200
+++ b/mercurial/mdiff.py	Mon Aug 23 13:28:04 2010 +0200
@@ -260,6 +260,9 @@
     return "".join(t)
 
 def patch(a, bin):
+    if len(a) == 0:
+        # skip over trivial delta header
+        return buffer(bin, 12)
     return mpatch.patches(a, [bin])
 
 # similar to difflib.SequenceMatcher.get_matching_blocks
--- a/mercurial/revlog.py	Mon Aug 23 13:24:19 2010 +0200
+++ b/mercurial/revlog.py	Mon Aug 23 13:28:04 2010 +0200
@@ -1353,12 +1353,7 @@
                         dfh.flush()
                     ifh.flush()
                     text = self.revision(chain)
-                    if len(text) == 0:
-                        # skip over trivial delta header
-                        # text == '' in the case of nullrev or punched revision
-                        text = buffer(delta, 12)
-                    else:
-                        text = mdiff.patches(text, [delta])
+                    text = mdiff.patch(text, delta)
                     del delta
                     chk = self._addrevision(node, text, transaction, link,
                                             p1, p2, None, ifh, dfh)