[PATCH] cmdutil: avoid calling a matcher 'patch'

Pierre-Yves David pierre-yves.david at ens-lyon.org
Tue Sep 2 14:12:18 CDT 2014



On 09/01/2014 12:13 PM, Martin von Zweigbergk wrote:
> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz at gmail.com>
> # Date 1409496350 25200
> #      Sun Aug 31 07:45:50 2014 -0700
> # Node ID 80685f1cfc6afa805c0b1930a8731c2df84425ec
> # Parent  188b8aa2120b03eead618ba150319074f4e3b42b
> cmdutil: avoid calling a matcher 'patch'

Can you elaborate about why this patches is necessary and that it does 
actually achieves?

>
> 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)

buffered should be aligned with the opening parenthesis:

   function(arg1, arg2,…
            arg42)

-- 
Pierre-Yves David


More information about the Mercurial-devel mailing list