# HG changeset patch # User Benoit Boissinot # Date 2010-08-23 11:28:04 # Node ID 2315a95ee88759ad2ed250dcbf2fc93be4073688 # Parent 56a7721ee3ec4d1785fd8b594efae0b6aa1e1dbd mdiff.patch(): add a special case for when the base text is empty remove the special casing from revlog.addgroup() diff --git a/mercurial/mdiff.py b/mercurial/mdiff.py --- a/mercurial/mdiff.py +++ b/mercurial/mdiff.py @@ -260,6 +260,9 @@ def patchtext(bin): 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 diff --git a/mercurial/revlog.py b/mercurial/revlog.py --- a/mercurial/revlog.py +++ b/mercurial/revlog.py @@ -1353,12 +1353,7 @@ class revlog(object): 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)