Patchwork [03,of,10,V4] context: reverse conditional branch order in introrev

login
register
mail settings
Submitter Boris Feld
Date Oct. 4, 2018, 2:44 p.m.
Message ID <0b56b3fd5e9fa1125d1d.1538664277@localhost.localdomain>
Download mbox | patch
Permalink /patch/35450/
State Accepted
Headers show

Comments

Boris Feld - Oct. 4, 2018, 2:44 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1538608945 -7200
#      Thu Oct 04 01:22:25 2018 +0200
# Node ID 0b56b3fd5e9fa1125d1d279b668a873b90bed7c9
# Parent  afeaa54d6b18c6582e461a65000f506bc1d7b9d8
# EXP-Topic copy-perf
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 0b56b3fd5e9f
context: reverse conditional branch order in introrev

Positive logic will be simpler to follow. It will help to clarify coming
refactoring.
via Mercurial-devel - Oct. 4, 2018, 5:26 p.m.
On Thu, Oct 4, 2018 at 7:44 AM Boris Feld <boris.feld@octobus.net> wrote:

> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1538608945 -7200
> #      Thu Oct 04 01:22:25 2018 +0200
> # Node ID 0b56b3fd5e9fa1125d1d279b668a873b90bed7c9
> # Parent  afeaa54d6b18c6582e461a65000f506bc1d7b9d8
> # EXP-Topic copy-perf
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r
> 0b56b3fd5e9f
> context: reverse conditional branch order in introrev
>

I've queued up to here because they seem good regardless of the rest of the
series. Thanks.

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -778,10 +778,11 @@  class basefilectx(object):
         """
         lkr = self.linkrev()
         attrs = vars(self)
-        noctx = not (r'_changeid' in attrs or r'_changectx' in attrs)
-        if noctx:
+        hastoprev = (r'_changeid' in attrs or r'_changectx' in attrs)
+        if hastoprev:
+            return self._adjustlinkrev(self.rev(), inclusive=True)
+        else:
             return self.linkrev()
-        return self._adjustlinkrev(self.rev(), inclusive=True)
 
     def introfilectx(self):
         """Return filectx having identical contents, but pointing to the