filelog: stop proxying flags() (API)
authorGregory Szorc <gregory.szorc@gmail.com>
Mon, 24 Sep 2018 11:16:33 -0700
changeset 39878 2ac4f3e97813
parent 39877 733db72f0f54
child 39879 9596cf2a550d
filelog: stop proxying flags() (API) Per-revision storage flags are kinda a revlog-centric API. (Except for the fact that changegroup uses the same integer flags as revlog does and there's minimal verification that the server's flags map to the client's storage flags - but that's another problem.) The last user of flags() was in verify.py and that code was just moved into revlog.py and is accessed behind the verifyintegrity() file storage API. Since there are no more consumers, let's drop the proxy and remove the method from the file storage interface. This commit only drops the dedicated API for reading a single revision's storage flags: we still support reading and writing flags through the bulk data retrieval and add revision APIs. And since changegroups encode revlog integer flags over the wire, we'll always need to support flags at some level. The removal of individual storage flags may be too premature. But since flags() is now unused, I'd like to see how far we can get without that dedicated API - especially since it uses revision numbers instead of nodes. Differential Revision: https://phab.mercurial-scm.org/D4746
mercurial/filelog.py
mercurial/repository.py
mercurial/testing/storage.py
tests/simplestorerepo.py
--- a/mercurial/filelog.py	Mon Sep 24 11:27:47 2018 -0700
+++ b/mercurial/filelog.py	Mon Sep 24 11:16:33 2018 -0700
@@ -53,10 +53,6 @@
     def linkrev(self, rev):
         return self._revlog.linkrev(rev)
 
-    # Unused.
-    def flags(self, rev):
-        return self._revlog.flags(rev)
-
     def commonancestorsheads(self, node1, node2):
         return self._revlog.commonancestorsheads(node1, node2)
 
--- a/mercurial/repository.py	Mon Sep 24 11:27:47 2018 -0700
+++ b/mercurial/repository.py	Mon Sep 24 11:16:33 2018 -0700
@@ -502,9 +502,6 @@
     def linkrev(rev):
         """Obtain the changeset revision number a revision is linked to."""
 
-    def flags(rev):
-        """Obtain flags used to affect storage of a revision."""
-
     def iscensored(rev):
         """Return whether a revision's content has been censored."""
 
--- a/mercurial/testing/storage.py	Mon Sep 24 11:27:47 2018 -0700
+++ b/mercurial/testing/storage.py	Mon Sep 24 11:16:33 2018 -0700
@@ -96,15 +96,6 @@
             with self.assertRaises(IndexError):
                 f.linkrev(i)
 
-        self.assertEqual(f.flags(nullrev), 0)
-
-        for i in range(-5, 5):
-            if i == nullrev:
-                continue
-
-            with self.assertRaises(IndexError):
-                f.flags(i)
-
         self.assertFalse(f.iscensored(nullrev))
 
         for i in range(-5, 5):
@@ -193,11 +184,6 @@
         with self.assertRaises(IndexError):
             f.linkrev(1)
 
-        self.assertEqual(f.flags(0), 0)
-
-        with self.assertRaises(IndexError):
-            f.flags(1)
-
         self.assertFalse(f.iscensored(0))
 
         with self.assertRaises(IndexError):
@@ -290,13 +276,6 @@
         with self.assertRaises(IndexError):
             f.linkrev(3)
 
-        self.assertEqual(f.flags(0), 0)
-        self.assertEqual(f.flags(1), 0)
-        self.assertEqual(f.flags(2), 0)
-
-        with self.assertRaises(IndexError):
-            f.flags(3)
-
         self.assertFalse(f.iscensored(0))
         self.assertFalse(f.iscensored(1))
         self.assertFalse(f.iscensored(2))
@@ -957,7 +936,6 @@
             f.addrevision(stored1, tr, 1, node0, nullid,
                           flags=revlog.REVIDX_ISCENSORED)
 
-        self.assertEqual(f.flags(1), revlog.REVIDX_ISCENSORED)
         self.assertTrue(f.iscensored(1))
 
         self.assertEqual(f.revision(1), stored1)
--- a/tests/simplestorerepo.py	Mon Sep 24 11:27:47 2018 -0700
+++ b/tests/simplestorerepo.py	Mon Sep 24 11:16:33 2018 -0700
@@ -228,7 +228,7 @@
 
         return self._indexbyrev[rev][b'linkrev']
 
-    def flags(self, rev):
+    def _flags(self, rev):
         validaterev(rev)
 
         return self._indexbyrev[rev][b'flags']
@@ -243,8 +243,8 @@
         validaterev(baserev)
         validaterev(rev)
 
-        if ((self.flags(baserev) & revlog.REVIDX_RAWTEXT_CHANGING_FLAGS)
-            or (self.flags(rev) & revlog.REVIDX_RAWTEXT_CHANGING_FLAGS)):
+        if ((self._flags(baserev) & revlog.REVIDX_RAWTEXT_CHANGING_FLAGS)
+            or (self._flags(rev) & revlog.REVIDX_RAWTEXT_CHANGING_FLAGS)):
             return False
 
         return True
@@ -307,7 +307,7 @@
             return b''
 
         rev = self.rev(node)
-        flags = self.flags(rev)
+        flags = self._flags(rev)
 
         path = b'/'.join([self._storepath, hex(node)])
         rawtext = self._svfs.read(path)
@@ -381,7 +381,7 @@
     def iscensored(self, rev):
         validaterev(rev)
 
-        return self.flags(rev) & revlog.REVIDX_ISCENSORED
+        return self._flags(rev) & revlog.REVIDX_ISCENSORED
 
     def commonancestorsheads(self, a, b):
         validatenode(a)