[PATCH 2 of 4 censor RFC] revlog: add flags argument to _addrevision, update callers use default flags

Mike Edgar adgar at google.com
Mon Jan 12 15:08:18 CST 2015


# HG changeset patch
# User Mike Edgar <adgar at google.com>
# Date 1421091024 18000
#      Mon Jan 12 14:30:24 2015 -0500
# Node ID e00466845102181cc01816b2b06df8fe12cc5493
# Parent  22f0383cb0d3429e36faa852b314c4fc1dfbecfb
revlog: add flags argument to _addrevision, update callers use default flags

For revlog index flags to be useful to other parts of Mercurial, they need to
be settable when writing revisions. The current use case for revlog index
flags is the censorship feature: http://mercurial.selenic.com/wiki/CensorPlan

While the censor flag could be inferred in _addrevision by interrogating the
text/delta being added, that would bury the censorship logic and
inappropriately couple it to all revision creation.

diff -r 22f0383cb0d3 -r e00466845102 mercurial/revlog.py
--- a/mercurial/revlog.py	Mon Jan 12 14:01:52 2015 -0500
+++ b/mercurial/revlog.py	Mon Jan 12 14:30:24 2015 -0500
@@ -1179,7 +1179,7 @@
         ifh = self.opener(self.indexfile, "a+")
         try:
             return self._addrevision(node, text, transaction, link, p1, p2,
-                                     cachedelta, ifh, dfh)
+                                     REVIDX_DEFAULT_FLAGS, cachedelta, ifh, dfh)
         finally:
             if dfh:
                 dfh.close()
@@ -1214,7 +1214,7 @@
             return ('u', text)
         return ("", bin)
 
-    def _addrevision(self, node, text, transaction, link, p1, p2,
+    def _addrevision(self, node, text, transaction, link, p1, p2, flags,
                      cachedelta, ifh, dfh):
         """internal function to add revisions to the log
 
@@ -1268,7 +1268,6 @@
         base = chainbase = curr
         chainlen = None
         offset = self.end(prev)
-        flags = 0
         d = None
         if self._basecache is None:
             self._basecache = (prev, self.chainbase(prev))
@@ -1399,7 +1398,8 @@
 
                 baserev = self.rev(deltabase)
                 chain = self._addrevision(node, None, transaction, link,
-                                          p1, p2, (baserev, delta), ifh, dfh)
+                                          p1, p2, REVIDX_DEFAULT_FLAGS,
+                                          (baserev, delta), ifh, dfh)
                 if not dfh and not self._inline:
                     # addrevision switched from inline to conventional
                     # reopen the index


More information about the Mercurial-devel mailing list