[PATCH 2 of 7] patch: add a new function to initialize diffopts by feature

Siddharth Agarwal sid0 at fb.com
Tue Nov 25 21:53:57 CST 2014


# HG changeset patch
# User Siddharth Agarwal <sid0 at fb.com>
# Date 1416358402 28800
#      Tue Nov 18 16:53:22 2014 -0800
# Node ID 738077e9f57d2cb1ca2a3b7cd134f643b6adecff
# Parent  491b6bf7bc858efe4f43c5d347f68f0624d846c1
patch: add a new function to initialize diffopts by feature

Not all callers are interested in all diffopts -- for example, commands like
record (which use diff internally) break when diffopts like noprefix are
enabled. This function will allow us to add flags that callers can use to
enable only the features they're interested in.

diff --git mercurial/patch.py mercurial/patch.py
--- mercurial/patch.py
+++ mercurial/patch.py
@@ -1559,6 +1559,11 @@
     pass
 
 def diffopts(ui, opts=None, untrusted=False, section='diff'):
+    '''return diffopts with all features supported and parsed'''
+    return difffeatureopts(ui, opts=opts, untrusted=untrusted, section=section)
+
+def difffeatureopts(ui, opts=None, untrusted=False, section='diff'):
+    '''return diffopts with only opted-in features parsed'''
     def get(key, name=None, getter=ui.configbool, forceplain=None):
         if opts:
             v = opts.get(key)


More information about the Mercurial-devel mailing list