Details
Details
- Reviewers
pulkit - Group Reviewers
hg-reviewers - Commits
- rHGa4a95bd7158d: filemerge: give some variables in _xmerge more descriptive names
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
( )
| pulkit |
| hg-reviewers |
| Lint Skipped |
| Unit Tests Skipped |
| Path | Packages | |||
|---|---|---|---|---|
| M | mercurial/filemerge.py (20 lines) |
| def _xmerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None): | def _xmerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None): | ||||
| tool, toolpath, binary, symlink = toolconf | tool, toolpath, binary, symlink = toolconf | ||||
| if fcd.isabsent() or fco.isabsent(): | if fcd.isabsent() or fco.isabsent(): | ||||
| repo.ui.warn(_('warning: %s cannot merge change/delete conflict ' | repo.ui.warn(_('warning: %s cannot merge change/delete conflict ' | ||||
| 'for %s\n') % (tool, fcd.path())) | 'for %s\n') % (tool, fcd.path())) | ||||
| return False, 1, None | return False, 1, None | ||||
| unused, unused, unused, back = files | unused, unused, unused, back = files | ||||
| a = _workingpath(repo, fcd) | localpath = _workingpath(repo, fcd) | ||||
| b, c = _maketempfiles(repo, fco, fca) | basepath, otherpath = _maketempfiles(repo, fco, fca) | ||||
| try: | try: | ||||
| out = "" | outpath = "" | ||||
| mylabel, otherlabel = labels[:2] | mylabel, otherlabel = labels[:2] | ||||
| if len(labels) >= 3: | if len(labels) >= 3: | ||||
| baselabel = labels[2] | baselabel = labels[2] | ||||
| else: | else: | ||||
| baselabel = 'base' | baselabel = 'base' | ||||
| env = {'HG_FILE': fcd.path(), | env = {'HG_FILE': fcd.path(), | ||||
| 'HG_MY_NODE': short(mynode), | 'HG_MY_NODE': short(mynode), | ||||
| 'HG_OTHER_NODE': short(fco.changectx().node()), | 'HG_OTHER_NODE': short(fco.changectx().node()), | ||||
| 'HG_BASE_NODE': short(fca.changectx().node()), | 'HG_BASE_NODE': short(fca.changectx().node()), | ||||
| 'HG_MY_ISLINK': 'l' in fcd.flags(), | 'HG_MY_ISLINK': 'l' in fcd.flags(), | ||||
| 'HG_OTHER_ISLINK': 'l' in fco.flags(), | 'HG_OTHER_ISLINK': 'l' in fco.flags(), | ||||
| 'HG_BASE_ISLINK': 'l' in fca.flags(), | 'HG_BASE_ISLINK': 'l' in fca.flags(), | ||||
| 'HG_MY_LABEL': mylabel, | 'HG_MY_LABEL': mylabel, | ||||
| 'HG_OTHER_LABEL': otherlabel, | 'HG_OTHER_LABEL': otherlabel, | ||||
| 'HG_BASE_LABEL': baselabel, | 'HG_BASE_LABEL': baselabel, | ||||
| } | } | ||||
| ui = repo.ui | ui = repo.ui | ||||
| args = _toolstr(ui, tool, "args") | args = _toolstr(ui, tool, "args") | ||||
| if "$output" in args: | if "$output" in args: | ||||
| # read input from backup, write to original | # read input from backup, write to original | ||||
| out = a | outpath = localpath | ||||
| a = repo.wvfs.join(back.path()) | localpath = repo.wvfs.join(back.path()) | ||||
| replace = {'local': a, 'base': b, 'other': c, 'output': out, | replace = {'local': localpath, 'base': basepath, 'other': otherpath, | ||||
| 'labellocal': mylabel, 'labelother': otherlabel, | 'output': outpath, 'labellocal': mylabel, | ||||
| 'labelbase': baselabel} | 'labelother': otherlabel, 'labelbase': baselabel} | ||||
| args = util.interpolate(br'\$', replace, args, | args = util.interpolate(br'\$', replace, args, | ||||
| lambda s: util.shellquote(util.localpath(s))) | lambda s: util.shellquote(util.localpath(s))) | ||||
| cmd = toolpath + ' ' + args | cmd = toolpath + ' ' + args | ||||
| if _toolbool(ui, tool, "gui"): | if _toolbool(ui, tool, "gui"): | ||||
| repo.ui.status(_('running merge tool %s for file %s\n') % | repo.ui.status(_('running merge tool %s for file %s\n') % | ||||
| (tool, fcd.path())) | (tool, fcd.path())) | ||||
| repo.ui.debug('launching merge tool: %s\n' % cmd) | repo.ui.debug('launching merge tool: %s\n' % cmd) | ||||
| r = ui.system(cmd, cwd=repo.root, environ=env, blockedtag='mergetool') | r = ui.system(cmd, cwd=repo.root, environ=env, blockedtag='mergetool') | ||||
| repo.ui.debug('merge tool returned: %d\n' % r) | repo.ui.debug('merge tool returned: %d\n' % r) | ||||
| return True, r, False | return True, r, False | ||||
| finally: | finally: | ||||
| util.unlink(b) | util.unlink(basepath) | ||||
| util.unlink(c) | util.unlink(otherpath) | ||||
| def _formatconflictmarker(ctx, template, label, pad): | def _formatconflictmarker(ctx, template, label, pad): | ||||
| """Applies the given template to the ctx, prefixed by the label. | """Applies the given template to the ctx, prefixed by the label. | ||||
| Pad is the minimum width of the label prefix, so that multiple markers | Pad is the minimum width of the label prefix, so that multiple markers | ||||
| can have aligned templated parts. | can have aligned templated parts. | ||||
| """ | """ | ||||
| if ctx.node() is None: | if ctx.node() is None: | ||||