Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/filemerge.py @ 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 | 62682662346c |
children | f970bc616ebc |
comparison
equal
deleted
inserted
replaced
48602:62682662346c | 48603:77e24ee8994b |
---|---|
426 mode = b'merge' | 426 mode = b'merge' |
427 if premerge == b'keep-mergediff': | 427 if premerge == b'keep-mergediff': |
428 mode = b'mergediff' | 428 mode = b'mergediff' |
429 elif premerge == b'keep-merge3': | 429 elif premerge == b'keep-merge3': |
430 mode = b'merge3' | 430 mode = b'merge3' |
431 local = simplemerge.MergeInput(fcd, labels[0]) | |
432 other = simplemerge.MergeInput(fco, labels[1]) | |
433 base = simplemerge.MergeInput(fca, labels[2]) | |
431 r = simplemerge.simplemerge( | 434 r = simplemerge.simplemerge( |
432 ui, fcd, fca, fco, quiet=True, label=labels, mode=mode | 435 ui, local, base, other, quiet=True, mode=mode |
433 ) | 436 ) |
434 if not r: | 437 if not r: |
435 ui.debug(b" premerge successful\n") | 438 ui.debug(b" premerge successful\n") |
436 return 0 | 439 return 0 |
437 if premerge not in validkeep: | 440 if premerge not in validkeep: |
467 files. It will fail if there are any conflicts and leave markers in | 470 files. It will fail if there are any conflicts and leave markers in |
468 the partially merged file. Markers will have two sections, one for each side | 471 the partially merged file. Markers will have two sections, one for each side |
469 of merge, unless mode equals 'union' which suppresses the markers.""" | 472 of merge, unless mode equals 'union' which suppresses the markers.""" |
470 ui = repo.ui | 473 ui = repo.ui |
471 | 474 |
472 r = simplemerge.simplemerge(ui, fcd, fca, fco, label=labels, mode=mode) | 475 local = simplemerge.MergeInput(fcd) |
476 if len(labels) > 0: | |
477 local.label = labels[0] | |
478 other = simplemerge.MergeInput(fco) | |
479 if len(labels) > 1: | |
480 other.label = labels[1] | |
481 base = simplemerge.MergeInput(fca) | |
482 if len(labels) > 2: | |
483 base.label = labels[2] | |
484 r = simplemerge.simplemerge(ui, local, base, other, mode=mode) | |
473 return True, r, False | 485 return True, r, False |
474 | 486 |
475 | 487 |
476 @internaltool( | 488 @internaltool( |
477 b'union', | 489 b'union', |