D5567: revlog: assign revlog._io in version lookup conditional

indygreg (Gregory Szorc) phabricator at mercurial-scm.org
Fri Jan 11 00:34:01 UTC 2019


indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  A single version lookup is desirable.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/revlog.py

CHANGE DETAILS

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -472,6 +472,8 @@
             self._sparserevlog = False
             self._withsparseread = False
 
+            self._io = revlogv0io()
+
         elif fmt == REVLOGV1:
             if flags & ~REVLOGV1_FLAGS:
                 raise error.RevlogError(_('unknown flags (%#04x) in version %d '
@@ -486,6 +488,8 @@
             # sparse-revlog forces sparse-read
             self._withsparseread = self._sparserevlog or withsparseread
 
+            self._io = revlogv1io()
+
         elif fmt == REVLOGV2:
             if flags & ~REVLOGV2_FLAGS:
                 raise error.RevlogError(_('unknown flags (%#04x) in version %d '
@@ -499,15 +503,14 @@
             self._sparserevlog = versionflags & FLAG_SPARSE_DELTA_CHAINS
             self._withsparseread = versionflags & FLAG_SPARSE_DELTA_CHAINS
 
+            self._io = revlogv1io()
+
         else:
             raise error.RevlogError(_('unknown version (%d) in revlog %s') %
                                     (fmt, self.indexfile))
 
         self._storedeltachains = True
 
-        self._io = revlogv1io()
-        if self.version == REVLOGV0:
-            self._io = revlogv0io()
         try:
             d = self._io.parseindex(indexdata, self._inline)
         except (ValueError, IndexError):



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


More information about the Mercurial-devel mailing list