Patchwork [4,of,5,v3] revlog: REVIDX_ISLARGEFILE flag

login
register
mail settings
Submitter Remi Chaintron
Date Nov. 23, 2016, 4:19 p.m.
Message ID <1d0b60b267fabedc683b.1479917956@iphonesleepsort.dhcp.thefacebook.com>
Download mbox | patch
Permalink /patch/17721/
State Superseded
Headers show

Comments

Remi Chaintron - Nov. 23, 2016, 4:19 p.m.
# HG changeset patch
# User Remi Chaintron <remi@fb.com>
# Date 1479917845 0
#      Wed Nov 23 16:17:25 2016 +0000
# Branch stable
# Node ID 1d0b60b267fabedc683bd53a880abc0b8e75badb
# Parent  2b21a1071ab3003f9ce145620e0e888d41742b80
revlog: REVIDX_ISLARGEFILE flag

Add the REVIDX_ISLARGEFILE flag for the `lfs` extension to interact with
revisions by registering transforms in the flagprocessor.

Patch

diff --git a/mercurial/help/internals/revlogs.txt b/mercurial/help/internals/revlogs.txt
--- a/mercurial/help/internals/revlogs.txt
+++ b/mercurial/help/internals/revlogs.txt
@@ -91,6 +91,8 @@ 
    Bit flags impacting revision behavior. The following bit offsets define:
    0
       'censor' extension flag.
+   1
+      'lfs' extension flag.
 8-11 (4 bytes)
    Compressed length of revision data / chunk as stored in revlog.
 12-15 (4 bytes)
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -54,11 +54,13 @@ 
 
 # revlog index flags
 REVIDX_ISCENSORED = (1 << 15) # revision has censor metadata, must be verified
+REVIDX_ISLARGEFILE = (1 << 14)
 REVIDX_DEFAULT_FLAGS = 0
-REVIDX_KNOWN_FLAGS = REVIDX_ISCENSORED
+REVIDX_KNOWN_FLAGS = REVIDX_ISCENSORED | REVIDX_ISLARGEFILE
 # stable order in which flags need to be processed by the flagprocessor
 REVIDX_FLAGS_PROCESSING_ORDER = [
     REVIDX_ISCENSORED,
+    REVIDX_ISLARGEFILE,
 ]
 
 # max size of revlog with inline data
@@ -1773,6 +1775,10 @@ 
         """Check if a file revision is censored."""
         return False
 
+    def islargefile(self, rev):
+        """Check if a file revision is flagged as large."""
+        return self.flags(rev) & REVIDX_ISLARGEFILE
+
     def _peek_iscensored(self, baserev, delta, flush):
         """Quickly check if a delta produces a censored revision."""
         return False