Patchwork [02,of,10] revlog: add totalfilesize method

login
register
mail settings
Submitter Gregory Szorc
Date Nov. 6, 2016, 4:40 a.m.
Message ID <ed3241d8b00e476818ff.1478407218@ubuntu-vm-main>
Download mbox | patch
Permalink /patch/17364/
State Changes Requested
Headers show

Comments

Gregory Szorc - Nov. 6, 2016, 4:40 a.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1478374370 25200
#      Sat Nov 05 12:32:50 2016 -0700
# Node ID ed3241d8b00e476818ff1aec3db0136bf960de35
# Parent  ebbd8d975e4bf59b2bdd44736fdf13222988d1a4
revlog: add totalfilesize method

This will also be used by the future repository/store upgrade
feature to report on file sizes.

Patch

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -1847,3 +1847,11 @@  class revlog(object):
 
             if addrevisioncb:
                 addrevisioncb(self, rev, node)
+
+    def totalfilesize(self):
+        """Obtain the total size of files used by this revlog."""
+        size = self.opener.stat(self.indexfile).st_size
+        if not self._inline:
+            size += self.opener.stat(self.datafile).st_size
+
+        return size