[PATCH] obsutil: clarify the access to "repo"

Boris Feld boris.feld at octobus.net
Mon Nov 5 10:42:19 UTC 2018


# HG changeset patch
# User Boris Feld <boris.feld at octobus.net>
# Date 1526995577 -7200
#      Tue May 22 15:26:17 2018 +0200
# Node ID f4f31bac4057231d97000967cb731ac0da25f30b
# Parent  e0dea186ab6edfab124b1dfd84237a4b8142f13b
# EXP-Topic gratuitous-cleanup
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r f4f31bac4057
obsutil: clarify the access to "repo"

We use the variable multiple times and we might use it even more in the
future. We use a temporary variable instead.

diff --git a/mercurial/obsutil.py b/mercurial/obsutil.py
--- a/mercurial/obsutil.py
+++ b/mercurial/obsutil.py
@@ -397,11 +397,14 @@ def _cmpdiff(leftctx, rightctx):
     This is a first and basic implementation, with many shortcoming.
     """
     diffopts = diffutil.diffallopts(leftctx.repo().ui, {'git': True})
+
+    # lefctx._repo and right_ctx._repo are the same here
+    repo = leftctx._repo
     # Leftctx or right ctx might be filtered, so we need to use the contexts
     # with an unfiltered repository to safely compute the diff
-    leftunfi = leftctx._repo.unfiltered()[leftctx.rev()]
+    leftunfi = repo.unfiltered()[leftctx.rev()]
     leftdiff = leftunfi.diff(opts=diffopts)
-    rightunfi = rightctx._repo.unfiltered()[rightctx.rev()]
+    rightunfi = repo.unfiltered()[rightctx.rev()]
     rightdiff = rightunfi.diff(opts=diffopts)
 
     left, right = (0, 0)


More information about the Mercurial-devel mailing list