Patchwork [3,of,8,V2] patch.diffopts: break get function into if statements

login
register
mail settings
Submitter Siddharth Agarwal
Date Nov. 13, 2014, 11:08 p.m.
Message ID <1b945e3178b5781a1012.1415920128@devbig136.prn2.facebook.com>
Download mbox | patch
Permalink /patch/6715/
State Accepted
Commit ac072c79bd9d4005d793eb94a01d5cb961e7f7bc
Headers show

Comments

Siddharth Agarwal - Nov. 13, 2014, 11:08 p.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1415864657 28800
#      Wed Nov 12 23:44:17 2014 -0800
# Node ID 1b945e3178b5781a10121adc9d2687be4b0e86cd
# Parent  83670f68811bd631d830067fc22e8452100c78b5
patch.diffopts: break get function into if statements

We're going to add another condition here, and with the current structure that
becomes just too confusing.

Patch

diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -1559,9 +1559,13 @@ 
     pass
 
 def diffopts(ui, opts=None, untrusted=False, section='diff'):
-    def get(key, name=None, getter=ui.configbool):
-        return ((opts and opts.get(key)) or
-                getter(section, name or key, None, untrusted=untrusted))
+    def get(key, name=None, getter=ui.configbool, forceplain=None):
+        if opts:
+            v = opts.get(key)
+            if v:
+                return v
+        return getter(section, name or key, None, untrusted=untrusted)
+
     return mdiff.diffopts(
         text=opts and opts.get('text'),
         git=get('git'),