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

login
register
mail settings
Submitter phabricator
Date Jan. 11, 2019, 12:34 a.m.
Message ID <differential-rev-PHID-DREV-pgih2wugnos6fa5zjo5m-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/37649/
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
  A single version lookup is desirable.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  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
@@ -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):