[PATCH 3 of 5] revlog: allow building deltas against local tombstones in _addrevision

Mike Edgar adgar at google.com
Thu Nov 6 13:03:09 CST 2014


# HG changeset patch
# User Mike Edgar <adgar at google.com>
# Date 1409572170 -7200
#      Mon Sep 01 13:49:30 2014 +0200
# Node ID deb363985dc862197fdc06bd2ed9d00f08a8e508
# Parent  141a55f9e25968229e656e06cdd854cc132d6657
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 stored 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 stored 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 141a55f9e259 -r deb363985dc8 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
@@ -1192,7 +1192,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