Patchwork [v2] cmdutil: avoid the confusing name 'patch' for a matcher

login
register
mail settings
Submitter Martin von Zweigbergk
Date Sept. 2, 2014, 8:21 p.m.
Message ID <1dc96008dc01aeb59065.1409689264@handduk2.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/5682/
State Accepted
Headers show

Comments

Martin von Zweigbergk - Sept. 2, 2014, 8:21 p.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@gmail.com>
# Date 1409496350 25200
#      Sun Aug 31 07:45:50 2014 -0700
# Node ID 1dc96008dc01aeb590657f7c316a7891fb420a13
# Parent  188b8aa2120b03eead618ba150319074f4e3b42b
cmdutil: avoid the confusing name 'patch' for a matcher
Pierre-Yves David - Sept. 3, 2014, 8:09 a.m.
On 09/02/2014 10:21 PM, Martin von Zweigbergk wrote:
> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz@gmail.com>
> # Date 1409496350 25200
> #      Sun Aug 31 07:45:50 2014 -0700
> # Node ID 1dc96008dc01aeb590657f7c316a7891fb420a13
> # Parent  188b8aa2120b03eead618ba150319074f4e3b42b
> cmdutil: avoid the confusing name 'patch' for a matcher

sounds obviously right, pushed to the clowncopter.

>
> diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
> --- a/mercurial/cmdutil.py
> +++ b/mercurial/cmdutil.py
> @@ -837,11 +837,11 @@
>   class changeset_printer(object):
>       '''show changeset information when templating not requested.'''
>
> -    def __init__(self, ui, repo, patch, diffopts, buffered):
> +    def __init__(self, ui, repo, matchfn, diffopts, buffered):
>           self.ui = ui
>           self.repo = repo
>           self.buffered = buffered
> -        self.patch = patch
> +        self.matchfn = matchfn
>           self.diffopts = diffopts
>           self.header = {}
>           self.hunk = {}
> @@ -980,7 +980,7 @@
>
>       def showpatch(self, node, matchfn):
>           if not matchfn:
> -            matchfn = self.patch
> +            matchfn = self.matchfn
>           if matchfn:
>               stat = self.diffopts.get('stat')
>               diff = self.diffopts.get('patch')
> @@ -1015,8 +1015,8 @@
>   class changeset_templater(changeset_printer):
>       '''format changeset information.'''
>
> -    def __init__(self, ui, repo, patch, diffopts, tmpl, mapfile, buffered):
> -        changeset_printer.__init__(self, ui, repo, patch, diffopts, buffered)
> +    def __init__(self, ui, repo, matchfn, diffopts, tmpl, mapfile, buffered):
> +        changeset_printer.__init__(self, ui, repo, matchfn, diffopts, buffered)
>           formatnode = ui.debugflag and (lambda x: x) or (lambda x: x[:12])
>           defaulttempl = {
>               'parent': '{rev}:{node|formatnode} ',
> @@ -1189,17 +1189,18 @@
>       regular display via changeset_printer() is done.
>       """
>       # options
> -    patch = None
> +    matchfn = None
>       if opts.get('patch') or opts.get('stat'):
> -        patch = scmutil.matchall(repo)
> +        matchfn = scmutil.matchall(repo)
>
>       tmpl, mapfile = gettemplate(ui, opts.get('template'), opts.get('style'))
>
>       if not tmpl and not mapfile:
> -        return changeset_printer(ui, repo, patch, opts, buffered)
> +        return changeset_printer(ui, repo, matchfn, opts, buffered)
>
>       try:
> -        t = changeset_templater(ui, repo, patch, opts, tmpl, mapfile, buffered)
> +        t = changeset_templater(ui, repo, matchfn, opts, tmpl, mapfile,
> +                                buffered)
>       except SyntaxError, inst:
>           raise util.Abort(inst.args[0])
>       return t
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -837,11 +837,11 @@ 
 class changeset_printer(object):
     '''show changeset information when templating not requested.'''
 
-    def __init__(self, ui, repo, patch, diffopts, buffered):
+    def __init__(self, ui, repo, matchfn, diffopts, buffered):
         self.ui = ui
         self.repo = repo
         self.buffered = buffered
-        self.patch = patch
+        self.matchfn = matchfn
         self.diffopts = diffopts
         self.header = {}
         self.hunk = {}
@@ -980,7 +980,7 @@ 
 
     def showpatch(self, node, matchfn):
         if not matchfn:
-            matchfn = self.patch
+            matchfn = self.matchfn
         if matchfn:
             stat = self.diffopts.get('stat')
             diff = self.diffopts.get('patch')
@@ -1015,8 +1015,8 @@ 
 class changeset_templater(changeset_printer):
     '''format changeset information.'''
 
-    def __init__(self, ui, repo, patch, diffopts, tmpl, mapfile, buffered):
-        changeset_printer.__init__(self, ui, repo, patch, diffopts, buffered)
+    def __init__(self, ui, repo, matchfn, diffopts, tmpl, mapfile, buffered):
+        changeset_printer.__init__(self, ui, repo, matchfn, diffopts, buffered)
         formatnode = ui.debugflag and (lambda x: x) or (lambda x: x[:12])
         defaulttempl = {
             'parent': '{rev}:{node|formatnode} ',
@@ -1189,17 +1189,18 @@ 
     regular display via changeset_printer() is done.
     """
     # options
-    patch = None
+    matchfn = None
     if opts.get('patch') or opts.get('stat'):
-        patch = scmutil.matchall(repo)
+        matchfn = scmutil.matchall(repo)
 
     tmpl, mapfile = gettemplate(ui, opts.get('template'), opts.get('style'))
 
     if not tmpl and not mapfile:
-        return changeset_printer(ui, repo, patch, opts, buffered)
+        return changeset_printer(ui, repo, matchfn, opts, buffered)
 
     try:
-        t = changeset_templater(ui, repo, patch, opts, tmpl, mapfile, buffered)
+        t = changeset_templater(ui, repo, matchfn, opts, tmpl, mapfile,
+                                buffered)
     except SyntaxError, inst:
         raise util.Abort(inst.args[0])
     return t