Patchwork [3,of,7,flagprocessor,v7] revlog: pass revlog flags to addrevision

login
register
mail settings
Submitter Remi Chaintron
Date Jan. 2, 2017, 5:51 p.m.
Message ID <2212e5fd10eef8d74e4d.1483379473@remi-mbp2>
Download mbox | patch
Permalink /patch/18070/
State Superseded
Delegated to: Pierre-Yves David
Headers show

Comments

Remi Chaintron - Jan. 2, 2017, 5:51 p.m.
# HG changeset patch
# User Remi Chaintron <remi@fb.com>
# Date 1482451731 18000
#      Thu Dec 22 19:08:51 2016 -0500
# Node ID 2212e5fd10eef8d74e4debc1fd0603fed21e6e57
# Parent  e8f2c1de84a9215769e3da868d267c23d99f3938
revlog: pass revlog flags to addrevision

Adding the ability to passing flags to addrevision instead of simply passing
default flags to _addrevision will allow extensions relying on flag transforms
to wrap around addrevision() in order to update revlog flags.

The first use case of this patch will be the lfs extension marking nodes as
stored externally when the contents are larger than the defined threshold.

One of the reasons leading to setting flags in addrevision() wrappers in the
flag processor design is that it allows to detect files larger than the 2GB
limit before the check is performed, which allows lfs to transform the contents
into metadata.

Patch

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -1328,7 +1328,7 @@ 
         self._chunkclear()
 
     def addrevision(self, text, transaction, link, p1, p2, cachedelta=None,
-                    node=None):
+                    node=None, flags=REVIDX_DEFAULT_FLAGS):
         """add a revision to the log
 
         text - the revision data to add
@@ -1339,6 +1339,7 @@ 
         node - nodeid of revision; typically node is not specified, and it is
             computed by default as hash(text, p1, p2), however subclasses might
             use different hashing method (and override checkhash() in such case)
+        flags - the known flags to set on the revision
         """
         if link == nullrev:
             raise RevlogError(_("attempted to add linkrev -1 to %s")
@@ -1359,7 +1360,7 @@ 
         ifh = self.opener(self.indexfile, "a+", checkambig=self._checkambig)
         try:
             return self._addrevision(node, text, transaction, link, p1, p2,
-                                     REVIDX_DEFAULT_FLAGS, cachedelta, ifh, dfh)
+                                     flags, cachedelta, ifh, dfh)
         finally:
             if dfh:
                 dfh.close()