Patchwork [V2] obsutil: clarify the access to "repo"

login
register
mail settings
Submitter Boris Feld
Date Nov. 6, 2018, 10:03 a.m.
Message ID <44b4391b6b68291e408f.1541498603@Laptop-Boris.lan>
Download mbox | patch
Permalink /patch/36410/
State Accepted
Headers show

Comments

Boris Feld - Nov. 6, 2018, 10:03 a.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1526995577 -7200
#      Tue May 22 15:26:17 2018 +0200
# Node ID 44b4391b6b68291e408fc7c42a477f893244cdd8
# Parent  e0dea186ab6edfab124b1dfd84237a4b8142f13b
# EXP-Topic gratuitous-cleanup
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 44b4391b6b68
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.
Yuya Nishihara - Nov. 6, 2018, 11:14 a.m.
On Tue, 06 Nov 2018 11:03:23 +0100, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1526995577 -7200
> #      Tue May 22 15:26:17 2018 +0200
> # Node ID 44b4391b6b68291e408fc7c42a477f893244cdd8
> # Parent  e0dea186ab6edfab124b1dfd84237a4b8142f13b
> # EXP-Topic gratuitous-cleanup
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 44b4391b6b68
> obsutil: clarify the access to "repo"

Queued, thanks.

Patch

diff --git a/mercurial/obsutil.py b/mercurial/obsutil.py
--- a/mercurial/obsutil.py
+++ b/mercurial/obsutil.py
@@ -396,12 +396,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()
+    diffopts = diffutil.diffallopts(repo.ui, {'git': True})
     # 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)