From patchwork Thu Sep 11 00:26:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [14, of, 21, RFC] revlog: support importing censored file revision tombstones From: michaeljedgar@gmail.com X-Patchwork-Id: 5789 Message-Id: <8adefa28d6fb5816ff96.1410395175@adgar-macbookpro3.roam.corp.google.com> To: mercurial-devel@selenic.com Date: Wed, 10 Sep 2014 20:26:15 -0400 # HG changeset patch # User Mike Edgar # Date 1409776469 14400 # Wed Sep 03 16:34:29 2014 -0400 # Node ID 8adefa28d6fb5816ff9623408ef53c1d2d70f884 # Parent 4004f1fed45d6ea2a88272895a5e12ccf28cad0c 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). diff -r 4004f1fed45d -r 8adefa28d6fb mercurial/revlog.py --- a/mercurial/revlog.py Wed Sep 10 00:15:26 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) @@ -1168,7 +1169,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 # importing a censored tombstone return btext[0] def builddelta(rev):