comparison contrib/simplemerge @ 48603:77e24ee8994b

simplemerge: take arguments as annotated context objects The labels we put in conflict markers are formatted so the part before the ':' (typically says things like "local") is padded so the ':' is aligned among the labels. That means that if you specify a long label for "base" but the conflict marker style is "merge" (i.e. 2-way), the other two will have unwanted padding. We often don't specify a label for the base, so we don't notice the problem (and it may very well be that it didn't exist before my D11972). I think the best fix is to pass the labels along with the context objects, so the low-level code that switches on the marker style to use (i.e. `simplemerge`) can do the formatting. This patch starts doing that by passing a fully-formatted label to `simplemerge`. A coming patch will move the formatting to `simplemerge`. Differential Revision: https://phab.mercurial-scm.org/D12013
author Martin von Zweigbergk <martinvonz@google.com>
date Thu, 20 Jan 2022 11:00:30 -0800
parents 6ad70879d2bd
children 9ee70e175fed
comparison
equal deleted inserted replaced
48602:62682662346c 48603:77e24ee8994b
82 raise ParseError(_(b'wrong number of arguments').decode('utf8')) 82 raise ParseError(_(b'wrong number of arguments').decode('utf8'))
83 if len(opts[b'label']) > 2: 83 if len(opts[b'label']) > 2:
84 opts[b'mode'] = b'merge3' 84 opts[b'mode'] = b'merge3'
85 local, base, other = args 85 local, base, other = args
86 overrides = opts[b'label'] 86 overrides = opts[b'label']
87 if len(overrides) > 3:
88 raise error.InputError(b'can only specify three labels.')
87 labels = [local, other, base] 89 labels = [local, other, base]
88 labels[: len(overrides)] = overrides 90 labels[: len(overrides)] = overrides
89 opts[b'label'] = labels 91 local_input = simplemerge.MergeInput(
92 context.arbitraryfilectx(local), labels[0]
93 )
94 other_input = simplemerge.MergeInput(
95 context.arbitraryfilectx(other), labels[1]
96 )
97 base_input = simplemerge.MergeInput(
98 context.arbitraryfilectx(base), labels[2]
99 )
90 sys.exit( 100 sys.exit(
91 simplemerge.simplemerge( 101 simplemerge.simplemerge(
92 uimod.ui.load(), 102 uimod.ui.load(),
93 context.arbitraryfilectx(local), 103 local_input,
94 context.arbitraryfilectx(base), 104 base_input,
95 context.arbitraryfilectx(other), 105 other_input,
96 **pycompat.strkwargs(opts) 106 **pycompat.strkwargs(opts)
97 ) 107 )
98 ) 108 )
99 except ParseError as e: 109 except ParseError as e:
100 e = stringutil.forcebytestr(e) 110 e = stringutil.forcebytestr(e)