revlog: support importing censored file revision tombstones
authorMike Edgar <adgar@google.com>
Wed, 03 Sep 2014 16:34:29 -0400
changeset 22934 8a096d4d0862
parent 22933 3a60cd44e619
child 22935 ee297602a208
revlog: support importing censored file revision tombstones This change allows a revision log to not fail integrity checks when applying a changegroup delta (eg from a bundle) results in a censored file tombstone. The tombstone is inserted as-is, so future integrity verification will observe the tombstone. Deltas based on the tombstone will also remain correct. The new code path is encountered for *exactly* the cases where _addrevision is importing a tombstone from a changegroup. When committing a file containing the "magic" tombstone text, the "text" parameter will be non-empty and the checkhash call is not executed (and when committing, the node will be computed to match the "magic" tombstone text).
mercurial/revlog.py
--- a/mercurial/revlog.py	Tue Oct 14 16:16:04 2014 -0400
+++ b/mercurial/revlog.py	Wed Sep 03 16:34:29 2014 -0400
@@ -42,6 +42,7 @@
 
 RevlogError = error.RevlogError
 LookupError = error.LookupError
+CensoredNodeError = error.CensoredNodeError
 
 def getoffset(q):
     return int(q >> 16)
@@ -1176,7 +1177,10 @@
             ifh.flush()
             basetext = self.revision(self.node(cachedelta[0]))
             btext[0] = mdiff.patch(basetext, cachedelta[1])
-            self.checkhash(btext[0], p1, p2, node)
+            try:
+                self.checkhash(btext[0], p1, p2, node)
+            except CensoredNodeError:
+                pass # always import a censor tombstone.
             return btext[0]
 
         def builddelta(rev):