Patchwork [1,of,3] files: give local variables more descriptive names

login
register
mail settings
Submitter Matt Harbison
Date March 10, 2015, 2:34 a.m.
Message ID <9ed5cdcf1f95c0ff2c52.1425954854@Envy>
Download mbox | patch
Permalink /patch/7957/
State Accepted
Delegated to: Pierre-Yves David
Headers show

Comments

Matt Harbison - March 10, 2015, 2:34 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1425847346 14400
#      Sun Mar 08 16:42:26 2015 -0400
# Node ID 9ed5cdcf1f95c0ff2c52a27ebee2903fad969e00
# Parent  73191a7fdebbf8aa518eef5a65abb25678c5781f
files: give local variables more descriptive names

These will become parameters to a cmdutil method when the reusable code is
factored out, so it seems useful to clarify what they are.
Matt Mackall - March 10, 2015, 7:45 p.m.
On Mon, 2015-03-09 at 22:34 -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1425847346 14400
> #      Sun Mar 08 16:42:26 2015 -0400
> # Node ID 9ed5cdcf1f95c0ff2c52a27ebee2903fad969e00
> # Parent  73191a7fdebbf8aa518eef5a65abb25678c5781f
> files: give local variables more descriptive names
> 
> These will become parameters to a cmdutil method when the reusable code is
> factored out, so it seems useful to clarify what they are.

I'm dropping this set.

We use m = match(..) _everywhere_. Every single user of the formatter
calls it fm. And there is significant value in keeping these names short
(and consistent) precisely because of how often they're used.

(And because the changes that follow are tied to this one, the whole set
is sunk.)

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -3264,23 +3264,23 @@ 
     end = '\n'
     if opts.get('print0'):
         end = '\0'
-    fm = ui.formatter('files', opts)
+    formatter = ui.formatter('files', opts)
     fmt = '%s' + end
 
-    m = scmutil.match(ctx, pats, opts)
+    matcher = scmutil.match(ctx, pats, opts)
     ds = repo.dirstate
-    for f in ctx.matches(m):
+    for f in ctx.matches(matcher):
         if rev is None and ds[f] == 'r':
             continue
-        fm.startitem()
+        formatter.startitem()
         if ui.verbose:
             fc = ctx[f]
-            fm.write('size flags', '% 10d % 1s ', fc.size(), fc.flags())
-        fm.data(abspath=f)
-        fm.write('path', fmt, m.rel(f))
+            formatter.write('size flags', '% 10d % 1s ', fc.size(), fc.flags())
+        formatter.data(abspath=f)
+        formatter.write('path', fmt, matcher.rel(f))
         ret = 0
 
-    fm.end()
+    formatter.end()
 
     return ret