From patchwork Tue Nov 6 10:03:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [V2] obsutil: clarify the access to "repo" From: Boris Feld X-Patchwork-Id: 36410 Message-Id: <44b4391b6b68291e408f.1541498603@Laptop-Boris.lan> To: mercurial-devel@mercurial-scm.org Date: Tue, 06 Nov 2018 11:03:23 +0100 # HG changeset patch # User Boris Feld # 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. 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)