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

login
register
mail settings
Submitter adgar@google.com
Date Jan. 12, 2015, 9:08 p.m.
Message ID <e00466845102181cc018.1421096898@adgar.nyc.corp.google.com>
Download mbox | patch
Permalink /patch/7443/
State Accepted
Commit 062c3ad866511c40af7c95890138d0b01636e8ea
Headers show

Comments

adgar@google.com - Jan. 12, 2015, 9:08 p.m.
# HG changeset patch
# User Mike Edgar <adgar@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.

Patch

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