Patchwork [v3] revlog: support importing censored file revision tombstones

login
register
mail settings
Submitter adgar@google.com
Date Oct. 14, 2014, 8:56 p.m.
Message ID <40df4a188cfe6f26475f.1413320188@adgar.nyc.corp.google.com>
Download mbox | patch
Permalink /patch/6255/
State Accepted
Headers show

Comments

adgar@google.com - Oct. 14, 2014, 8:56 p.m.
# HG changeset patch
# User Mike Edgar <adgar@google.com>
# Date 1409776469 14400
#      Wed Sep 03 16:34:29 2014 -0400
# Node ID 40df4a188cfe6f26475f715d3ef981bd89d5ebcd
# Parent  32533d333ad47871be09852129a47c02d3d3c169
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).
Matt Mackall - Oct. 14, 2014, 9:08 p.m.
On Tue, 2014-10-14 at 16:56 -0400, adgar@google.com wrote:
> # HG changeset patch
> # User Mike Edgar <adgar@google.com>
> # Date 1409776469 14400
> #      Wed Sep 03 16:34:29 2014 -0400
> # Node ID 40df4a188cfe6f26475f715d3ef981bd89d5ebcd
> # Parent  32533d333ad47871be09852129a47c02d3d3c169
> revlog: support importing censored file revision tombstones

Queued for default, thanks.

Patch

diff -r 32533d333ad4 -r 40df4a188cfe mercurial/revlog.py
--- a/mercurial/revlog.py	Fri Oct 10 10:34:52 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 # always import a censor tombstone.
             return btext[0]
 
         def builddelta(rev):