comparison mercurial/filemerge.py @ 48583:a809f1465a76

filemerge: set default labels a little earlier By setting the default labels a little earlier, we can rely on them always being set, as far as I can tell. It may actually even be fine to rely on that even if we don't set them earlier, but it makes more sense to me to do it. Differential Revision: https://phab.mercurial-scm.org/D12015
author Martin von Zweigbergk <martinvonz@google.com>
date Thu, 20 Jan 2022 13:43:43 -0800
parents f970bc616ebc
children 74973a6d4e67
comparison
equal deleted inserted replaced
48579:f970bc616ebc 48583:a809f1465a76
533 """ 533 """
534 Uses the internal non-interactive simple merge algorithm for merging 534 Uses the internal non-interactive simple merge algorithm for merging
535 files. It will fail if there are any conflicts and leave markers in 535 files. It will fail if there are any conflicts and leave markers in
536 the partially merged file. Marker will have three sections, one from each 536 the partially merged file. Marker will have three sections, one from each
537 side of the merge and one for the base content.""" 537 side of the merge and one for the base content."""
538 if not labels:
539 labels = _defaultconflictlabels
540 if len(labels) < 3: 538 if len(labels) < 3:
541 labels.append(b'base') 539 labels.append(b'base')
542 return _merge(repo, fcd, fco, fca, labels, b'merge3') 540 return _merge(repo, fcd, fco, fca, labels, b'merge3')
543 541
544 542
575 Uses the internal non-interactive simple merge algorithm for merging 573 Uses the internal non-interactive simple merge algorithm for merging
576 files. It will fail if there are any conflicts and leave markers in 574 files. It will fail if there are any conflicts and leave markers in
577 the partially merged file. The marker will have two sections, one with the 575 the partially merged file. The marker will have two sections, one with the
578 content from one side of the merge, and one with a diff from the base 576 content from one side of the merge, and one with a diff from the base
579 content to the content on the other side. (experimental)""" 577 content to the content on the other side. (experimental)"""
580 if not labels:
581 labels = _defaultconflictlabels
582 if len(labels) < 3: 578 if len(labels) < 3:
583 labels.append(b'base') 579 labels.append(b'base')
584 return _merge(repo, fcd, fco, fca, labels, b'mergediff') 580 return _merge(repo, fcd, fco, fca, labels, b'mergediff')
585 581
586 582
839 835
840 # 8 for the prefix of conflict marker lines (e.g. '<<<<<<< ') 836 # 8 for the prefix of conflict marker lines (e.g. '<<<<<<< ')
841 return stringutil.ellipsis(mark, 80 - 8) 837 return stringutil.ellipsis(mark, 80 - 8)
842 838
843 839
844 _defaultconflictlabels = [b'local', b'other']
845
846
847 def _formatlabels(repo, fcd, fco, fca, labels, tool=None): 840 def _formatlabels(repo, fcd, fco, fca, labels, tool=None):
848 """Formats the given labels using the conflict marker template. 841 """Formats the given labels using the conflict marker template.
849 842
850 Returns a list of formatted labels. 843 Returns a list of formatted labels.
851 """ 844 """
1066 precheck = None 1059 precheck = None
1067 isexternal = True 1060 isexternal = True
1068 1061
1069 toolconf = tool, toolpath, binary, symlink, scriptfn 1062 toolconf = tool, toolpath, binary, symlink, scriptfn
1070 1063
1064 if not labels:
1065 labels = [b'local', b'other']
1071 if mergetype == nomerge: 1066 if mergetype == nomerge:
1072 return func(repo, mynode, fcd, fco, fca, toolconf, labels) 1067 return func(repo, mynode, fcd, fco, fca, toolconf, labels)
1073 1068
1074 if orig != fco.path(): 1069 if orig != fco.path():
1075 ui.status( 1070 ui.status(
1097 if isexternal: 1092 if isexternal:
1098 markerstyle = _toolstr(ui, tool, b'mergemarkers') 1093 markerstyle = _toolstr(ui, tool, b'mergemarkers')
1099 else: 1094 else:
1100 markerstyle = internalmarkerstyle 1095 markerstyle = internalmarkerstyle
1101 1096
1102 if not labels:
1103 labels = _defaultconflictlabels
1104 formattedlabels = labels 1097 formattedlabels = labels
1105 if markerstyle != b'basic': 1098 if markerstyle != b'basic':
1106 formattedlabels = _formatlabels( 1099 formattedlabels = _formatlabels(
1107 repo, fcd, fco, fca, labels, tool=tool 1100 repo, fcd, fco, fca, labels, tool=tool
1108 ) 1101 )