Patchwork D5566: revlog: rename revlog I/O classes to reflect version (API)

login
register
mail settings
Submitter phabricator
Date Jan. 11, 2019, 12:34 a.m.
Message ID <differential-rev-PHID-DREV-eujlpwpeghuwsffv6ifj-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/37650/
State New
Headers show

Comments

phabricator - Jan. 11, 2019, 12:34 a.m.
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  I never liked these names. They imply the existence of exactly
  2 revlog versions. We're hacking on version 2. So let's
  introduce better names.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D5566

AFFECTED FILES
  contrib/perf.py
  mercurial/revlog.py

CHANGE DETAILS




To: indygreg, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -240,7 +240,7 @@ 
             return (0, 0, 0, -1, -1, -1, -1, nullid)
         return list.__getitem__(self, i)
 
-class revlogoldio(object):
+class revlogv0io(object):
     def __init__(self):
         self.size = indexformatv0.size
 
@@ -291,7 +291,7 @@ 
 # signed integer)
 _maxentrysize = 0x7fffffff
 
-class revlogio(object):
+class revlogv1io(object):
     def __init__(self):
         self.size = indexformatng.size
 
@@ -505,9 +505,9 @@ 
 
         self._storedeltachains = True
 
-        self._io = revlogio()
+        self._io = revlogv1io()
         if self.version == REVLOGV0:
-            self._io = revlogoldio()
+            self._io = revlogv0io()
         try:
             d = self._io.parseindex(indexdata, self._inline)
         except (ValueError, IndexError):
diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -1576,7 +1576,11 @@ 
     header = struct.unpack(b'>I', data[0:4])[0]
     version = header & 0xFFFF
     if version == 1:
-        revlogio = revlog.revlogio()
+        # Renamed to revlogv1io in Mercurial 4.9.
+        try:
+            revlogio = revlog.revlogv1io()
+        except AttributeError:
+            revlogio = revlog.revlogio()
         inline = header & (1 << 16)
     else:
         raise error.Abort((b'unsupported revlog version: %d') % version)