Patchwork [2,of,7] revlog: assign rawtext earlier in `_revisiondata`

login
register
mail settings
Submitter Pierre-Yves David
Date Aug. 20, 2019, 4:37 p.m.
Message ID <598ab124d9b67810662d.1566319047@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/41368/
State Accepted
Headers show

Comments

Pierre-Yves David - Aug. 20, 2019, 4:37 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1565214374 -7200
#      Wed Aug 07 23:46:14 2019 +0200
# Node ID 598ab124d9b67810662db9a5d770e90cf913b9a4
# Parent  5a46fc205da7509e937c826720e0211bd80f2c52
# EXP-Topic revisiondata
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 598ab124d9b6
revlog: assign rawtext earlier in `_revisiondata`

Assigning the revision earlier make the code easier to read.

Patch

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -1626,8 +1626,10 @@  class revlog(object):
         if self._revisioncache:
             if self._revisioncache[0] == node:
                 # _cache only stores rawtext
+                # rawtext is reusable. but we might need to run flag processors
+                rawtext = self._revisioncache[2]
                 if raw:
-                    return self._revisioncache[2]
+                    return rawtext
                 # duplicated, but good for perf
                 if rev is None:
                     rev = self.rev(node)
@@ -1635,9 +1637,7 @@  class revlog(object):
                     flags = self.flags(rev)
                 # no extra flags set, no flag processor runs, text = rawtext
                 if flags == REVIDX_DEFAULT_FLAGS:
-                    return self._revisioncache[2]
-                # rawtext is reusable. need to run flag processor
-                rawtext = self._revisioncache[2]
+                    return rawtext
 
             cachedrev = self._revisioncache[1]