Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/diffutil.py @ 50252:a6b8b1ab9116
branching: merge stable into default
The clippy god had to be appeased on some aspect.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Thu, 02 Mar 2023 19:02:52 +0100 |
parents | 024e0580b853 b8cac4e37100 |
children | d6e5bec550f1 |
comparison
equal
deleted
inserted
replaced
50251:2fbc109fd58a | 50252:a6b8b1ab9116 |
---|---|
5 # Copyright 2018 Octobus <octobus@octobus.net> | 5 # Copyright 2018 Octobus <octobus@octobus.net> |
6 # | 6 # |
7 # This software may be used and distributed according to the terms of the | 7 # This software may be used and distributed according to the terms of the |
8 # GNU General Public License version 2 or any later version. | 8 # GNU General Public License version 2 or any later version. |
9 | 9 |
10 import typing | |
11 | |
12 from typing import ( | |
13 Any, | |
14 Dict, | |
15 Optional, | |
16 ) | |
10 | 17 |
11 from .i18n import _ | 18 from .i18n import _ |
12 | 19 |
13 from . import ( | 20 from . import ( |
14 mdiff, | 21 mdiff, |
15 pycompat, | 22 pycompat, |
16 ) | 23 ) |
17 | 24 |
25 if typing.TYPE_CHECKING: | |
26 from . import ui as uimod | |
27 | |
28 # TODO: narrow the value after the config module is typed | |
29 _Opts = Dict[bytes, Any] | |
30 | |
18 | 31 |
19 def diffallopts( | 32 def diffallopts( |
20 ui, opts=None, untrusted=False, section=b'diff', configprefix=b'' | 33 ui: "uimod.ui", |
21 ): | 34 opts: Optional[_Opts] = None, |
35 untrusted: bool = False, | |
36 section: bytes = b'diff', | |
37 configprefix: bytes = b'', | |
38 ) -> mdiff.diffopts: | |
22 '''return diffopts with all features supported and parsed''' | 39 '''return diffopts with all features supported and parsed''' |
23 return difffeatureopts( | 40 return difffeatureopts( |
24 ui, | 41 ui, |
25 opts=opts, | 42 opts=opts, |
26 untrusted=untrusted, | 43 untrusted=untrusted, |
31 configprefix=configprefix, | 48 configprefix=configprefix, |
32 ) | 49 ) |
33 | 50 |
34 | 51 |
35 def difffeatureopts( | 52 def difffeatureopts( |
36 ui, | 53 ui: "uimod.ui", |
37 opts=None, | 54 opts: Optional[_Opts] = None, |
38 untrusted=False, | 55 untrusted: bool = False, |
39 section=b'diff', | 56 section: bytes = b'diff', |
40 git=False, | 57 git: bool = False, |
41 whitespace=False, | 58 whitespace: bool = False, |
42 formatchanging=False, | 59 formatchanging: bool = False, |
43 configprefix=b'', | 60 configprefix: bytes = b'', |
44 ): | 61 ) -> mdiff.diffopts: |
45 """return diffopts with only opted-in features parsed | 62 """return diffopts with only opted-in features parsed |
46 | 63 |
47 Features: | 64 Features: |
48 - git: git-style diffs | 65 - git: git-style diffs |
49 - whitespace: whitespace options like ignoreblanklines and ignorews | 66 - whitespace: whitespace options like ignoreblanklines and ignorews |
50 - formatchanging: options that will likely break or cause correctness issues | 67 - formatchanging: options that will likely break or cause correctness issues |
51 with most diff parsers | 68 with most diff parsers |
52 """ | 69 """ |
53 | 70 |
54 def get(key, name=None, getter=ui.configbool, forceplain=None): | 71 def get( |
72 key: bytes, | |
73 name: Optional[bytes] = None, | |
74 getter=ui.configbool, | |
75 forceplain: Optional[bool] = None, | |
76 ) -> Any: | |
55 if opts: | 77 if opts: |
56 v = opts.get(key) | 78 v = opts.get(key) |
57 # diffopts flags are either None-default (which is passed | 79 # diffopts flags are either None-default (which is passed |
58 # through unchanged, so we can identify unset values), or | 80 # through unchanged, so we can identify unset values), or |
59 # some other falsey default (eg --unified, which defaults | 81 # some other falsey default (eg --unified, which defaults |