70 section, configprefix + (name or key), untrusted=untrusted |
70 section, configprefix + (name or key), untrusted=untrusted |
71 ) |
71 ) |
72 |
72 |
73 # core options, expected to be understood by every diff parser |
73 # core options, expected to be understood by every diff parser |
74 buildopts = { |
74 buildopts = { |
75 'nodates': get('nodates'), |
75 b'nodates': get(b'nodates'), |
76 'showfunc': get('show_function', 'showfunc'), |
76 b'showfunc': get(b'show_function', b'showfunc'), |
77 'context': get('unified', getter=ui.config), |
77 b'context': get(b'unified', getter=ui.config), |
78 } |
78 } |
79 buildopts['xdiff'] = ui.configbool('experimental', 'xdiff') |
79 buildopts[b'xdiff'] = ui.configbool(b'experimental', b'xdiff') |
80 |
80 |
81 if git: |
81 if git: |
82 buildopts['git'] = get('git') |
82 buildopts[b'git'] = get(b'git') |
83 |
83 |
84 # since this is in the experimental section, we need to call |
84 # since this is in the experimental section, we need to call |
85 # ui.configbool directory |
85 # ui.configbool directory |
86 buildopts['showsimilarity'] = ui.configbool( |
86 buildopts[b'showsimilarity'] = ui.configbool( |
87 'experimental', 'extendedheader.similarity' |
87 b'experimental', b'extendedheader.similarity' |
88 ) |
88 ) |
89 |
89 |
90 # need to inspect the ui object instead of using get() since we want to |
90 # need to inspect the ui object instead of using get() since we want to |
91 # test for an int |
91 # test for an int |
92 hconf = ui.config('experimental', 'extendedheader.index') |
92 hconf = ui.config(b'experimental', b'extendedheader.index') |
93 if hconf is not None: |
93 if hconf is not None: |
94 hlen = None |
94 hlen = None |
95 try: |
95 try: |
96 # the hash config could be an integer (for length of hash) or a |
96 # the hash config could be an integer (for length of hash) or a |
97 # word (e.g. short, full, none) |
97 # word (e.g. short, full, none) |
98 hlen = int(hconf) |
98 hlen = int(hconf) |
99 if hlen < 0 or hlen > 40: |
99 if hlen < 0 or hlen > 40: |
100 msg = _("invalid length for extendedheader.index: '%d'\n") |
100 msg = _(b"invalid length for extendedheader.index: '%d'\n") |
101 ui.warn(msg % hlen) |
101 ui.warn(msg % hlen) |
102 except ValueError: |
102 except ValueError: |
103 # default value |
103 # default value |
104 if hconf == 'short' or hconf == '': |
104 if hconf == b'short' or hconf == b'': |
105 hlen = 12 |
105 hlen = 12 |
106 elif hconf == 'full': |
106 elif hconf == b'full': |
107 hlen = 40 |
107 hlen = 40 |
108 elif hconf != 'none': |
108 elif hconf != b'none': |
109 msg = _("invalid value for extendedheader.index: '%s'\n") |
109 msg = _(b"invalid value for extendedheader.index: '%s'\n") |
110 ui.warn(msg % hconf) |
110 ui.warn(msg % hconf) |
111 finally: |
111 finally: |
112 buildopts['index'] = hlen |
112 buildopts[b'index'] = hlen |
113 |
113 |
114 if whitespace: |
114 if whitespace: |
115 buildopts['ignorews'] = get('ignore_all_space', 'ignorews') |
115 buildopts[b'ignorews'] = get(b'ignore_all_space', b'ignorews') |
116 buildopts['ignorewsamount'] = get( |
116 buildopts[b'ignorewsamount'] = get( |
117 'ignore_space_change', 'ignorewsamount' |
117 b'ignore_space_change', b'ignorewsamount' |
118 ) |
118 ) |
119 buildopts['ignoreblanklines'] = get( |
119 buildopts[b'ignoreblanklines'] = get( |
120 'ignore_blank_lines', 'ignoreblanklines' |
120 b'ignore_blank_lines', b'ignoreblanklines' |
121 ) |
121 ) |
122 buildopts['ignorewseol'] = get('ignore_space_at_eol', 'ignorewseol') |
122 buildopts[b'ignorewseol'] = get(b'ignore_space_at_eol', b'ignorewseol') |
123 if formatchanging: |
123 if formatchanging: |
124 buildopts['text'] = opts and opts.get('text') |
124 buildopts[b'text'] = opts and opts.get(b'text') |
125 binary = None if opts is None else opts.get('binary') |
125 binary = None if opts is None else opts.get(b'binary') |
126 buildopts['nobinary'] = ( |
126 buildopts[b'nobinary'] = ( |
127 not binary |
127 not binary |
128 if binary is not None |
128 if binary is not None |
129 else get('nobinary', forceplain=False) |
129 else get(b'nobinary', forceplain=False) |
130 ) |
130 ) |
131 buildopts['noprefix'] = get('noprefix', forceplain=False) |
131 buildopts[b'noprefix'] = get(b'noprefix', forceplain=False) |
132 buildopts['worddiff'] = get('word_diff', 'word-diff', forceplain=False) |
132 buildopts[b'worddiff'] = get( |
|
133 b'word_diff', b'word-diff', forceplain=False |
|
134 ) |
133 |
135 |
134 return mdiff.diffopts(**pycompat.strkwargs(buildopts)) |
136 return mdiff.diffopts(**pycompat.strkwargs(buildopts)) |