changeset 39875:d909c44d29e1

filelog: stop proxying rawsize() (API) This method is no longer used by external consumers. The API is quite low-level and is effectively len(revision(raw=True)). I don't see a compelling reason to keep it around. Let's drop the API and make the file storage interface simpler. Differential Revision: https://phab.mercurial-scm.org/D4750
author Gregory Szorc <gregory.szorc@gmail.com>
date Mon, 24 Sep 2018 12:49:17 -0700
parents 9596cf2a550d
children a269fa55467e
files mercurial/filelog.py mercurial/repository.py mercurial/testing/storage.py tests/simplestorerepo.py tests/test-lfs.t
diffstat 5 files changed, 2 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/filelog.py	Mon Sep 24 12:42:03 2018 -0700
+++ b/mercurial/filelog.py	Mon Sep 24 12:49:17 2018 -0700
@@ -73,10 +73,6 @@
     def iscensored(self, rev):
         return self._revlog.iscensored(rev)
 
-    # Unused.
-    def rawsize(self, rev):
-        return self._revlog.rawsize(rev)
-
     # Might be unused.
     def checkhash(self, text, node, p1=None, p2=None, rev=None):
         return self._revlog.checkhash(text, node, p1=p1, p2=p2, rev=rev)
--- a/mercurial/repository.py	Mon Sep 24 12:42:03 2018 -0700
+++ b/mercurial/repository.py	Mon Sep 24 12:49:17 2018 -0700
@@ -542,14 +542,10 @@
     This complements ``ifileindex`` and provides an interface for accessing
     data for a tracked file.
     """
-    def rawsize(rev):
-        """The size of the fulltext data for a revision as stored."""
-
     def size(rev):
         """Obtain the fulltext size of file data.
 
-        Any metadata is excluded from size measurements. Use ``rawsize()`` if
-        metadata size is important.
+        Any metadata is excluded from size measurements.
         """
 
     def checkhash(fulltext, node, p1=None, p2=None, rev=None):
--- a/mercurial/testing/storage.py	Mon Sep 24 12:42:03 2018 -0700
+++ b/mercurial/testing/storage.py	Mon Sep 24 12:49:17 2018 -0700
@@ -371,15 +371,6 @@
         self.assertEqual(f.storageinfo(revisionscount=True, trackedsize=True),
                          {'revisionscount': 0, 'trackedsize': 0})
 
-        self.assertEqual(f.rawsize(nullrev), 0)
-
-        for i in range(-5, 5):
-            if i == nullrev:
-                continue
-
-            with self.assertRaises(IndexError):
-                f.rawsize(i)
-
         self.assertEqual(f.size(nullrev), 0)
 
         for i in range(-5, 5):
@@ -453,11 +444,6 @@
         self.assertEqual(f.storageinfo(revisionscount=True, trackedsize=True),
                          {'revisionscount': 1, 'trackedsize': len(fulltext)})
 
-        self.assertEqual(f.rawsize(0), len(fulltext))
-
-        with self.assertRaises(IndexError):
-            f.rawsize(1)
-
         self.assertEqual(f.size(0), len(fulltext))
 
         with self.assertRaises(IndexError):
@@ -548,13 +534,6 @@
                 'trackedsize': len(fulltext0) + len(fulltext1) + len(fulltext2),
             })
 
-        self.assertEqual(f.rawsize(0), len(fulltext0))
-        self.assertEqual(f.rawsize(1), len(fulltext1))
-        self.assertEqual(f.rawsize(2), len(fulltext2))
-
-        with self.assertRaises(IndexError):
-            f.rawsize(3)
-
         self.assertEqual(f.size(0), len(fulltext0))
         self.assertEqual(f.size(1), len(fulltext1))
         self.assertEqual(f.size(2), len(fulltext2))
@@ -853,9 +832,6 @@
             node1 = f.add(fulltext1, meta1, tr, 1, node0, nullid)
             node2 = f.add(fulltext2, meta2, tr, 2, nullid, nullid)
 
-        self.assertEqual(f.rawsize(1), len(stored1))
-        self.assertEqual(f.rawsize(2), len(stored2))
-
         # Metadata header isn't recognized when parent isn't nullid.
         self.assertEqual(f.size(1), len(stored1))
         self.assertEqual(f.size(2), len(fulltext2))
@@ -898,9 +874,6 @@
             node0 = f.add(fulltext0, {}, tr, 0, nullid, nullid)
             node1 = f.add(fulltext1, meta1, tr, 1, nullid, nullid)
 
-        self.assertEqual(f.rawsize(0), len(stored0))
-        self.assertEqual(f.rawsize(1), len(stored1))
-
         # TODO this is buggy.
         self.assertEqual(f.size(0), len(fulltext0) + 4)
 
--- a/tests/simplestorerepo.py	Mon Sep 24 12:42:03 2018 -0700
+++ b/tests/simplestorerepo.py	Mon Sep 24 12:49:17 2018 -0700
@@ -249,11 +249,6 @@
 
         return True
 
-    def rawsize(self, rev):
-        validaterev(rev)
-        node = self.node(rev)
-        return len(self.revision(node, raw=True))
-
     def _processflags(self, text, flags, operation, raw=False):
         if flags == 0:
             return text, True
--- a/tests/test-lfs.t	Mon Sep 24 12:42:03 2018 -0700
+++ b/tests/test-lfs.t	Mon Sep 24 12:49:17 2018 -0700
@@ -690,7 +690,7 @@
   >         fl = repo.file(name)
   >         if len(fl) == 0:
   >             continue
-  >         sizes = [fl.rawsize(i) for i in fl]
+  >         sizes = [fl._revlog.rawsize(i) for i in fl]
   >         texts = [fl.revision(i, raw=True) for i in fl]
   >         flags = [int(fl._revlog.flags(i)) for i in fl]
   >         hashes = [hash(t) for t in texts]