revlog: add shallow header flag
authorVishakh H <vsh426@gmail.com>
Tue, 03 Aug 2010 19:38:19 +0530
changeset 11746 46ac30b17978
parent 11745 138c055ec57d
child 11747 40d5633889bb
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.
mercurial/revlog.py
--- a/mercurial/revlog.py	Tue Aug 03 19:38:19 2010 +0530
+++ b/mercurial/revlog.py	Tue Aug 03 19:38:19 2010 +0530
@@ -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: