Depends on D952.
This allows the user to halt the merge if conflict markers or no changes are
found in the merged file as well.
| mbthomas |
| hg-reviewers |
Depends on D952.
This allows the user to halt the merge if conflict markers or no changes are
found in the merged file as well.
| No Linters Available |
| No Unit Test Coverage |
It turns out this isn't needed -- setting the return to 1 means we catch the failure in the generic handler I added earlier. I fixed up the tests in the previous patch to include the important test changes from here (ie, more testing of the prompt stuff).
| Path | Packages | |||
|---|---|---|---|---|
| M | mercurial/filemerge.py (2 lines) | |||
| M | tests/test-merge-halt.t (7 lines) |
| Commit | Local | Parents | Author | Summary | Date |
|---|---|---|---|---|---|
| 80d814b20fa1 | 37531 | 69e3b460d006 | Ryan McElroy | merge: use filemerge failure handler for additional checks | Oct 5 2017, 5:16 AM |
| r = 1 | r = 1 | ||||
| checked = False | checked = False | ||||
| if 'prompt' in _toollist(ui, tool, "check"): | if 'prompt' in _toollist(ui, tool, "check"): | ||||
| checked = True | checked = True | ||||
| if ui.promptchoice(_("was merge of '%s' successful (yn)?" | if ui.promptchoice(_("was merge of '%s' successful (yn)?" | ||||
| "$$ &Yes $$ &No") % fd, 1): | "$$ &Yes $$ &No") % fd, 1): | ||||
| r = 1 | r = 1 | ||||
| _onfilemergefailure(ui) | |||||
| if not r and not checked and (_toolbool(ui, tool, "checkchanged") or | if not r and not checked and (_toolbool(ui, tool, "checkchanged") or | ||||
| 'changed' in | 'changed' in | ||||
| _toollist(ui, tool, "check")): | _toollist(ui, tool, "check")): | ||||
| if back is not None and filecmp.cmp(_workingpath(repo, fcd), back): | if back is not None and filecmp.cmp(_workingpath(repo, fcd), back): | ||||
| if ui.promptchoice(_(" output file %s appears unchanged\n" | if ui.promptchoice(_(" output file %s appears unchanged\n" | ||||
| "was merge successful (yn)?" | "was merge successful (yn)?" | ||||
| "$$ &Yes $$ &No") % fd, 1): | "$$ &Yes $$ &No") % fd, 1): | ||||
| r = 1 | r = 1 | ||||
| _onfilemergefailure(ui) | |||||
| if back is not None and _toolbool(ui, tool, "fixeol"): | if back is not None and _toolbool(ui, tool, "fixeol"): | ||||
| _matcheol(_workingpath(repo, fcd), back) | _matcheol(_workingpath(repo, fcd), back) | ||||
| return r | return r | ||||
| def _workingpath(repo, ctx): | def _workingpath(repo, ctx): | ||||
| return repo.wjoin(ctx.path()) | return repo.wjoin(ctx.path()) | ||||
| > true.check=changed | > true.check=changed | ||||
| > EOS | > EOS | ||||
| $ hg rebase -s 1 -d 2 --tool true | $ hg rebase -s 1 -d 2 --tool true | ||||
| rebasing 1:1f28a51c3c9b "c" | rebasing 1:1f28a51c3c9b "c" | ||||
| merging a | merging a | ||||
| merging b | merging b | ||||
| output file a appears unchanged | output file a appears unchanged | ||||
| was merge successful (yn)? n | was merge successful (yn)? n | ||||
| merging a failed! | |||||
| merge halted after failed merge (see hg resolve) | merge halted after failed merge (see hg resolve) | ||||
| [1] | [1] | ||||
| $ hg resolve --list | $ hg resolve --list | ||||
| U a | U a | ||||
| U b | U b | ||||
| $ hg rebase --abort | $ hg rebase --abort | ||||
| Check conflict prompts | Check conflict prompts | ||||
| $ hg rebase --abort | $ hg rebase --abort | ||||
| rebase aborted | rebase aborted | ||||
| $ hg rebase -s 1 -d 2 --tool true --config merge-tools.true.check=prompt | $ hg rebase -s 1 -d 2 --tool true --config merge-tools.true.check=prompt | ||||
| rebasing 1:1f28a51c3c9b "c" | rebasing 1:1f28a51c3c9b "c" | ||||
| merging a | merging a | ||||
| merging b | merging b | ||||
| was merge of 'a' successful (yn)? n | was merge of 'a' successful (yn)? n | ||||
| merging a failed! | |||||
| merge halted after failed merge (see hg resolve) | merge halted after failed merge (see hg resolve) | ||||
| [1] | [1] | ||||
| $ hg rebase --abort | $ hg rebase --abort | ||||
| rebase aborted | rebase aborted | ||||
| Check that a requested abort actually works | Check that a requested abort actually works | ||||
| $ cat <<EOS >> $HGRCPATH | |||||
| > [merge] | |||||
| > onfailure=prompt | |||||
| > EOS | |||||
| $ cat <<EOS | hg rebase -s 1 -d 2 --tool false --config ui.interactive=1 | $ cat <<EOS | hg rebase -s 1 -d 2 --tool false --config ui.interactive=1 | ||||
| > n | > n | ||||
| > EOS | > EOS | ||||
| rebasing 1:1f28a51c3c9b "c" | rebasing 1:1f28a51c3c9b "c" | ||||
| merging a | merging a | ||||
| merging b | merging b | ||||
| merging a failed! | merging a failed! | ||||
| continue merge operation (yn)? n | |||||
| merge halted after failed merge (see hg resolve) | merge halted after failed merge (see hg resolve) | ||||
| [1] | [1] | ||||
| $ hg rebase --abort | $ hg rebase --abort | ||||
| rebase aborted | rebase aborted | ||||
| Check that successful tool otherwise allows the merge to continue | Check that successful tool otherwise allows the merge to continue | ||||
| $ hg rebase -s 1 -d 2 --tool echo --keep --config merge-tools.echo.premerge=keep | $ hg rebase -s 1 -d 2 --tool echo --keep --config merge-tools.echo.premerge=keep | ||||
| rebasing 1:1f28a51c3c9b "c" | rebasing 1:1f28a51c3c9b "c" | ||||
| merging a | merging a | ||||
| merging b | merging b | ||||
| $TESTTMP/repo/a *a~base* *a~other* (glob) | $TESTTMP/repo/a *a~base* *a~other* (glob) | ||||
| $TESTTMP/repo/b *b~base* *b~other* (glob) | $TESTTMP/repo/b *b~base* *b~other* (glob) | ||||