Patchwork [3,of,3] revlog: rename _chunkraw to _getsegmentforrevs()

login
register
mail settings
Submitter Gregory Szorc
Date May 6, 2017, 7:19 p.m.
Message ID <13ac158a12d3b1256a69.1494098386@ubuntu-vm-main>
Download mbox | patch
Permalink /patch/20493/
State Accepted
Headers show

Comments

Gregory Szorc - May 6, 2017, 7:19 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1494097973 25200
#      Sat May 06 12:12:53 2017 -0700
# Node ID 13ac158a12d3b1256a6910affdf3aa63eb660ac1
# Parent  71ecddb2aa427e9d3c2372f5a616ff6cf99cb03f
revlog: rename _chunkraw to _getsegmentforrevs()

This completes our rename of internal revlog methods to
distinguish between low-level raw revlog data "segments" and
higher-level, per-revision "chunks."

perf.py has been updated to consult both names so it will work
against older Mercurial versions.
Augie Fackler - May 8, 2017, 7:28 p.m.
On Sat, May 06, 2017 at 12:19:46PM -0700, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc@gmail.com>
> # Date 1494097973 25200
> #      Sat May 06 12:12:53 2017 -0700
> # Node ID 13ac158a12d3b1256a6910affdf3aa63eb660ac1
> # Parent  71ecddb2aa427e9d3c2372f5a616ff6cf99cb03f
> revlog: rename _chunkraw to _getsegmentforrevs()

queued, thanks

I particularly like how some of the *chunk* methods already had
"segment" in their docstring.

Patch

diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -888,7 +888,12 @@  def perfrevlogchunks(ui, repo, file_=Non
     see ``perfrevlog`` and ``perfrevlogrevision``.
     """
     rl = cmdutil.openrevlog(repo, 'perfrevlogchunks', file_, opts)
-    segmentforrevs = rl._chunkraw
+
+    # _chunkraw was renamed to _getsegmentforrevs.
+    try:
+        segmentforrevs = rl._getsegmentforrevs
+    except AttributeError:
+        segmentforrevs = rl._chunkraw
 
     # Verify engines argument.
     if engines:
@@ -1004,7 +1009,13 @@  def perfrevlogrevision(ui, repo, file_, 
         raise error.CommandError('perfrevlogrevision', 'invalid arguments')
 
     r = cmdutil.openrevlog(repo, 'perfrevlogrevision', file_, opts)
-    segmentforrevs = r._chunkraw
+
+    # _chunkraw was renamed to _getsegmentforrevs.
+    try:
+        segmentforrevs = r._getsegmentforrevs
+    except AttributeError:
+        segmentforrevs = r._chunkraw
+
     node = r.lookup(rev)
     rev = r.rev(node)
 
diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -1706,9 +1706,9 @@  def debugrevlog(ui, repo, file_=None, **
                 numother += 1
 
         # Obtain data on the raw chunks in the revlog.
-        chunk = r._chunkraw(rev, rev)[1]
-        if chunk:
-            chunktype = chunk[0]
+        segment = r._getsegmentforrevs(rev, rev)[1]
+        if segment:
+            chunktype = segment[0]
         else:
             chunktype = 'empty'
 
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -1147,7 +1147,7 @@  class revlog(object):
 
         return self._readsegment(offset, length, df=df)
 
-    def _chunkraw(self, startrev, endrev, df=None):
+    def _getsegmentforrevs(self, startrev, endrev, df=None):
         """Obtain a segment of raw data corresponding to a range of revisions.
 
         Accepts the start and end revisions and an optional already-open
@@ -1190,7 +1190,7 @@  class revlog(object):
 
         Returns a str holding uncompressed data for the requested revision.
         """
-        return self.decompress(self._chunkraw(rev, rev, df=df)[1])
+        return self.decompress(self._getsegmentforrevs(rev, rev, df=df)[1])
 
     def _chunks(self, revs, df=None):
         """Obtain decompressed chunks for the specified revisions.
@@ -1217,7 +1217,7 @@  class revlog(object):
         ladd = l.append
 
         try:
-            offset, data = self._chunkraw(revs[0], revs[-1], df=df)
+            offset, data = self._getsegmentforrevs(revs[0], revs[-1], df=df)
         except OverflowError:
             # issue4215 - we can't cache a run of chunks greater than
             # 2G on Windows
@@ -1443,7 +1443,7 @@  class revlog(object):
         df = self.opener(self.datafile, 'w')
         try:
             for r in self:
-                df.write(self._chunkraw(r, r)[1])
+                df.write(self._getsegmentforrevs(r, r)[1])
         finally:
             df.close()