Mercurial > public > mercurial-scm > hg
comparison mercurial/filemerge.py @ 41510:faa49a5914bb
merge: respect ui.relative-paths
We print file paths in a lot of places in this code and I've probably
missed a few places. We can fix them as we discover them (I'm also
happy to fix anything reviewers notice, of course).
Differential Revision: https://phab.mercurial-scm.org/D5747
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Wed, 30 Jan 2019 12:05:43 -0800 |
parents | 876494fd967d |
children | a8ccd821b7d2 |
comparison
equal
deleted
inserted
replaced
41509:11c076786d56 | 41510:faa49a5914bb |
---|---|
277 def _iprompt(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None): | 277 def _iprompt(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None): |
278 """Asks the user which of the local `p1()` or the other `p2()` version to | 278 """Asks the user which of the local `p1()` or the other `p2()` version to |
279 keep as the merged version.""" | 279 keep as the merged version.""" |
280 ui = repo.ui | 280 ui = repo.ui |
281 fd = fcd.path() | 281 fd = fcd.path() |
282 uipathfn = scmutil.getuipathfn(repo) | |
282 | 283 |
283 # Avoid prompting during an in-memory merge since it doesn't support merge | 284 # Avoid prompting during an in-memory merge since it doesn't support merge |
284 # conflicts. | 285 # conflicts. |
285 if fcd.changectx().isinmemory(): | 286 if fcd.changectx().isinmemory(): |
286 raise error.InMemoryMergeConflictsError('in-memory merge does not ' | 287 raise error.InMemoryMergeConflictsError('in-memory merge does not ' |
287 'support file conflicts') | 288 'support file conflicts') |
288 | 289 |
289 prompts = partextras(labels) | 290 prompts = partextras(labels) |
290 prompts['fd'] = fd | 291 prompts['fd'] = uipathfn(fd) |
291 try: | 292 try: |
292 if fco.isabsent(): | 293 if fco.isabsent(): |
293 index = ui.promptchoice( | 294 index = ui.promptchoice( |
294 _localchangedotherdeletedmsg % prompts, 2) | 295 _localchangedotherdeletedmsg % prompts, 2) |
295 choice = ['local', 'other', 'unresolved'][index] | 296 choice = ['local', 'other', 'unresolved'][index] |
392 _restorebackup(fcd, back) | 393 _restorebackup(fcd, back) |
393 return 1 # continue merging | 394 return 1 # continue merging |
394 | 395 |
395 def _mergecheck(repo, mynode, orig, fcd, fco, fca, toolconf): | 396 def _mergecheck(repo, mynode, orig, fcd, fco, fca, toolconf): |
396 tool, toolpath, binary, symlink, scriptfn = toolconf | 397 tool, toolpath, binary, symlink, scriptfn = toolconf |
398 uipathfn = scmutil.getuipathfn(repo) | |
397 if symlink: | 399 if symlink: |
398 repo.ui.warn(_('warning: internal %s cannot merge symlinks ' | 400 repo.ui.warn(_('warning: internal %s cannot merge symlinks ' |
399 'for %s\n') % (tool, fcd.path())) | 401 'for %s\n') % (tool, uipathfn(fcd.path()))) |
400 return False | 402 return False |
401 if fcd.isabsent() or fco.isabsent(): | 403 if fcd.isabsent() or fco.isabsent(): |
402 repo.ui.warn(_('warning: internal %s cannot merge change/delete ' | 404 repo.ui.warn(_('warning: internal %s cannot merge change/delete ' |
403 'conflict for %s\n') % (tool, fcd.path())) | 405 'conflict for %s\n') % (tool, uipathfn(fcd.path()))) |
404 return False | 406 return False |
405 return True | 407 return True |
406 | 408 |
407 def _merge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels, mode): | 409 def _merge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels, mode): |
408 """ | 410 """ |
578 resources=tres) | 580 resources=tres) |
579 ui.status(t.renderdefault(props)) | 581 ui.status(t.renderdefault(props)) |
580 | 582 |
581 def _xmerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None): | 583 def _xmerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None): |
582 tool, toolpath, binary, symlink, scriptfn = toolconf | 584 tool, toolpath, binary, symlink, scriptfn = toolconf |
585 uipathfn = scmutil.getuipathfn(repo) | |
583 if fcd.isabsent() or fco.isabsent(): | 586 if fcd.isabsent() or fco.isabsent(): |
584 repo.ui.warn(_('warning: %s cannot merge change/delete conflict ' | 587 repo.ui.warn(_('warning: %s cannot merge change/delete conflict ' |
585 'for %s\n') % (tool, fcd.path())) | 588 'for %s\n') % (tool, uipathfn(fcd.path()))) |
586 return False, 1, None | 589 return False, 1, None |
587 unused, unused, unused, back = files | 590 unused, unused, unused, back = files |
588 localpath = _workingpath(repo, fcd) | 591 localpath = _workingpath(repo, fcd) |
589 args = _toolstr(repo.ui, tool, "args") | 592 args = _toolstr(repo.ui, tool, "args") |
590 | 593 |
620 args = util.interpolate( | 623 args = util.interpolate( |
621 br'\$', replace, args, | 624 br'\$', replace, args, |
622 lambda s: procutil.shellquote(util.localpath(s))) | 625 lambda s: procutil.shellquote(util.localpath(s))) |
623 if _toolbool(ui, tool, "gui"): | 626 if _toolbool(ui, tool, "gui"): |
624 repo.ui.status(_('running merge tool %s for file %s\n') % | 627 repo.ui.status(_('running merge tool %s for file %s\n') % |
625 (tool, fcd.path())) | 628 (tool, uipathfn(fcd.path()))) |
626 if scriptfn is None: | 629 if scriptfn is None: |
627 cmd = toolpath + ' ' + args | 630 cmd = toolpath + ' ' + args |
628 repo.ui.debug('launching merge tool: %s\n' % cmd) | 631 repo.ui.debug('launching merge tool: %s\n' % cmd) |
629 _describemerge(ui, repo, mynode, fcd, fca, fco, env, toolpath, args) | 632 _describemerge(ui, repo, mynode, fcd, fca, fco, env, toolpath, args) |
630 r = ui.system(cmd, cwd=repo.root, environ=env, | 633 r = ui.system(cmd, cwd=repo.root, environ=env, |
839 if not fco.cmp(fcd): # files identical? | 842 if not fco.cmp(fcd): # files identical? |
840 return True, None, False | 843 return True, None, False |
841 | 844 |
842 ui = repo.ui | 845 ui = repo.ui |
843 fd = fcd.path() | 846 fd = fcd.path() |
847 uipathfn = scmutil.getuipathfn(repo) | |
848 fduipath = uipathfn(fd) | |
844 binary = fcd.isbinary() or fco.isbinary() or fca.isbinary() | 849 binary = fcd.isbinary() or fco.isbinary() or fca.isbinary() |
845 symlink = 'l' in fcd.flags() + fco.flags() | 850 symlink = 'l' in fcd.flags() + fco.flags() |
846 changedelete = fcd.isabsent() or fco.isabsent() | 851 changedelete = fcd.isabsent() or fco.isabsent() |
847 tool, toolpath = _picktool(repo, ui, fd, binary, symlink, changedelete) | 852 tool, toolpath = _picktool(repo, ui, fd, binary, symlink, changedelete) |
848 scriptfn = None | 853 scriptfn = None |
862 invalidsyntax = True | 867 invalidsyntax = True |
863 if invalidsyntax: | 868 if invalidsyntax: |
864 raise error.Abort(_("invalid 'python:' syntax: %s") % toolpath) | 869 raise error.Abort(_("invalid 'python:' syntax: %s") % toolpath) |
865 toolpath = script | 870 toolpath = script |
866 ui.debug("picked tool '%s' for %s (binary %s symlink %s changedelete %s)\n" | 871 ui.debug("picked tool '%s' for %s (binary %s symlink %s changedelete %s)\n" |
867 % (tool, fd, pycompat.bytestr(binary), pycompat.bytestr(symlink), | 872 % (tool, fduipath, pycompat.bytestr(binary), |
868 pycompat.bytestr(changedelete))) | 873 pycompat.bytestr(symlink), pycompat.bytestr(changedelete))) |
869 | 874 |
870 if tool in internals: | 875 if tool in internals: |
871 func = internals[tool] | 876 func = internals[tool] |
872 mergetype = func.mergetype | 877 mergetype = func.mergetype |
873 onfailure = func.onfailure | 878 onfailure = func.onfailure |
889 r, deleted = func(repo, mynode, orig, fcd, fco, fca, toolconf, labels) | 894 r, deleted = func(repo, mynode, orig, fcd, fco, fca, toolconf, labels) |
890 return True, r, deleted | 895 return True, r, deleted |
891 | 896 |
892 if premerge: | 897 if premerge: |
893 if orig != fco.path(): | 898 if orig != fco.path(): |
894 ui.status(_("merging %s and %s to %s\n") % (orig, fco.path(), fd)) | 899 ui.status(_("merging %s and %s to %s\n") % |
895 else: | 900 (uipathfn(orig), uipathfn(fco.path()), fduipath)) |
896 ui.status(_("merging %s\n") % fd) | 901 else: |
902 ui.status(_("merging %s\n") % fduipath) | |
897 | 903 |
898 ui.debug("my %s other %s ancestor %s\n" % (fcd, fco, fca)) | 904 ui.debug("my %s other %s ancestor %s\n" % (fcd, fco, fca)) |
899 | 905 |
900 if precheck and not precheck(repo, mynode, orig, fcd, fco, fca, | 906 if precheck and not precheck(repo, mynode, orig, fcd, fco, fca, |
901 toolconf): | 907 toolconf): |
902 if onfailure: | 908 if onfailure: |
903 if wctx.isinmemory(): | 909 if wctx.isinmemory(): |
904 raise error.InMemoryMergeConflictsError('in-memory merge does ' | 910 raise error.InMemoryMergeConflictsError('in-memory merge does ' |
905 'not support merge ' | 911 'not support merge ' |
906 'conflicts') | 912 'conflicts') |
907 ui.warn(onfailure % fd) | 913 ui.warn(onfailure % fduipath) |
908 return True, 1, False | 914 return True, 1, False |
909 | 915 |
910 back = _makebackup(repo, ui, wctx, fcd, premerge) | 916 back = _makebackup(repo, ui, wctx, fcd, premerge) |
911 files = (None, None, None, back) | 917 files = (None, None, None, back) |
912 r = 1 | 918 r = 1 |
955 if onfailure: | 961 if onfailure: |
956 if wctx.isinmemory(): | 962 if wctx.isinmemory(): |
957 raise error.InMemoryMergeConflictsError('in-memory merge ' | 963 raise error.InMemoryMergeConflictsError('in-memory merge ' |
958 'does not support ' | 964 'does not support ' |
959 'merge conflicts') | 965 'merge conflicts') |
960 ui.warn(onfailure % fd) | 966 ui.warn(onfailure % fduipath) |
961 _onfilemergefailure(ui) | 967 _onfilemergefailure(ui) |
962 | 968 |
963 return True, r, deleted | 969 return True, r, deleted |
964 finally: | 970 finally: |
965 if not r and back is not None: | 971 if not r and back is not None: |
983 return bool(re.search("^(<<<<<<< .*|=======|>>>>>>> .*)$", data, | 989 return bool(re.search("^(<<<<<<< .*|=======|>>>>>>> .*)$", data, |
984 re.MULTILINE)) | 990 re.MULTILINE)) |
985 | 991 |
986 def _check(repo, r, ui, tool, fcd, files): | 992 def _check(repo, r, ui, tool, fcd, files): |
987 fd = fcd.path() | 993 fd = fcd.path() |
994 uipathfn = scmutil.getuipathfn(repo) | |
988 unused, unused, unused, back = files | 995 unused, unused, unused, back = files |
989 | 996 |
990 if not r and (_toolbool(ui, tool, "checkconflicts") or | 997 if not r and (_toolbool(ui, tool, "checkconflicts") or |
991 'conflicts' in _toollist(ui, tool, "check")): | 998 'conflicts' in _toollist(ui, tool, "check")): |
992 if hasconflictmarkers(fcd.data()): | 999 if hasconflictmarkers(fcd.data()): |
994 | 1001 |
995 checked = False | 1002 checked = False |
996 if 'prompt' in _toollist(ui, tool, "check"): | 1003 if 'prompt' in _toollist(ui, tool, "check"): |
997 checked = True | 1004 checked = True |
998 if ui.promptchoice(_("was merge of '%s' successful (yn)?" | 1005 if ui.promptchoice(_("was merge of '%s' successful (yn)?" |
999 "$$ &Yes $$ &No") % fd, 1): | 1006 "$$ &Yes $$ &No") % uipathfn(fd), 1): |
1000 r = 1 | 1007 r = 1 |
1001 | 1008 |
1002 if not r and not checked and (_toolbool(ui, tool, "checkchanged") or | 1009 if not r and not checked and (_toolbool(ui, tool, "checkchanged") or |
1003 'changed' in | 1010 'changed' in |
1004 _toollist(ui, tool, "check")): | 1011 _toollist(ui, tool, "check")): |
1005 if back is not None and not fcd.cmp(back): | 1012 if back is not None and not fcd.cmp(back): |
1006 if ui.promptchoice(_(" output file %s appears unchanged\n" | 1013 if ui.promptchoice(_(" output file %s appears unchanged\n" |
1007 "was merge successful (yn)?" | 1014 "was merge successful (yn)?" |
1008 "$$ &Yes $$ &No") % fd, 1): | 1015 "$$ &Yes $$ &No") % uipathfn(fd), 1): |
1009 r = 1 | 1016 r = 1 |
1010 | 1017 |
1011 if back is not None and _toolbool(ui, tool, "fixeol"): | 1018 if back is not None and _toolbool(ui, tool, "fixeol"): |
1012 _matcheol(_workingpath(repo, fcd), back) | 1019 _matcheol(_workingpath(repo, fcd), back) |
1013 | 1020 |