Patchwork [1,of,7] patch.diffopts: use a dict for initialization

login
register
mail settings
Submitter Siddharth Agarwal
Date Nov. 26, 2014, 3:53 a.m.
Message ID <491b6bf7bc858efe4f43.1416974036@devbig136.prn2.facebook.com>
Download mbox | patch
Permalink /patch/6858/
State Accepted
Commit f35526b999f4ac50c9dfbe34b8c734f1427ec75d
Headers show

Comments

Siddharth Agarwal - Nov. 26, 2014, 3:53 a.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1416355254 28800
#      Tue Nov 18 16:00:54 2014 -0800
# Node ID 491b6bf7bc858efe4f43c5d347f68f0624d846c1
# Parent  b5e2128ce9e6cc0b6a2b20cc2763f9e6c351625b
patch.diffopts: use a dict for initialization

In upcoming patches we'll conditionally add to and remove from the dict.
Siddharth Agarwal - Nov. 26, 2014, 3:55 a.m.
On 11/25/2014 07:53 PM, Siddharth Agarwal wrote:
> # HG changeset patch
> # User Siddharth Agarwal <sid0@fb.com>
> # Date 1416355254 28800
> #      Tue Nov 18 16:00:54 2014 -0800
> # Node ID 491b6bf7bc858efe4f43c5d347f68f0624d846c1
> # Parent  b5e2128ce9e6cc0b6a2b20cc2763f9e6c351625b
> patch.diffopts: use a dict for initialization

(forgot to flag this series V2)

>
> In upcoming patches we'll conditionally add to and remove from the dict.
>
> diff --git mercurial/patch.py mercurial/patch.py
> --- mercurial/patch.py
> +++ mercurial/patch.py
> @@ -1568,17 +1568,20 @@
>               return forceplain
>           return getter(section, name or key, None, untrusted=untrusted)
>   
> -    return mdiff.diffopts(
> -        text=opts and opts.get('text'),
> -        git=get('git'),
> -        nodates=get('nodates'),
> -        nobinary=get('nobinary'),
> -        noprefix=get('noprefix', forceplain=False),
> -        showfunc=get('show_function', 'showfunc'),
> -        ignorews=get('ignore_all_space', 'ignorews'),
> -        ignorewsamount=get('ignore_space_change', 'ignorewsamount'),
> -        ignoreblanklines=get('ignore_blank_lines', 'ignoreblanklines'),
> -        context=get('unified', getter=ui.config))
> +    buildopts = {
> +        'text': opts and opts.get('text'),
> +        'git': get('git'),
> +        'nodates': get('nodates'),
> +        'nobinary': get('nobinary'),
> +        'noprefix': get('noprefix', forceplain=False),
> +        'showfunc': get('show_function', 'showfunc'),
> +        'ignorews': get('ignore_all_space', 'ignorews'),
> +        'ignorewsamount': get('ignore_space_change', 'ignorewsamount'),
> +        'ignoreblanklines': get('ignore_blank_lines', 'ignoreblanklines'),
> +        'context': get('unified', getter=ui.config),
> +    }
> +
> +    return mdiff.diffopts(**buildopts)
>   
>   def diff(repo, node1=None, node2=None, match=None, changes=None, opts=None,
>            losedatafn=None, prefix=''):
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git mercurial/patch.py mercurial/patch.py
--- mercurial/patch.py
+++ mercurial/patch.py
@@ -1568,17 +1568,20 @@ 
             return forceplain
         return getter(section, name or key, None, untrusted=untrusted)
 
-    return mdiff.diffopts(
-        text=opts and opts.get('text'),
-        git=get('git'),
-        nodates=get('nodates'),
-        nobinary=get('nobinary'),
-        noprefix=get('noprefix', forceplain=False),
-        showfunc=get('show_function', 'showfunc'),
-        ignorews=get('ignore_all_space', 'ignorews'),
-        ignorewsamount=get('ignore_space_change', 'ignorewsamount'),
-        ignoreblanklines=get('ignore_blank_lines', 'ignoreblanklines'),
-        context=get('unified', getter=ui.config))
+    buildopts = {
+        'text': opts and opts.get('text'),
+        'git': get('git'),
+        'nodates': get('nodates'),
+        'nobinary': get('nobinary'),
+        'noprefix': get('noprefix', forceplain=False),
+        'showfunc': get('show_function', 'showfunc'),
+        'ignorews': get('ignore_all_space', 'ignorews'),
+        'ignorewsamount': get('ignore_space_change', 'ignorewsamount'),
+        'ignoreblanklines': get('ignore_blank_lines', 'ignoreblanklines'),
+        'context': get('unified', getter=ui.config),
+    }
+
+    return mdiff.diffopts(**buildopts)
 
 def diff(repo, node1=None, node2=None, match=None, changes=None, opts=None,
          losedatafn=None, prefix=''):