[PATCH 2 of 2] revlog: add shallow header flag
Vishakh H
vsh426 at gmail.com
Tue Aug 3 09:09:46 CDT 2010
# HG changeset patch
# User Vishakh H <vsh426 at gmail.com>
# Date 1280844499 -19800
# Node ID 465b712dff6351b64ac6c834175f7a051182025a
# Parent 242d826efed714b83716cae8a61a744b7e4c5cd4
revlog: add shallow header flag
REVLOGSHALLOW header flag to mark revlog as shallow.
The _shallow attribute of the revlog is used to check if the header flag is set.
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -23,13 +23,17 @@
_decompress = zlib.decompress
_sha = util.sha1
-# revlog flags
+# revlog header flags
REVLOGV0 = 0
REVLOGNG = 1
REVLOGNGINLINEDATA = (1 << 16)
+REVLOGSHALLOW = (1 << 17)
REVLOG_DEFAULT_FLAGS = REVLOGNGINLINEDATA
REVLOG_DEFAULT_FORMAT = REVLOGNG
REVLOG_DEFAULT_VERSION = REVLOG_DEFAULT_FORMAT | REVLOG_DEFAULT_FLAGS
+REVLOGNG_FLAGS = REVLOGNGINLINEDATA | REVLOGSHALLOW
+
+# revlog index flags
REVIDX_PUNCHED_FLAG = 2
REVIDX_KNOWN_FLAGS = REVIDX_PUNCHED_FLAG
@@ -422,7 +426,7 @@
remove data, and can use some simple techniques to avoid the need
for locking while reading.
"""
- def __init__(self, opener, indexfile):
+ def __init__(self, opener, indexfile, shallowroot=None):
"""
create a revlog object
@@ -436,12 +440,15 @@
self._chunkcache = (0, '')
self.nodemap = {nullid: nullrev}
self.index = []
+ self._shallowroot = shallowroot
v = REVLOG_DEFAULT_VERSION
if hasattr(opener, 'options') and 'defversion' in opener.options:
v = opener.options['defversion']
if v & REVLOGNG:
v |= REVLOGNGINLINEDATA
+ if shallowroot:
+ v |= REVLOGSHALLOW
i = ''
try:
@@ -458,12 +465,13 @@
self.version = v
self._inline = v & REVLOGNGINLINEDATA
+ self._shallow = v & REVLOGSHALLOW
flags = v & ~0xFFFF
fmt = v & 0xFFFF
if fmt == REVLOGV0 and flags:
raise RevlogError(_("index %s unknown flags %#04x for format v0")
% (self.indexfile, flags >> 16))
- elif fmt == REVLOGNG and flags & ~REVLOGNGINLINEDATA:
+ elif fmt == REVLOGNG and flags & ~REVLOGNG_FLAGS:
raise RevlogError(_("index %s unknown flags %#04x for revlogng")
% (self.indexfile, flags >> 16))
elif fmt > REVLOGNG:
More information about the Mercurial-devel
mailing list