Patchwork localrepo: reduce scope of 'removed' variable

login
register
mail settings
Submitter Martin von Zweigbergk
Date Oct. 14, 2014, 4:50 a.m.
Message ID <1922ad32849078f12326.1413262207@handduk2.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/6246/
State Accepted
Headers show

Comments

Martin von Zweigbergk - Oct. 14, 2014, 4:50 a.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@gmail.com>
# Date 1413243817 25200
#      Mon Oct 13 16:43:37 2014 -0700
# Node ID 1922ad32849078f123266c6a9bcf38074240eaf8
# Parent  e1d19753de23e299e80e78025aeca5bd3afb52e3
localrepo: reduce scope of 'removed' variable

The variable is closely related to 'added' and 'changed', so it makes
sense to have it declared next to them.
Matt Mackall - Oct. 14, 2014, 5:22 a.m.
On Mon, 2014-10-13 at 21:50 -0700, Martin von Zweigbergk wrote:
> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz@gmail.com>
> # Date 1413243817 25200
> #      Mon Oct 13 16:43:37 2014 -0700
> # Node ID 1922ad32849078f123266c6a9bcf38074240eaf8
> # Parent  e1d19753de23e299e80e78025aeca5bd3afb52e3
> localrepo: reduce scope of 'removed' variable

For future reference, the part before the ':' should be the most useful
keyword. Things like 'localrepo' or 'commands' are unhelpful as those
are huge files. I've changed it here to 'commit'.

Patch

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1378,7 +1378,6 @@ 
         """
 
         tr = None
-        removed = list(ctx.removed())
         p1, p2 = ctx.p1(), ctx.p2()
         user = ctx.user()
 
@@ -1395,6 +1394,7 @@ 
                 # check in files
                 added = []
                 changed = []
+                removed = list(ctx.removed())
                 linkrev = len(self)
                 for f in sorted(ctx.modified() + ctx.added()):
                     self.ui.note(f + "\n")