[PATCH 3 of 9] revlog: introduce flag for punched revisions
Vishakh H
vsh426 at gmail.com
Tue Jul 6 05:47:02 CDT 2010
# HG changeset patch
# User Vishakh H <vsh426 at gmail.com>
# Date 1278412035 -19800
# Branch stable
# Node ID cdcee07095c888d1c6a168d95f7badb0b4de82f7
# Parent 41e3851011511e3b7d5e9b9dc11f07e7a5fd0ce4
revlog: introduce flag for punched revisions
REVLOG_PUNCHED_FLAG = 2, is used to mark a revision as punched.
REVLOG_KNOWN_FLAGS is the accumulation of all know revision flags.
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -30,6 +30,8 @@
REVLOG_DEFAULT_FLAGS = REVLOGNGINLINEDATA
REVLOG_DEFAULT_FORMAT = REVLOGNG
REVLOG_DEFAULT_VERSION = REVLOG_DEFAULT_FORMAT | REVLOG_DEFAULT_FLAGS
+REVLOG_PUNCHED_FLAG = 2
+REVLOG_KNOWN_FLAGS = REVLOG_PUNCHED_FLAG
# amount of data read unconditionally, should be >= 4
# when not inline: threshold for using lazy index
@@ -1022,9 +1024,9 @@
base = self.base(rev)
# check rev flags
- if self.flags(rev):
+ if self.flags(rev, ~REVLOG_KNOWN_FLAGS):
raise RevlogError(_('incompatible revision flag %x') %
- self.flags(rev))
+ self.flags(rev, ~REVLOG_KNOWN_FLAGS))
# do we have useful data cached?
if self._cache and self._cache[1] >= base and self._cache[1] < rev:
@@ -1039,7 +1041,8 @@
bins = [self._chunk(r) for r in xrange(base + 1, rev + 1)]
text = mdiff.patches(text, bins)
p1, p2 = self.parents(node)
- if node != hash(text, p1, p2):
+ if (node != hash(text, p1, p2) and
+ not self.flags(rev, REVLOG_PUNCHED_FLAG)):
raise RevlogError(_("integrity check failed on %s:%d")
% (self.indexfile, rev))
@@ -1125,7 +1128,8 @@
# full versions are inserted when the needed deltas
# become comparable to the uncompressed text
- if not curr or dist > len(text) * 2:
+ if (not curr or dist > len(text) * 2 or
+ self.flags(base, REVLOG_PUNCHED_FLAG)):
data = compress(text)
l = len(data[1]) + len(data[0])
base = curr
More information about the Mercurial-devel
mailing list