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

Pierre-Yves David pierre-yves.david at ens-lyon.org
Tue Aug 20 12:37:27 EDT 2019


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at 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.

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]
 


More information about the Mercurial-devel mailing list