Details
Details
- Reviewers
- None
- Group Reviewers
hg-reviewers - Commits
- rHGfa6309c5761d: simplemerge: stop accepting, and passing, file parameters
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
hg-reviewers |
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | contrib/simplemerge (3 lines) | |||
M | mercurial/filemerge.py (6 lines) | |||
M | mercurial/simplemerge.py (4 lines) |
raise ParseError(e) | raise ParseError(e) | ||||
if opts['help']: | if opts['help']: | ||||
showhelp() | showhelp() | ||||
sys.exit(0) | sys.exit(0) | ||||
if len(args) != 3: | if len(args) != 3: | ||||
raise ParseError(_('wrong number of arguments')) | raise ParseError(_('wrong number of arguments')) | ||||
local, base, other = args | local, base, other = args | ||||
sys.exit(simplemerge.simplemerge(uimod.ui.load(), | sys.exit(simplemerge.simplemerge(uimod.ui.load(), | ||||
local, | |||||
base, | |||||
other, | |||||
filebackedctx(local), | filebackedctx(local), | ||||
filebackedctx(base), | filebackedctx(base), | ||||
filebackedctx(other), | filebackedctx(other), | ||||
filtereddata=True, | filtereddata=True, | ||||
**opts)) | **opts)) | ||||
except ParseError as e: | except ParseError as e: | ||||
sys.stdout.write("%s: %s\n" % (sys.argv[0], e)) | sys.stdout.write("%s: %s\n" % (sys.argv[0], e)) | ||||
showhelp() | showhelp() | ||||
sys.exit(1) | sys.exit(1) | ||||
except error.Abort as e: | except error.Abort as e: | ||||
sys.stderr.write("abort: %s\n" % e) | sys.stderr.write("abort: %s\n" % e) | ||||
sys.exit(255) | sys.exit(255) | ||||
except KeyboardInterrupt: | except KeyboardInterrupt: | ||||
sys.exit(255) | sys.exit(255) |
(tool, premerge, _valid)) | (tool, premerge, _valid)) | ||||
if premerge: | if premerge: | ||||
if premerge == 'keep-merge3': | if premerge == 'keep-merge3': | ||||
if not labels: | if not labels: | ||||
labels = _defaultconflictlabels | labels = _defaultconflictlabels | ||||
if len(labels) < 3: | if len(labels) < 3: | ||||
labels.append('base') | labels.append('base') | ||||
r = simplemerge.simplemerge(ui, a, b, c, fcd, fca, fco, | r = simplemerge.simplemerge(ui, fcd, fca, fco, | ||||
quiet=True, label=labels, repo=repo) | quiet=True, label=labels, repo=repo) | ||||
if not r: | if not r: | ||||
ui.debug(" premerge successful\n") | ui.debug(" premerge successful\n") | ||||
return 0 | return 0 | ||||
if premerge not in validkeep: | if premerge not in validkeep: | ||||
util.copyfile(back, a) # restore from backup and try again | util.copyfile(back, a) # restore from backup and try again | ||||
return 1 # continue merging | return 1 # continue merging | ||||
Uses the internal non-interactive simple merge algorithm for merging | Uses the internal non-interactive simple merge algorithm for merging | ||||
files. It will fail if there are any conflicts and leave markers in | files. It will fail if there are any conflicts and leave markers in | ||||
the partially merged file. Markers will have two sections, one for each side | the partially merged file. Markers will have two sections, one for each side | ||||
of merge, unless mode equals 'union' which suppresses the markers.""" | of merge, unless mode equals 'union' which suppresses the markers.""" | ||||
a, b, c, back = files | a, b, c, back = files | ||||
ui = repo.ui | ui = repo.ui | ||||
r = simplemerge.simplemerge(ui, a, b, c, fcd, fca, fco, | r = simplemerge.simplemerge(ui, fcd, fca, fco, | ||||
label=labels, mode=mode, repo=repo) | label=labels, mode=mode, repo=repo) | ||||
return True, r, False | return True, r, False | ||||
@internaltool('union', fullmerge, | @internaltool('union', fullmerge, | ||||
_("warning: conflicts while merging %s! " | _("warning: conflicts while merging %s! " | ||||
"(edit, then use 'hg resolve --mark')\n"), | "(edit, then use 'hg resolve --mark')\n"), | ||||
precheck=_mergecheck) | precheck=_mergecheck) | ||||
def _iunion(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None): | def _iunion(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None): | ||||
def _imergeauto(repo, mynode, orig, fcd, fco, fca, toolconf, files, | def _imergeauto(repo, mynode, orig, fcd, fco, fca, toolconf, files, | ||||
labels=None, localorother=None): | labels=None, localorother=None): | ||||
""" | """ | ||||
Generic driver for _imergelocal and _imergeother | Generic driver for _imergelocal and _imergeother | ||||
""" | """ | ||||
assert localorother is not None | assert localorother is not None | ||||
tool, toolpath, binary, symlink = toolconf | tool, toolpath, binary, symlink = toolconf | ||||
a, b, c, back = files | a, b, c, back = files | ||||
r = simplemerge.simplemerge(repo.ui, a, b, c, fcd, fca, fco, | r = simplemerge.simplemerge(repo.ui, fcd, fca, fco, | ||||
label=labels, localorother=localorother, | label=labels, localorother=localorother, | ||||
repo=repo) | repo=repo) | ||||
return True, r | return True, r | ||||
@internaltool('merge-local', mergeonly, precheck=_mergecheck) | @internaltool('merge-local', mergeonly, precheck=_mergecheck) | ||||
def _imergelocal(*args, **kwargs): | def _imergelocal(*args, **kwargs): | ||||
""" | """ | ||||
Like :merge, but resolve all conflicts non-interactively in favor | Like :merge, but resolve all conflicts non-interactively in favor |
name_b = overrides[1] | name_b = overrides[1] | ||||
if len(overrides) > 2: | if len(overrides) > 2: | ||||
name_base = overrides[2] | name_base = overrides[2] | ||||
if len(overrides) > 3: | if len(overrides) > 3: | ||||
raise error.Abort(_("can only specify three labels.")) | raise error.Abort(_("can only specify three labels.")) | ||||
return [name_a, name_b, name_base] | return [name_a, name_b, name_base] | ||||
def simplemerge(ui, localfile, basefile, otherfile, | def simplemerge(ui, localctx=None, basectx=None, otherctx=None, repo=None, | ||||
localctx=None, basectx=None, otherctx=None, repo=None, **opts): | **opts): | ||||
"""Performs the simplemerge algorithm. | """Performs the simplemerge algorithm. | ||||
{local|base|other}ctx are optional. If passed, they (local/base/other) will | {local|base|other}ctx are optional. If passed, they (local/base/other) will | ||||
be read from and the merge result written to (local). You should pass | be read from and the merge result written to (local). You should pass | ||||
explicit labels in this mode since the default is to use the file paths. | explicit labels in this mode since the default is to use the file paths. | ||||
""" | """ | ||||
def readctx(ctx): | def readctx(ctx): | ||||
if not ctx: | if not ctx: |