[PATCH 16 of 21 RFC] revlog: allow building deltas against local tombstones in _addrevision

michaeljedgar at gmail.com michaeljedgar at gmail.com
Wed Sep 10 19:26:17 CDT 2014


# HG changeset patch
# User Mike Edgar <adgar at google.com>
# Date 1409572170 -7200
#      Mon Sep 01 13:49:30 2014 +0200
# Node ID 8b22ce5c409431c8ec9fc0ac1b4d93e8816069cb
# Parent  1e85b2cd488fb1b13517345b3ff425e0da7b48b9
revlog: allow building deltas against local tombstones in _addrevision

When appending a revision of an existing file, via unbundle/pull/commit/etc,
the revlog will consider storing a delta for that revision (by comparing the
size of the delta chain against the fulltext of the revision). This requires
materializing the file at the delta base revision unless the delta cache hits.

That materialization will fail if the chosen delta base is a censor tombstone;
this change permits delta construction to proceed in this case.

In practice, this is required for three major scenarios:

1. Building/importing a generaldelta can always miss the delta cache.
2. Unbundling a new revision of a file whose last revlog revision is censored
   AND the bundle's delta base is not the tombstoned last revision.
3. Committing a new revision of a file whose last revlog revision is censored.
   This is possible purely locally with 1 head at all times:
   r0) commit file
   r1) delete file
   r1) censor file at r0
   r2) commit file

diff -r 1e85b2cd488f -r 8b22ce5c4094 mercurial/revlog.py
--- a/mercurial/revlog.py	Wed Sep 03 16:34:59 2014 -0400
+++ b/mercurial/revlog.py	Mon Sep 01 13:49:30 2014 +0200
@@ -1184,7 +1184,11 @@
                 delta = cachedelta[1]
             else:
                 t = buildtext()
-                ptext = self.revision(self.node(rev))
+                try:
+                    ptext = self.revision(self.node(rev))
+                except CensoredNodeError, e:
+                    # building a new delta against a local tombstone is allowed
+                    ptext = e.metadata
                 delta = mdiff.textdiff(ptext, t)
             data = self.compress(delta)
             l = len(data[1]) + len(data[0])


More information about the Mercurial-devel mailing list