Patchwork D10599: revlog: directly use self._format_version when loading index

login
register
mail settings
Submitter phabricator
Date May 3, 2021, 12:07 p.m.
Message ID <differential-rev-PHID-DREV-iglysuk4g7wzxc5utgt4-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48918/
State Superseded
Headers show

Comments

phabricator - May 3, 2021, 12:07 p.m.
marmoute created this revision.
Herald added a reviewer: indygreg.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The shorthand variable does not bring much, so we drop it to simplify the code.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/revlog.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -491,34 +491,31 @@ 
             header = new_header
 
         flags = self._format_flags = header & ~0xFFFF
-        fmt = self._format_version = header & 0xFFFF
-
-        if fmt == REVLOGV0:
+        self._format_version = header & 0xFFFF
+
+        if self._format_version == REVLOGV0:
             if flags:
-                raise error.RevlogError(
-                    _(b'unknown flags (%#04x) in version %d revlog %s')
-                    % (flags >> 16, fmt, self.display_id)
-                )
+                msg = _(b'unknown flags (%#04x) in version %d revlog %s')
+                msg %= (flags >> 16, self._format_version, self.display_id)
+                raise error.RevlogError(msg)
 
             self._inline = False
             self._generaldelta = False
 
-        elif fmt == REVLOGV1:
+        elif self._format_version == REVLOGV1:
             if flags & ~REVLOGV1_FLAGS:
-                raise error.RevlogError(
-                    _(b'unknown flags (%#04x) in version %d revlog %s')
-                    % (flags >> 16, fmt, self.display_id)
-                )
+                msg = _(b'unknown flags (%#04x) in version %d revlog %s')
+                msg %= (flags >> 16, self._format_version, self.display_id)
+                raise error.RevlogError(msg)
 
             self._inline = self._format_flags & FLAG_INLINE_DATA
             self._generaldelta = self._format_flags & FLAG_GENERALDELTA
 
-        elif fmt == REVLOGV2:
+        elif self._format_version == REVLOGV2:
             if flags & ~REVLOGV2_FLAGS:
-                raise error.RevlogError(
-                    _(b'unknown flags (%#04x) in version %d revlog %s')
-                    % (flags >> 16, fmt, self.display_id)
-                )
+                msg = _(b'unknown flags (%#04x) in version %d revlog %s')
+                msg %= (flags >> 16, self._format_version, self.display_id)
+                raise error.RevlogError(msg)
 
             # There is a bug in the transaction handling when going from an
             # inline revlog to a separate index and data file. Turn it off until
@@ -529,9 +526,9 @@ 
             self._generaldelta = True
 
         else:
-            raise error.RevlogError(
-                _(b'unknown version (%d) in revlog %s') % (fmt, self.display_id)
-            )
+            msg = _(b'unknown version (%d) in revlog %s')
+            msg %= (self._format_version, self.display_id)
+            raise error.RevlogError(msg)
 
         self.nodeconstants = sha1nodeconstants
         self.nullid = self.nodeconstants.nullid
@@ -558,7 +555,7 @@ 
         self._parse_index = parse_index_v1
         if self._format_version == REVLOGV0:
             self._parse_index = revlogv0.parse_index_v0
-        elif fmt == REVLOGV2:
+        elif self._format_version == REVLOGV2:
             self._parse_index = parse_index_v2
         elif devel_nodemap:
             self._parse_index = parse_index_v1_nodemap