Patchwork [14,of,21,RFC] revlog: support importing censored file revision tombstones

login
register
mail settings
Submitter michaeljedgar@gmail.com
Date Sept. 11, 2014, 12:26 a.m.
Message ID <8adefa28d6fb5816ff96.1410395175@adgar-macbookpro3.roam.corp.google.com>
Download mbox | patch
Permalink /patch/5789/
State Superseded
Commit 8a096d4d0862c5ba5b08ed22c732015bbc866add
Headers show

Comments

michaeljedgar@gmail.com - Sept. 11, 2014, 12:26 a.m.
# HG changeset patch
# User Mike Edgar <adgar@google.com>
# 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).

Patch

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):