D6588: abort: added support for merge
Closed by commit rHG3bc400ccbf99: abort: added support for merge (authored by taapas1128). This revision was automatically updated to reflect the committed changes. CHANGED PRIOR TO COMMIT https://phab.mercurial-scm.org/D6588?vs=15880=15883#toc REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D6588?vs=15880=15883 CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D6588/new/ REVISION DETAIL https://phab.mercurial-scm.org/D6588 AFFECTED FILES mercurial/commands.py mercurial/hg.py mercurial/state.py tests/test-commit-unresolved.t tests/test-shelve2.t CHANGE DETAILS diff --git a/tests/test-shelve2.t b/tests/test-shelve2.t --- a/tests/test-shelve2.t +++ b/tests/test-shelve2.t @@ -718,11 +718,16 @@ Unshelve --abort fails with appropriate message if there's no unshelve in progress + +#if abortflag + $ hg unshelve --abort + abort: no unshelve in progress + [255] +#else $ hg abort - abort: no unshelve in progress (abortflag !) - abort: merge in progress but does not support 'hg abort' (no-abortflag !) - (use 'hg commit' or 'hg merge --abort') (no-abortflag !) - [255] + aborting the merge, updating back to 9451eaa6eee3 + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved +#endif $ cd .. Unshelve respects --keep even if user intervention is needed diff --git a/tests/test-commit-unresolved.t b/tests/test-commit-unresolved.t --- a/tests/test-commit-unresolved.t +++ b/tests/test-commit-unresolved.t @@ -1,3 +1,11 @@ +#testcases abortcommand abortflag +#if abortflag + $ cat >> $HGRCPATH < [alias] + > abort = merge --abort + > EOF +#endif + $ addcommit () { > echo $1 > $1 > hg add $1 @@ -36,9 +44,11 @@ Testing the abort functionality first in case of conflicts - $ hg merge --abort - abort: no merge in progress + $ hg abort + abort: no merge in progress (abortflag !) + abort: no operation in progress (abortcommand !) [255] + $ hg merge merging A warning: conflicts while merging A! (edit, then use 'hg resolve --mark') @@ -53,7 +63,13 @@ abort: cannot specify both --rev and --abort [255] - $ hg merge --abort +#if abortcommand +when in dry-run mode + $ hg abort --dry-run + merge in progress, will be aborted +#endif + + $ hg abort aborting the merge, updating back to e45016d2b3d3 1 files updated, 0 files merged, 1 files removed, 0 files unresolved @@ -131,7 +147,7 @@ abort: cannot specify --preview with --abort [255] - $ hg merge --abort + $ hg abort aborting the merge, updating back to 68352a18a7c4 1 files updated, 0 files merged, 1 files removed, 0 files unresolved diff --git a/mercurial/state.py b/mercurial/state.py --- a/mercurial/state.py +++ b/mercurial/state.py @@ -205,13 +205,6 @@ 'To mark the changeset bad: hg bisect --bad\n' 'To abort: hg bisect --reset\n') ) -addunfinished( -'merge', fname=None, clearable=True, allowcommit=True, -cmdmsg=_('outstanding uncommitted merge'), -statushint=_('To continue:hg commit\n' - 'To abort: hg merge --abort'), -cmdhint=_("use 'hg commit' or 'hg merge --abort'") -) def getrepostate(repo): # experimental config: commands.status.skipstates diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -956,31 +956,35 @@ abort=False): """Branch merge with node, resolving changes. Return true if any unresolved conflicts.""" -if not abort: -stats = mergemod.update(repo, node, branchmerge=True, force=force, -mergeforce=mergeforce, labels=labels) -else: -ms = mergemod.mergestate.read(repo) -if ms.active(): -# there were conflicts -node = ms.localctx.hex() -else: -# there were no conficts, mergestate was not stored -node = repo['.'].hex() +if abort: +return abortmerge(repo.ui, repo, labels=labels) -repo.ui.status(_("aborting the merge, updating back to" - " %s\n") % node[:12]) -stats = mergemod.update(repo, node, branchmerge=False, force=True, -labels=labels) - +stats = mergemod.update(repo, node, branchmerge=True, force=force, +mergeforce=mergeforce, labels=labels) _showstats(repo, stats) if stats.unresolvedcount: repo.ui.status(_("use 'hg resolve' to retry unresolved file merges " "or 'hg merge --abort' to abandon\n")) -elif remind and not abort: +elif remind: repo.ui.status(_("(branch merge, don't forget to commit)\n")) return stats.unresolvedcount > 0 +def abortmerge(ui, repo, labels=None): +ms = mergemod.mergestate.read(repo) +if ms.active(): +# there were conflicts +node = ms.localctx.hex() +else: +#
D6588: abort: added support for merge
taapas1128 updated this revision to Diff 15880. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D6588?vs=15879=15880 CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D6588/new/ REVISION DETAIL https://phab.mercurial-scm.org/D6588 AFFECTED FILES mercurial/commands.py mercurial/hg.py mercurial/state.py tests/test-commit-unresolved.t tests/test-shelve2.t CHANGE DETAILS diff --git a/tests/test-shelve2.t b/tests/test-shelve2.t --- a/tests/test-shelve2.t +++ b/tests/test-shelve2.t @@ -718,11 +718,16 @@ Unshelve --abort fails with appropriate message if there's no unshelve in progress + +#if abortflag + $ hg unshelve --abort + abort: no unshelve in progress + [255] +#else $ hg abort - abort: no unshelve in progress (abortflag !) - abort: merge in progress but does not support 'hg abort' (no-abortflag !) - (use 'hg commit' or 'hg merge --abort') (no-abortflag !) - [255] + aborting the merge, updating back to 9451eaa6eee3 + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved +#endif $ cd .. Unshelve respects --keep even if user intervention is needed diff --git a/tests/test-commit-unresolved.t b/tests/test-commit-unresolved.t --- a/tests/test-commit-unresolved.t +++ b/tests/test-commit-unresolved.t @@ -1,3 +1,11 @@ +#testcases abortcommand abortflag +#if abortflag + $ cat >> $HGRCPATH < [alias] + > abort = merge --abort + > EOF +#endif + $ addcommit () { > echo $1 > $1 > hg add $1 @@ -36,9 +44,11 @@ Testing the abort functionality first in case of conflicts - $ hg merge --abort - abort: no merge in progress + $ hg abort + abort: no merge in progress (abortflag !) + abort: no operation in progress (abortcommand !) [255] + $ hg merge merging A warning: conflicts while merging A! (edit, then use 'hg resolve --mark') @@ -53,7 +63,13 @@ abort: cannot specify both --rev and --abort [255] - $ hg merge --abort +#if abortcommand +when in dry-run mode + $ hg abort --dry-run + merge in progress, will be aborted +#endif + + $ hg abort aborting the merge, updating back to e45016d2b3d3 1 files updated, 0 files merged, 1 files removed, 0 files unresolved @@ -131,7 +147,7 @@ abort: cannot specify --preview with --abort [255] - $ hg merge --abort + $ hg abort aborting the merge, updating back to 68352a18a7c4 1 files updated, 0 files merged, 1 files removed, 0 files unresolved diff --git a/mercurial/state.py b/mercurial/state.py --- a/mercurial/state.py +++ b/mercurial/state.py @@ -205,13 +205,6 @@ 'To mark the changeset bad: hg bisect --bad\n' 'To abort: hg bisect --reset\n') ) -addunfinished( -'merge', fname=None, clearable=True, allowcommit=True, -cmdmsg=_('outstanding uncommitted merge'), -statushint=_('To continue:hg commit\n' - 'To abort: hg merge --abort'), -cmdhint=_("use 'hg commit' or 'hg merge --abort'") -) def getrepostate(repo): # experimental config: commands.status.skipstates diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -956,31 +956,35 @@ abort=False): """Branch merge with node, resolving changes. Return true if any unresolved conflicts.""" -if not abort: -stats = mergemod.update(repo, node, branchmerge=True, force=force, -mergeforce=mergeforce, labels=labels) -else: -ms = mergemod.mergestate.read(repo) -if ms.active(): -# there were conflicts -node = ms.localctx.hex() -else: -# there were no conficts, mergestate was not stored -node = repo['.'].hex() - -repo.ui.status(_("aborting the merge, updating back to" - " %s\n") % node[:12]) -stats = mergemod.update(repo, node, branchmerge=False, force=True, -labels=labels) - +if abort: +return abortmerge(repo.ui, repo, labels=labels) + +stats = mergemod.update(repo, node, branchmerge=True, force=force, +mergeforce=mergeforce, labels=labels) _showstats(repo, stats) if stats.unresolvedcount: repo.ui.status(_("use 'hg resolve' to retry unresolved file merges " - "or 'hg merge --abort' to abandon\n")) -elif remind and not abort: + "or 'hg merge --abort' todef abortmerge abandon\n")) +elif remind: repo.ui.status(_("(branch merge, don't forget to commit)\n")) return stats.unresolvedcount > 0 +def abortmerge(ui, repo, labels=None): +ms = mergemod.mergestate.read(repo) +if ms.active(): +# there were conflicts +node = ms.localctx.hex() +else: +# there were no conficts, mergestate was not stored +node = repo['.'].hex() + +repo.ui.status(_("aborting the
D6588: abort: added support for merge
This revision is now accepted and ready to land. pulkit added inline comments. pulkit accepted this revision. INLINE COMMENTS > pulkit wrote in hg.py:987 > Here the user is already running `hg merge --abort`, so we should not show > this message. > > Ideally, this `if` condition should not never when aborting a merge. Turns out I am blind and the previous version already had everything correct. I will either apply previous version of fix things in flight. REPOSITORY rHG Mercurial CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D6588/new/ REVISION DETAIL https://phab.mercurial-scm.org/D6588 To: taapas1128, #hg-reviewers, pulkit Cc: pulkit, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D6588: abort: added support for merge
pulkit added inline comments. INLINE COMMENTS > hg.py:987 > +if stats.unresolvedcount: > +repo.ui.status(_("use 'hg resolve' to retry unresolved file merges " > + "or 'hg merge --abort' to abandon\n")) Here the user is already running `hg merge --abort`, so we should not show this message. Ideally, this `if` condition should not never when aborting a merge. REPOSITORY rHG Mercurial CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D6588/new/ REVISION DETAIL https://phab.mercurial-scm.org/D6588 To: taapas1128, #hg-reviewers, pulkit Cc: pulkit, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D6588: abort: added support for merge
taapas1128 updated this revision to Diff 15879. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D6588?vs=15867=15879 CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D6588/new/ REVISION DETAIL https://phab.mercurial-scm.org/D6588 AFFECTED FILES mercurial/commands.py mercurial/hg.py mercurial/state.py tests/test-commit-unresolved.t tests/test-shelve2.t CHANGE DETAILS diff --git a/tests/test-shelve2.t b/tests/test-shelve2.t --- a/tests/test-shelve2.t +++ b/tests/test-shelve2.t @@ -718,11 +718,16 @@ Unshelve --abort fails with appropriate message if there's no unshelve in progress + +#if abortflag + $ hg unshelve --abort + abort: no unshelve in progress + [255] +#else $ hg abort - abort: no unshelve in progress (abortflag !) - abort: merge in progress but does not support 'hg abort' (no-abortflag !) - (use 'hg commit' or 'hg merge --abort') (no-abortflag !) - [255] + aborting the merge, updating back to 9451eaa6eee3 + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved +#endif $ cd .. Unshelve respects --keep even if user intervention is needed diff --git a/tests/test-commit-unresolved.t b/tests/test-commit-unresolved.t --- a/tests/test-commit-unresolved.t +++ b/tests/test-commit-unresolved.t @@ -1,3 +1,11 @@ +#testcases abortcommand abortflag +#if abortflag + $ cat >> $HGRCPATH < [alias] + > abort = merge --abort + > EOF +#endif + $ addcommit () { > echo $1 > $1 > hg add $1 @@ -36,9 +44,11 @@ Testing the abort functionality first in case of conflicts - $ hg merge --abort - abort: no merge in progress + $ hg abort + abort: no merge in progress (abortflag !) + abort: no operation in progress (abortcommand !) [255] + $ hg merge merging A warning: conflicts while merging A! (edit, then use 'hg resolve --mark') @@ -53,7 +63,13 @@ abort: cannot specify both --rev and --abort [255] - $ hg merge --abort +#if abortcommand +when in dry-run mode + $ hg abort --dry-run + merge in progress, will be aborted +#endif + + $ hg abort aborting the merge, updating back to e45016d2b3d3 1 files updated, 0 files merged, 1 files removed, 0 files unresolved @@ -131,7 +147,7 @@ abort: cannot specify --preview with --abort [255] - $ hg merge --abort + $ hg abort aborting the merge, updating back to 68352a18a7c4 1 files updated, 0 files merged, 1 files removed, 0 files unresolved diff --git a/mercurial/state.py b/mercurial/state.py --- a/mercurial/state.py +++ b/mercurial/state.py @@ -205,13 +205,6 @@ 'To mark the changeset bad: hg bisect --bad\n' 'To abort: hg bisect --reset\n') ) -addunfinished( -'merge', fname=None, clearable=True, allowcommit=True, -cmdmsg=_('outstanding uncommitted merge'), -statushint=_('To continue:hg commit\n' - 'To abort: hg merge --abort'), -cmdhint=_("use 'hg commit' or 'hg merge --abort'") -) def getrepostate(repo): # experimental config: commands.status.skipstates diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -956,31 +956,38 @@ abort=False): """Branch merge with node, resolving changes. Return true if any unresolved conflicts.""" -if not abort: -stats = mergemod.update(repo, node, branchmerge=True, force=force, -mergeforce=mergeforce, labels=labels) -else: -ms = mergemod.mergestate.read(repo) -if ms.active(): -# there were conflicts -node = ms.localctx.hex() -else: -# there were no conficts, mergestate was not stored -node = repo['.'].hex() - -repo.ui.status(_("aborting the merge, updating back to" - " %s\n") % node[:12]) -stats = mergemod.update(repo, node, branchmerge=False, force=True, -labels=labels) - +if abort: +return abortmerge(repo.ui, repo, labels=labels) + +stats = mergemod.update(repo, node, branchmerge=True, force=force, +mergeforce=mergeforce, labels=labels) _showstats(repo, stats) if stats.unresolvedcount: repo.ui.status(_("use 'hg resolve' to retry unresolved file merges " "or 'hg merge --abort' to abandon\n")) -elif remind and not abort: +elif remind: repo.ui.status(_("(branch merge, don't forget to commit)\n")) return stats.unresolvedcount > 0 +def abortmerge(ui, repo, labels=None): +ms = mergemod.mergestate.read(repo) +if ms.active(): +# there were conflicts +node = ms.localctx.hex() +else: +# there were no conficts, mergestate was not stored +node = repo['.'].hex() + +repo.ui.status(_("aborting the merge, updating back to" + " %s\n") % node[:12]) +stats =
D6588: abort: added support for merge
This revision now requires changes to proceed. pulkit added inline comments. pulkit requested changes to this revision. INLINE COMMENTS > pulkit wrote in hg.py:985 > We lost `return stats.unresolvedcount > 0` in this code movement. This is not yet addressed. REPOSITORY rHG Mercurial CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D6588/new/ REVISION DETAIL https://phab.mercurial-scm.org/D6588 To: taapas1128, #hg-reviewers, pulkit Cc: pulkit, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D6588: abort: added support for merge
taapas1128 updated this revision to Diff 15867. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D6588?vs=15864=15867 CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D6588/new/ REVISION DETAIL https://phab.mercurial-scm.org/D6588 AFFECTED FILES mercurial/commands.py mercurial/hg.py mercurial/state.py tests/test-commit-unresolved.t tests/test-shelve2.t CHANGE DETAILS diff --git a/tests/test-shelve2.t b/tests/test-shelve2.t --- a/tests/test-shelve2.t +++ b/tests/test-shelve2.t @@ -718,11 +718,16 @@ Unshelve --abort fails with appropriate message if there's no unshelve in progress + +#if abortflag + $ hg unshelve --abort + abort: no unshelve in progress + [255] +#else $ hg abort - abort: no unshelve in progress (abortflag !) - abort: merge in progress but does not support 'hg abort' (no-abortflag !) - (use 'hg commit' or 'hg merge --abort') (no-abortflag !) - [255] + aborting the merge, updating back to 9451eaa6eee3 + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved +#endif $ cd .. Unshelve respects --keep even if user intervention is needed diff --git a/tests/test-commit-unresolved.t b/tests/test-commit-unresolved.t --- a/tests/test-commit-unresolved.t +++ b/tests/test-commit-unresolved.t @@ -1,3 +1,11 @@ +#testcases abortcommand abortflag +#if abortflag + $ cat >> $HGRCPATH < [alias] + > abort = merge --abort + > EOF +#endif + $ addcommit () { > echo $1 > $1 > hg add $1 @@ -36,9 +44,11 @@ Testing the abort functionality first in case of conflicts - $ hg merge --abort - abort: no merge in progress + $ hg abort + abort: no merge in progress (abortflag !) + abort: no operation in progress (abortcommand !) [255] + $ hg merge merging A warning: conflicts while merging A! (edit, then use 'hg resolve --mark') @@ -53,7 +63,13 @@ abort: cannot specify both --rev and --abort [255] - $ hg merge --abort +#if abortcommand +when in dry-run mode + $ hg abort --dry-run + merge in progress, will be aborted +#endif + + $ hg abort aborting the merge, updating back to e45016d2b3d3 1 files updated, 0 files merged, 1 files removed, 0 files unresolved @@ -131,7 +147,7 @@ abort: cannot specify --preview with --abort [255] - $ hg merge --abort + $ hg abort aborting the merge, updating back to 68352a18a7c4 1 files updated, 0 files merged, 1 files removed, 0 files unresolved diff --git a/mercurial/state.py b/mercurial/state.py --- a/mercurial/state.py +++ b/mercurial/state.py @@ -205,13 +205,6 @@ 'To mark the changeset bad: hg bisect --bad\n' 'To abort: hg bisect --reset\n') ) -addunfinished( -'merge', fname=None, clearable=True, allowcommit=True, -cmdmsg=_('outstanding uncommitted merge'), -statushint=_('To continue:hg commit\n' - 'To abort: hg merge --abort'), -cmdhint=_("use 'hg commit' or 'hg merge --abort'") -) def getrepostate(repo): # experimental config: commands.status.skipstates diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -956,23 +956,11 @@ abort=False): """Branch merge with node, resolving changes. Return true if any unresolved conflicts.""" -if not abort: -stats = mergemod.update(repo, node, branchmerge=True, force=force, -mergeforce=mergeforce, labels=labels) -else: -ms = mergemod.mergestate.read(repo) -if ms.active(): -# there were conflicts -node = ms.localctx.hex() -else: -# there were no conficts, mergestate was not stored -node = repo['.'].hex() - -repo.ui.status(_("aborting the merge, updating back to" - " %s\n") % node[:12]) -stats = mergemod.update(repo, node, branchmerge=False, force=True, -labels=labels) - +if abort: +return abortmerge(repo.ui, repo, labels=labels) + +stats = mergemod.update(repo, node, branchmerge=True, force=force, +mergeforce=mergeforce, labels=labels) _showstats(repo, stats) if stats.unresolvedcount: repo.ui.status(_("use 'hg resolve' to retry unresolved file merges " @@ -981,6 +969,22 @@ repo.ui.status(_("(branch merge, don't forget to commit)\n")) return stats.unresolvedcount > 0 +def abortmerge(ui, repo, labels=None): +ms = mergemod.mergestate.read(repo) +if ms.active(): +# there were conflicts +node = ms.localctx.hex() +else: +# there were no conficts, mergestate was not stored +node = repo['.'].hex() + +repo.ui.status(_("aborting the merge, updating back to" + " %s\n") % node[:12]) +stats = mergemod.update(repo, node, branchmerge=False, force=True, +
D6588: abort: added support for merge
taapas1128 updated this revision to Diff 15864. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D6588?vs=15858=15864 CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D6588/new/ REVISION DETAIL https://phab.mercurial-scm.org/D6588 AFFECTED FILES mercurial/commands.py mercurial/hg.py mercurial/state.py tests/test-commit-unresolved.t tests/test-shelve2.t CHANGE DETAILS diff --git a/tests/test-shelve2.t b/tests/test-shelve2.t --- a/tests/test-shelve2.t +++ b/tests/test-shelve2.t @@ -718,11 +718,16 @@ Unshelve --abort fails with appropriate message if there's no unshelve in progress + +#if abortflag + $ hg unshelve --abort + abort: no unshelve in progress + [255] +#else $ hg abort - abort: no unshelve in progress (abortflag !) - abort: merge in progress but does not support 'hg abort' (no-abortflag !) - (use 'hg commit' or 'hg merge --abort') (no-abortflag !) - [255] + aborting the merge, updating back to 9451eaa6eee3 + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved +#endif $ cd .. Unshelve respects --keep even if user intervention is needed diff --git a/tests/test-commit-unresolved.t b/tests/test-commit-unresolved.t --- a/tests/test-commit-unresolved.t +++ b/tests/test-commit-unresolved.t @@ -1,3 +1,11 @@ +#testcases abortcommand abortflag +#if abortflag + $ cat >> $HGRCPATH < [alias] + > abort = merge --abort + > EOF +#endif + $ addcommit () { > echo $1 > $1 > hg add $1 @@ -36,9 +44,11 @@ Testing the abort functionality first in case of conflicts - $ hg merge --abort - abort: no merge in progress + $ hg abort + abort: no merge in progress (abortflag !) + abort: no operation in progress (abortcommand !) [255] + $ hg merge merging A warning: conflicts while merging A! (edit, then use 'hg resolve --mark') @@ -53,7 +63,13 @@ abort: cannot specify both --rev and --abort [255] - $ hg merge --abort +#if abortcommand +when in dry-run mode + $ hg abort --dry-run + merge in progress, will be aborted +#endif + + $ hg abort aborting the merge, updating back to e45016d2b3d3 1 files updated, 0 files merged, 1 files removed, 0 files unresolved @@ -131,7 +147,7 @@ abort: cannot specify --preview with --abort [255] - $ hg merge --abort + $ hg abort aborting the merge, updating back to 68352a18a7c4 1 files updated, 0 files merged, 1 files removed, 0 files unresolved diff --git a/mercurial/state.py b/mercurial/state.py --- a/mercurial/state.py +++ b/mercurial/state.py @@ -205,13 +205,6 @@ 'To mark the changeset bad: hg bisect --bad\n' 'To abort: hg bisect --reset\n') ) -addunfinished( -'merge', fname=None, clearable=True, allowcommit=True, -cmdmsg=_('outstanding uncommitted merge'), -statushint=_('To continue:hg commit\n' - 'To abort: hg merge --abort'), -cmdhint=_("use 'hg commit' or 'hg merge --abort'") -) def getrepostate(repo): # experimental config: commands.status.skipstates diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -956,23 +956,11 @@ abort=False): """Branch merge with node, resolving changes. Return true if any unresolved conflicts.""" -if not abort: -stats = mergemod.update(repo, node, branchmerge=True, force=force, -mergeforce=mergeforce, labels=labels) -else: -ms = mergemod.mergestate.read(repo) -if ms.active(): -# there were conflicts -node = ms.localctx.hex() -else: -# there were no conficts, mergestate was not stored -node = repo['.'].hex() - -repo.ui.status(_("aborting the merge, updating back to" - " %s\n") % node[:12]) -stats = mergemod.update(repo, node, branchmerge=False, force=True, -labels=labels) - +if abort: +return abortmerge(repo.ui, repo, labels=labels) + +stats = mergemod.update(repo, node, branchmerge=True, force=force, +mergeforce=mergeforce, labels=labels) _showstats(repo, stats) if stats.unresolvedcount: repo.ui.status(_("use 'hg resolve' to retry unresolved file merges " @@ -981,6 +969,22 @@ repo.ui.status(_("(branch merge, don't forget to commit)\n")) return stats.unresolvedcount > 0 +def abortmerge(ui, repo, labels=None): +ms = mergemod.mergestate.read(repo) +if ms.active(): +# there were conflicts +node = ms.localctx.hex() +else: +# there were no conficts, mergestate was not stored +node = repo['.'].hex() + +repo.ui.status(_("aborting the merge, updating back to" + " %s\n") % node[:12]) +stats = mergemod.update(repo, node, branchmerge=False, force=True, +
D6588: abort: added support for merge
taapas1128 updated this revision to Diff 15858. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D6588?vs=15835=15858 CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D6588/new/ REVISION DETAIL https://phab.mercurial-scm.org/D6588 AFFECTED FILES mercurial/commands.py mercurial/hg.py mercurial/state.py tests/test-commit-unresolved.t tests/test-shelve2.t CHANGE DETAILS diff --git a/tests/test-shelve2.t b/tests/test-shelve2.t --- a/tests/test-shelve2.t +++ b/tests/test-shelve2.t @@ -718,11 +718,16 @@ Unshelve --abort fails with appropriate message if there's no unshelve in progress + +#if abortflag + $ hg unshelve --abort + abort: no unshelve in progress + [255] +#else $ hg abort - abort: no unshelve in progress (abortflag !) - abort: merge in progress but does not support 'hg abort' (no-abortflag !) - (use 'hg commit' or 'hg merge --abort') (no-abortflag !) - [255] + aborting the merge, updating back to 9451eaa6eee3 + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved +#endif $ cd .. Unshelve respects --keep even if user intervention is needed diff --git a/tests/test-commit-unresolved.t b/tests/test-commit-unresolved.t --- a/tests/test-commit-unresolved.t +++ b/tests/test-commit-unresolved.t @@ -1,3 +1,11 @@ +#testcases abortcommand abortflag +#if abortflag + $ cat >> $HGRCPATH < [alias] + > abort = merge --abort + > EOF +#endif + $ addcommit () { > echo $1 > $1 > hg add $1 @@ -36,9 +44,11 @@ Testing the abort functionality first in case of conflicts - $ hg merge --abort - abort: no merge in progress + $ hg abort + abort: no merge in progress (abortflag !) + abort: no operation in progress (abortcommand !) [255] + $ hg merge merging A warning: conflicts while merging A! (edit, then use 'hg resolve --mark') @@ -53,7 +63,13 @@ abort: cannot specify both --rev and --abort [255] - $ hg merge --abort +#if abortcommand +when in dry-run mode + $ hg abort --dry-run + merge in progress, will be aborted +#endif + + $ hg abort aborting the merge, updating back to e45016d2b3d3 1 files updated, 0 files merged, 1 files removed, 0 files unresolved @@ -131,7 +147,7 @@ abort: cannot specify --preview with --abort [255] - $ hg merge --abort + $ hg abort aborting the merge, updating back to 68352a18a7c4 1 files updated, 0 files merged, 1 files removed, 0 files unresolved diff --git a/mercurial/state.py b/mercurial/state.py --- a/mercurial/state.py +++ b/mercurial/state.py @@ -205,13 +205,6 @@ 'To mark the changeset bad: hg bisect --bad\n' 'To abort: hg bisect --reset\n') ) -addunfinished( -'merge', fname=None, clearable=True, allowcommit=True, -cmdmsg=_('outstanding uncommitted merge'), -statushint=_('To continue:hg commit\n' - 'To abort: hg merge --abort'), -cmdhint=_("use 'hg commit' or 'hg merge --abort'") -) def getrepostate(repo): # experimental config: commands.status.skipstates diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -956,23 +956,11 @@ abort=False): """Branch merge with node, resolving changes. Return true if any unresolved conflicts.""" -if not abort: -stats = mergemod.update(repo, node, branchmerge=True, force=force, -mergeforce=mergeforce, labels=labels) -else: -ms = mergemod.mergestate.read(repo) -if ms.active(): -# there were conflicts -node = ms.localctx.hex() -else: -# there were no conficts, mergestate was not stored -node = repo['.'].hex() - -repo.ui.status(_("aborting the merge, updating back to" - " %s\n") % node[:12]) -stats = mergemod.update(repo, node, branchmerge=False, force=True, -labels=labels) - +if abort: +return abortmerge(repo.ui, repo, labels=labels) + +stats = mergemod.update(repo, node, branchmerge=True, force=force, +mergeforce=mergeforce, labels=labels) _showstats(repo, stats) if stats.unresolvedcount: repo.ui.status(_("use 'hg resolve' to retry unresolved file merges " @@ -981,6 +969,22 @@ repo.ui.status(_("(branch merge, don't forget to commit)\n")) return stats.unresolvedcount > 0 +def abortmerge(ui, repo, labels=None): +ms = mergemod.mergestate.read(repo) +if ms.active(): +# there were conflicts +node = ms.localctx.hex() +else: +# there were no conficts, mergestate was not stored +node = repo['.'].hex() + +repo.ui.status(_("aborting the merge, updating back to" + " %s\n") % node[:12]) +stats = mergemod.update(repo, node, branchmerge=False, force=True, +
D6588: abort: added support for merge
pulkit added inline comments. INLINE COMMENTS > hg.py:985 > +labels=labels) > +_showstats(repo, stats) > + We lost `return stats.unresolvedcount > 0` in this code movement. REPOSITORY rHG Mercurial CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D6588/new/ REVISION DETAIL https://phab.mercurial-scm.org/D6588 To: taapas1128, #hg-reviewers, pulkit Cc: pulkit, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D6588: abort: added support for merge
taapas1128 edited the summary of this revision. taapas1128 updated this revision to Diff 15835. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D6588?vs=15808=15835 CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D6588/new/ REVISION DETAIL https://phab.mercurial-scm.org/D6588 AFFECTED FILES mercurial/commands.py mercurial/hg.py mercurial/state.py tests/test-commit-unresolved.t tests/test-shelve2.t CHANGE DETAILS diff --git a/tests/test-shelve2.t b/tests/test-shelve2.t --- a/tests/test-shelve2.t +++ b/tests/test-shelve2.t @@ -716,11 +716,16 @@ Unshelve --abort fails with appropriate message if there's no unshelve in progress + +#if abortflag + $ hg unshelve --abort + abort: no unshelve in progress + [255] +#else $ hg abort - abort: no unshelve in progress (abortflag !) - abort: merge in progress but does not support 'hg abort' (no-abortflag !) - (use 'hg commit' or 'hg merge --abort') (no-abortflag !) - [255] + aborting the merge, updating back to 9451eaa6eee3 + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved +#endif $ cd .. Unshelve respects --keep even if user intervention is needed diff --git a/tests/test-commit-unresolved.t b/tests/test-commit-unresolved.t --- a/tests/test-commit-unresolved.t +++ b/tests/test-commit-unresolved.t @@ -1,3 +1,11 @@ +#testcases abortcommand abortflag +#if abortflag + $ cat >> $HGRCPATH < [alias] + > abort = merge --abort + > EOF +#endif + $ addcommit () { > echo $1 > $1 > hg add $1 @@ -36,9 +44,11 @@ Testing the abort functionality first in case of conflicts - $ hg merge --abort - abort: no merge in progress + $ hg abort + abort: no merge in progress (abortflag !) + abort: no operation in progress (abortcommand !) [255] + $ hg merge merging A warning: conflicts while merging A! (edit, then use 'hg resolve --mark') @@ -53,7 +63,13 @@ abort: cannot specify both --rev and --abort [255] - $ hg merge --abort +#if abortcommand +when in dry-run mode + $ hg abort --dry-run + merge in progress, will be aborted +#endif + + $ hg abort aborting the merge, updating back to e45016d2b3d3 1 files updated, 0 files merged, 1 files removed, 0 files unresolved @@ -131,7 +147,7 @@ abort: cannot specify --preview with --abort [255] - $ hg merge --abort + $ hg abort aborting the merge, updating back to 68352a18a7c4 1 files updated, 0 files merged, 1 files removed, 0 files unresolved diff --git a/mercurial/state.py b/mercurial/state.py --- a/mercurial/state.py +++ b/mercurial/state.py @@ -205,13 +205,6 @@ 'To mark the changeset bad: hg bisect --bad\n' 'To abort: hg bisect --reset\n') ) -addunfinished( -'merge', fname=None, clearable=True, allowcommit=True, -cmdmsg=_('outstanding uncommitted merge'), -statushint=_('To continue:hg commit\n' - 'To abort: hg merge --abort'), -cmdhint=_("use 'hg commit' or 'hg merge --abort'") -) def getrepostate(repo): # experimental config: commands.status.skipstates diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -956,23 +956,11 @@ abort=False): """Branch merge with node, resolving changes. Return true if any unresolved conflicts.""" -if not abort: -stats = mergemod.update(repo, node, branchmerge=True, force=force, -mergeforce=mergeforce, labels=labels) -else: -ms = mergemod.mergestate.read(repo) -if ms.active(): -# there were conflicts -node = ms.localctx.hex() -else: -# there were no conficts, mergestate was not stored -node = repo['.'].hex() - -repo.ui.status(_("aborting the merge, updating back to" - " %s\n") % node[:12]) -stats = mergemod.update(repo, node, branchmerge=False, force=True, -labels=labels) - +if abort: +return abortmerge(repo.ui, repo, labels=labels) + +stats = mergemod.update(repo, node, branchmerge=True, force=force, +mergeforce=mergeforce, labels=labels) _showstats(repo, stats) if stats.unresolvedcount: repo.ui.status(_("use 'hg resolve' to retry unresolved file merges " @@ -981,6 +969,21 @@ repo.ui.status(_("(branch merge, don't forget to commit)\n")) return stats.unresolvedcount > 0 +def abortmerge(ui, repo, labels=None): +ms = mergemod.mergestate.read(repo) +if ms.active(): +# there were conflicts +node = ms.localctx.hex() +else: +# there were no conficts, mergestate was not stored +node = repo['.'].hex() + +repo.ui.status(_("aborting the merge, updating back to" + " %s\n") % node[:12]) +stats = mergemod.update(repo, node, branchmerge=False,
D6588: abort: added support for merge
taapas1128 edited the summary of this revision. taapas1128 updated this revision to Diff 15808. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D6588?vs=15783=15808 CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D6588/new/ REVISION DETAIL https://phab.mercurial-scm.org/D6588 AFFECTED FILES mercurial/commands.py mercurial/hg.py mercurial/state.py tests/test-commit-unresolved.t tests/test-shelve2.t CHANGE DETAILS diff --git a/tests/test-shelve2.t b/tests/test-shelve2.t --- a/tests/test-shelve2.t +++ b/tests/test-shelve2.t @@ -716,11 +716,16 @@ Unshelve --abort fails with appropriate message if there's no unshelve in progress + +#if abortflag + $ hg unshelve --abort + abort: no unshelve in progress + [255] +#else $ hg abort - abort: no unshelve in progress (abortflag !) - abort: merge does not support 'hg abort' (no-abortflag !) - (use 'hg commit' or 'hg merge --abort') (no-abortflag !) - [255] + aborting the merge, updating back to 9451eaa6eee3 + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved +#endif $ cd .. Unshelve respects --keep even if user intervention is needed diff --git a/tests/test-commit-unresolved.t b/tests/test-commit-unresolved.t --- a/tests/test-commit-unresolved.t +++ b/tests/test-commit-unresolved.t @@ -1,3 +1,11 @@ +#testcases abortcommand abortflag +#if abortflag + $ cat >> $HGRCPATH < [alias] + > abort = merge --abort + > EOF +#endif + $ addcommit () { > echo $1 > $1 > hg add $1 @@ -36,9 +44,11 @@ Testing the abort functionality first in case of conflicts - $ hg merge --abort - abort: no merge in progress + $ hg abort + abort: no merge in progress (abortflag !) + abort: no operation in progress (abortcommand !) [255] + $ hg merge merging A warning: conflicts while merging A! (edit, then use 'hg resolve --mark') @@ -53,7 +63,13 @@ abort: cannot specify both --rev and --abort [255] - $ hg merge --abort +#if abortcommand +when in dry-run mode + $ hg abort --dry-run + merge in progress, will be aborted +#endif + + $ hg abort aborting the merge, updating back to e45016d2b3d3 1 files updated, 0 files merged, 1 files removed, 0 files unresolved @@ -131,7 +147,7 @@ abort: cannot specify --preview with --abort [255] - $ hg merge --abort + $ hg abort aborting the merge, updating back to 68352a18a7c4 1 files updated, 0 files merged, 1 files removed, 0 files unresolved diff --git a/mercurial/state.py b/mercurial/state.py --- a/mercurial/state.py +++ b/mercurial/state.py @@ -205,13 +205,6 @@ 'To mark the changeset bad: hg bisect --bad\n' 'To abort: hg bisect --reset\n') ) -addunfinished( -'merge', fname=None, clearable=True, allowcommit=True, -cmdmsg=_('outstanding uncommitted merge'), -statushint=_('To continue:hg commit\n' - 'To abort: hg merge --abort'), -cmdhint=_("use 'hg commit' or 'hg merge --abort'") -) def getrepostate(repo): # experimental config: commands.status.skipstates diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -956,23 +956,11 @@ abort=False): """Branch merge with node, resolving changes. Return true if any unresolved conflicts.""" -if not abort: -stats = mergemod.update(repo, node, branchmerge=True, force=force, -mergeforce=mergeforce, labels=labels) -else: -ms = mergemod.mergestate.read(repo) -if ms.active(): -# there were conflicts -node = ms.localctx.hex() -else: -# there were no conficts, mergestate was not stored -node = repo['.'].hex() - -repo.ui.status(_("aborting the merge, updating back to" - " %s\n") % node[:12]) -stats = mergemod.update(repo, node, branchmerge=False, force=True, -labels=labels) - +if abort: +return abortmerge(repo.ui, repo, labels=labels) + +stats = mergemod.update(repo, node, branchmerge=True, force=force, +mergeforce=mergeforce, labels=labels) _showstats(repo, stats) if stats.unresolvedcount: repo.ui.status(_("use 'hg resolve' to retry unresolved file merges " @@ -981,6 +969,21 @@ repo.ui.status(_("(branch merge, don't forget to commit)\n")) return stats.unresolvedcount > 0 +def abortmerge(ui, repo, labels=None, **opts): +ms = mergemod.mergestate.read(repo) +if ms.active(): +# there were conflicts +node = ms.localctx.hex() +else: +# there were no conficts, mergestate was not stored +node = repo['.'].hex() + +repo.ui.status(_("aborting the merge, updating back to" + " %s\n") % node[:12]) +stats = mergemod.update(repo, node, branchmerge=False,
D6588: abort: added support for merge
taapas1128 updated this revision to Diff 15783. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D6588?vs=15770=15783 CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D6588/new/ REVISION DETAIL https://phab.mercurial-scm.org/D6588 AFFECTED FILES mercurial/commands.py mercurial/hg.py mercurial/state.py tests/test-commit-unresolved.t tests/test-shelve2.t CHANGE DETAILS diff --git a/tests/test-shelve2.t b/tests/test-shelve2.t --- a/tests/test-shelve2.t +++ b/tests/test-shelve2.t @@ -724,15 +724,20 @@ Unshelve --abort fails with appropriate message if there's no unshelve in progress + +#if abortflag + $ hg unshelve --abort + abort: no unshelve in progress + [255] +#else $ hg abort - abort: no unshelve in progress (abortflag !) - abort: merge does not support 'hg abort' (abortcommand !) - (use 'hg commit' or 'hg merge --abort') (abortcommand !) - abort: merge does not support 'hg abort' (phasebased !) - (use 'hg commit' or 'hg merge --abort') (phasebased !) - abort: merge does not support 'hg abort' (stripbased !) - (use 'hg commit' or 'hg merge --abort') (stripbased !) - [255] + aborting the merge, updating back to 9451eaa6eee3 (abortcommand !) + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved (abortcommand !) + aborting the merge, updating back to 9451eaa6eee3 (phasebased !) + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved (phasebased !) + aborting the merge, updating back to 9451eaa6eee3 (stripbased !) + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved (stripbased !) +#endif $ cd .. Unshelve respects --keep even if user intervention is needed diff --git a/tests/test-commit-unresolved.t b/tests/test-commit-unresolved.t --- a/tests/test-commit-unresolved.t +++ b/tests/test-commit-unresolved.t @@ -1,3 +1,11 @@ +#testcases abortcommand abortflag +#if abortflag + $ cat >> $HGRCPATH < [alias] + > abort = merge --abort + > EOF +#endif + $ addcommit () { > echo $1 > $1 > hg add $1 @@ -36,9 +44,11 @@ Testing the abort functionality first in case of conflicts - $ hg merge --abort - abort: no merge in progress + $ hg abort + abort: no merge in progress (abortflag !) + abort: no operation in progress (abortcommand !) [255] + $ hg merge merging A warning: conflicts while merging A! (edit, then use 'hg resolve --mark') @@ -53,7 +63,22 @@ abort: cannot specify both --rev and --abort [255] - $ hg merge --abort +#if abortcommand +when in dry-run mode + $ hg abort --dry-run + merge in progress, will be aborted + +when in no-backup mode + $ hg abort --no-backup + abort: aborting merge does not support no-backup flag + [255] + +when dry-run mode is used with no backup + $ hg abort --dry-run --no-backup + merge in progress, will be aborted +#endif + + $ hg abort aborting the merge, updating back to e45016d2b3d3 1 files updated, 0 files merged, 1 files removed, 0 files unresolved @@ -131,7 +156,7 @@ abort: cannot specify --preview with --abort [255] - $ hg merge --abort + $ hg abort aborting the merge, updating back to 68352a18a7c4 1 files updated, 0 files merged, 1 files removed, 0 files unresolved diff --git a/mercurial/state.py b/mercurial/state.py --- a/mercurial/state.py +++ b/mercurial/state.py @@ -205,13 +205,6 @@ 'To mark the changeset bad: hg bisect --bad\n' 'To abort: hg bisect --reset\n') ) -addunfinished( -'merge', fname=None, clearable=True, allowcommit=True, -cmdmsg=_('outstanding uncommitted merge'), -statushint=_('To continue:hg commit\n' - 'To abort: hg merge --abort'), -cmdhint=_("use 'hg commit' or 'hg merge --abort'") -) def getrepostate(repo): # experimental config: commands.status.skipstates diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -956,23 +956,11 @@ abort=False): """Branch merge with node, resolving changes. Return true if any unresolved conflicts.""" -if not abort: -stats = mergemod.update(repo, node, branchmerge=True, force=force, -mergeforce=mergeforce, labels=labels) -else: -ms = mergemod.mergestate.read(repo) -if ms.active(): -# there were conflicts -node = ms.localctx.hex() -else: -# there were no conficts, mergestate was not stored -node = repo['.'].hex() - -repo.ui.status(_("aborting the merge, updating back to" - " %s\n") % node[:12]) -stats = mergemod.update(repo, node, branchmerge=False, force=True, -labels=labels) - +if abort: +return abortmerge(repo.ui, repo, labels=labels) + +stats = mergemod.update(repo, node, branchmerge=True, force=force, +
D6588: abort: added support for merge
taapas1128 updated this revision to Diff 15770. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D6588?vs=15761=15770 CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D6588/new/ REVISION DETAIL https://phab.mercurial-scm.org/D6588 AFFECTED FILES mercurial/commands.py mercurial/hg.py mercurial/state.py tests/test-commit-unresolved.t tests/test-shelve2.t CHANGE DETAILS diff --git a/tests/test-shelve2.t b/tests/test-shelve2.t --- a/tests/test-shelve2.t +++ b/tests/test-shelve2.t @@ -726,15 +726,20 @@ Unshelve --abort fails with appropriate message if there's no unshelve in progress + +#if abortflag + $ hg unshelve --abort + abort: no unshelve in progress + [255] +#else $ hg abort - abort: no unshelve in progress (abortflag !) - abort: merge does not support 'hg abort' (abortcommand !) - (use 'hg commit' or 'hg merge --abort') (abortcommand !) - abort: merge does not support 'hg abort' (phasebased !) - (use 'hg commit' or 'hg merge --abort') (phasebased !) - abort: merge does not support 'hg abort' (stripbased !) - (use 'hg commit' or 'hg merge --abort') (stripbased !) - [255] + aborting the merge, updating back to 9451eaa6eee3 (abortcommand !) + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved (abortcommand !) + aborting the merge, updating back to 9451eaa6eee3 (phasebased !) + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved (phasebased !) + aborting the merge, updating back to 9451eaa6eee3 (stripbased !) + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved (stripbased !) +#endif $ cd .. Unshelve respects --keep even if user intervention is needed diff --git a/tests/test-commit-unresolved.t b/tests/test-commit-unresolved.t --- a/tests/test-commit-unresolved.t +++ b/tests/test-commit-unresolved.t @@ -1,3 +1,11 @@ +#testcases abortcommand abortflag +#if abortflag + $ cat >> $HGRCPATH < [alias] + > abort = merge --abort + > EOF +#endif + $ addcommit () { > echo $1 > $1 > hg add $1 @@ -36,9 +44,11 @@ Testing the abort functionality first in case of conflicts - $ hg merge --abort - abort: no merge in progress + $ hg abort + abort: no merge in progress (abortflag !) + abort: no operation in progress (abortcommand !) [255] + $ hg merge merging A warning: conflicts while merging A! (edit, then use 'hg resolve --mark') @@ -53,7 +63,24 @@ abort: cannot specify both --rev and --abort [255] - $ hg merge --abort +#if abortcommand +when in dry-run mode + $ hg abort --dry-run + aborting merge + +when in no-backup mode + $ hg abort --no-backup + abort: merge does not support no-backup flag + [255] + +when dry-run mode is used with no backup + $ hg abort --dry-run --no-backup + aborting merge + abort: merge does not support no-backup flag + [255] +#endif + + $ hg abort aborting the merge, updating back to e45016d2b3d3 1 files updated, 0 files merged, 1 files removed, 0 files unresolved @@ -131,7 +158,7 @@ abort: cannot specify --preview with --abort [255] - $ hg merge --abort + $ hg abort aborting the merge, updating back to 68352a18a7c4 1 files updated, 0 files merged, 1 files removed, 0 files unresolved diff --git a/mercurial/state.py b/mercurial/state.py --- a/mercurial/state.py +++ b/mercurial/state.py @@ -205,13 +205,6 @@ 'To mark the changeset bad: hg bisect --bad\n' 'To abort: hg bisect --reset\n') ) -addunfinished( -'merge', fname=None, clearable=True, allowcommit=True, -cmdmsg=_('outstanding uncommitted merge'), -statushint=_('To continue:hg commit\n' - 'To abort: hg merge --abort'), -cmdhint=_("use 'hg commit' or 'hg merge --abort'") -) def getrepostate(repo): # experimental config: commands.status.skipstates diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -956,23 +956,11 @@ abort=False): """Branch merge with node, resolving changes. Return true if any unresolved conflicts.""" -if not abort: -stats = mergemod.update(repo, node, branchmerge=True, force=force, -mergeforce=mergeforce, labels=labels) -else: -ms = mergemod.mergestate.read(repo) -if ms.active(): -# there were conflicts -node = ms.localctx.hex() -else: -# there were no conficts, mergestate was not stored -node = repo['.'].hex() - -repo.ui.status(_("aborting the merge, updating back to" - " %s\n") % node[:12]) -stats = mergemod.update(repo, node, branchmerge=False, force=True, -labels=labels) - +if abort: +return abortmerge(repo.ui, repo, labels=labels) + +stats = mergemod.update(repo, node, branchmerge=True, force=force, +
D6588: abort: added support for merge
pulkit added inline comments. INLINE COMMENTS > test-commit-unresolved.t:48 > +#if abortflag >$ hg merge --abort >abort: no merge in progress `hg abort` can be used. we can case the output here. REPOSITORY rHG Mercurial CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D6588/new/ REVISION DETAIL https://phab.mercurial-scm.org/D6588 To: taapas1128, #hg-reviewers Cc: pulkit, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D6588: abort: added support for merge
taapas1128 updated this revision to Diff 15761. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D6588?vs=15760=15761 CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D6588/new/ REVISION DETAIL https://phab.mercurial-scm.org/D6588 AFFECTED FILES mercurial/commands.py mercurial/hg.py mercurial/state.py tests/test-commit-unresolved.t CHANGE DETAILS diff --git a/tests/test-commit-unresolved.t b/tests/test-commit-unresolved.t --- a/tests/test-commit-unresolved.t +++ b/tests/test-commit-unresolved.t @@ -1,3 +1,11 @@ +#testcases hgabort abortflag +#if abortflag + $ cat >> $HGRCPATH < [alias] + > abort = merge --abort + > EOF +#endif + $ addcommit () { > echo $1 > $1 > hg add $1 @@ -36,9 +44,16 @@ Testing the abort functionality first in case of conflicts +#if abortflag $ hg merge --abort abort: no merge in progress [255] +#else + $ hg abort + abort: no operation in progress + [255] +#endif + $ hg merge merging A warning: conflicts while merging A! (edit, then use 'hg resolve --mark') @@ -53,7 +68,24 @@ abort: cannot specify both --rev and --abort [255] - $ hg merge --abort +#if hgabort +when in dry-run mode + $ hg abort --dry-run + aborting merge + +when in no-backup mode + $ hg abort --no-backup + abort: merge does not support no-backup flag + [255] + +when dry-run mode is used with no backup + $ hg abort --dry-run --no-backup + aborting merge + abort: merge does not support no-backup flag + [255] +#endif + + $ hg abort aborting the merge, updating back to e45016d2b3d3 1 files updated, 0 files merged, 1 files removed, 0 files unresolved @@ -131,7 +163,7 @@ abort: cannot specify --preview with --abort [255] - $ hg merge --abort + $ hg abort aborting the merge, updating back to 68352a18a7c4 1 files updated, 0 files merged, 1 files removed, 0 files unresolved diff --git a/mercurial/state.py b/mercurial/state.py --- a/mercurial/state.py +++ b/mercurial/state.py @@ -205,13 +205,6 @@ 'To mark the changeset bad: hg bisect --bad\n' 'To abort: hg bisect --reset\n') ) -addunfinished( -'merge', fname=None, clearable=True, allowcommit=True, -cmdmsg=_('outstanding uncommitted merge'), -statushint=_('To continue:hg commit\n' - 'To abort: hg merge --abort'), -cmdhint=_("use 'hg commit' or 'hg merge --abort'") -) def getrepostate(repo): # experimental config: commands.status.skipstates diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -956,23 +956,11 @@ abort=False): """Branch merge with node, resolving changes. Return true if any unresolved conflicts.""" -if not abort: -stats = mergemod.update(repo, node, branchmerge=True, force=force, -mergeforce=mergeforce, labels=labels) -else: -ms = mergemod.mergestate.read(repo) -if ms.active(): -# there were conflicts -node = ms.localctx.hex() -else: -# there were no conficts, mergestate was not stored -node = repo['.'].hex() - -repo.ui.status(_("aborting the merge, updating back to" - " %s\n") % node[:12]) -stats = mergemod.update(repo, node, branchmerge=False, force=True, -labels=labels) - +if abort: +return abortmerge(repo.ui, repo, labels=labels) + +stats = mergemod.update(repo, node, branchmerge=True, force=force, +mergeforce=mergeforce, labels=labels) _showstats(repo, stats) if stats.unresolvedcount: repo.ui.status(_("use 'hg resolve' to retry unresolved file merges " @@ -981,6 +969,25 @@ repo.ui.status(_("(branch merge, don't forget to commit)\n")) return stats.unresolvedcount > 0 +def abortmerge(ui, repo, labels=None, **opts): +if opts.get('no_backup'): +raise error.Abort(_("merge does not support no-backup flag")) +if opts.get('dry_run'): +return 0 +ms = mergemod.mergestate.read(repo) +if ms.active(): +# there were conflicts +node = ms.localctx.hex() +else: +# there were no conficts, mergestate was not stored +node = repo['.'].hex() + +repo.ui.status(_("aborting the merge, updating back to" + " %s\n") % node[:12]) +stats = mergemod.update(repo, node, branchmerge=False, force=True, +labels=labels) +_showstats(repo, stats) + def _incoming(displaychlist, subreporecurse, ui, repo, source, opts, buffered=False): """ diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -4101,6 +4101,14 @@ return hg.merge(repo, node, force=force, mergeforce=force,
D6588: abort: added support for merge
pulkit added inline comments. INLINE COMMENTS > test-commit-unresolved.t:1 > +#testcases hgabort abortflag > + `abortcommand` will be better name instead of `hgabort` as that will match the way we named `abortflag` and will be more easier to realise the difference between them. REPOSITORY rHG Mercurial CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D6588/new/ REVISION DETAIL https://phab.mercurial-scm.org/D6588 To: taapas1128, #hg-reviewers Cc: pulkit, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D6588: abort: added support for merge
pulkit added inline comments. INLINE COMMENTS > test-commit-unresolved.t:45 >[255] > +#endif > + since there are only two cases, you can use `#else` here. > test-commit-unresolved.t:169 > > +#if abortflag >$ hg merge --abort We can put only the command in `if` and `else` part. The output is same on the both sides. REPOSITORY rHG Mercurial CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D6588/new/ REVISION DETAIL https://phab.mercurial-scm.org/D6588 To: taapas1128, #hg-reviewers Cc: pulkit, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D6588: abort: added support for merge
taapas1128 updated this revision to Diff 15760. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D6588?vs=15755=15760 CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D6588/new/ REVISION DETAIL https://phab.mercurial-scm.org/D6588 AFFECTED FILES mercurial/commands.py mercurial/hg.py mercurial/state.py tests/test-abort.t tests/test-commit-unresolved.t CHANGE DETAILS diff --git a/tests/test-commit-unresolved.t b/tests/test-commit-unresolved.t --- a/tests/test-commit-unresolved.t +++ b/tests/test-commit-unresolved.t @@ -1,3 +1,5 @@ +#testcases hgabort abortflag + $ addcommit () { > echo $1 > $1 > hg add $1 @@ -36,9 +38,18 @@ Testing the abort functionality first in case of conflicts +#if abortflag $ hg merge --abort abort: no merge in progress [255] +#endif + +#if hgabort + $ hg abort + abort: no operation in progress + [255] +#endif + $ hg merge merging A warning: conflicts while merging A! (edit, then use 'hg resolve --mark') @@ -53,9 +64,33 @@ abort: cannot specify both --rev and --abort [255] +#if abortflag $ hg merge --abort aborting the merge, updating back to e45016d2b3d3 1 files updated, 0 files merged, 1 files removed, 0 files unresolved +#endif + +#if hgabort +when in dry-run mode + $ hg abort --dry-run + aborting merge + +when in no-backup mode + $ hg abort --no-backup + abort: merge does not support no-backup flag + [255] + +when dry-run mode is used with no backup + $ hg abort --dry-run --no-backup + aborting merge + abort: merge does not support no-backup flag + [255] + +normal abort + $ hg abort + aborting the merge, updating back to e45016d2b3d3 + 1 files updated, 0 files merged, 1 files removed, 0 files unresolved +#endif Checking that we got back in the same state @@ -131,9 +166,17 @@ abort: cannot specify --preview with --abort [255] +#if abortflag $ hg merge --abort aborting the merge, updating back to 68352a18a7c4 1 files updated, 0 files merged, 1 files removed, 0 files unresolved +#endif + +#if hgabort + $ hg abort + aborting the merge, updating back to 68352a18a7c4 + 1 files updated, 0 files merged, 1 files removed, 0 files unresolved +#endif $ hg id 68352a18a7c4 tip diff --git a/tests/test-abort.t b/tests/test-abort.t --- a/tests/test-abort.t +++ b/tests/test-abort.t @@ -661,9 +661,8 @@ Unshelve abort fails with appropriate message if there's no unshelve in progress $ hg abort - abort: merge does not support 'hg abort' - (use 'hg commit' or 'hg merge --abort') - [255] + aborting the merge, updating back to 9451eaa6eee3 + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ cd .. Abort due to pending changes diff --git a/mercurial/state.py b/mercurial/state.py --- a/mercurial/state.py +++ b/mercurial/state.py @@ -205,13 +205,6 @@ 'To mark the changeset bad: hg bisect --bad\n' 'To abort: hg bisect --reset\n') ) -addunfinished( -'merge', fname=None, clearable=True, allowcommit=True, -cmdmsg=_('outstanding uncommitted merge'), -statushint=_('To continue:hg commit\n' - 'To abort: hg merge --abort'), -cmdhint=_("use 'hg commit' or 'hg merge --abort'") -) def getrepostate(repo): # experimental config: commands.status.skipstates diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -956,23 +956,11 @@ abort=False): """Branch merge with node, resolving changes. Return true if any unresolved conflicts.""" -if not abort: -stats = mergemod.update(repo, node, branchmerge=True, force=force, -mergeforce=mergeforce, labels=labels) -else: -ms = mergemod.mergestate.read(repo) -if ms.active(): -# there were conflicts -node = ms.localctx.hex() -else: -# there were no conficts, mergestate was not stored -node = repo['.'].hex() - -repo.ui.status(_("aborting the merge, updating back to" - " %s\n") % node[:12]) -stats = mergemod.update(repo, node, branchmerge=False, force=True, -labels=labels) - +if abort: +return abortmerge(repo.ui, repo, labels=labels) + +stats = mergemod.update(repo, node, branchmerge=True, force=force, +mergeforce=mergeforce, labels=labels) _showstats(repo, stats) if stats.unresolvedcount: repo.ui.status(_("use 'hg resolve' to retry unresolved file merges " @@ -981,6 +969,25 @@ repo.ui.status(_("(branch merge, don't forget to commit)\n")) return stats.unresolvedcount > 0 +def abortmerge(ui, repo, labels=None, **opts): +if opts.get('no_backup'): +raise error.Abort(_("merge does not support no-backup flag")) +if opts.get('dry_run'): +
D6588: abort: added support for merge
taapas1128 edited the summary of this revision. taapas1128 updated this revision to Diff 15755. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D6588?vs=15749=15755 CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D6588/new/ REVISION DETAIL https://phab.mercurial-scm.org/D6588 AFFECTED FILES mercurial/commands.py mercurial/hg.py mercurial/state.py tests/test-abort.t CHANGE DETAILS diff --git a/tests/test-abort.t b/tests/test-abort.t --- a/tests/test-abort.t +++ b/tests/test-abort.t @@ -661,9 +661,8 @@ Unshelve abort fails with appropriate message if there's no unshelve in progress $ hg abort - abort: merge does not support 'hg abort' - (use 'hg commit' or 'hg merge --abort') - [255] + aborting the merge, updating back to 9451eaa6eee3 + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ cd .. Abort due to pending changes @@ -976,3 +975,75 @@ $ hg abort abort: no operation in progress [255] + $ cd .. + +TEST `hg abort` operation merge + + $ addcommit () { + > echo $1 > $1 + > hg add $1 + > hg commit -d "${2} 0" -m $1 + > } + + $ commit () { + > hg commit -d "${2} 0" -m $1 + > } + + $ hg init a + $ cd a + $ addcommit "A" 0 + $ addcommit "B" 1 + $ echo "C" >> A + $ commit "C" 2 + + $ hg update -C 0 + 1 files updated, 0 files merged, 1 files removed, 0 files unresolved + $ echo "D" >> A + $ commit "D" 3 + created new head + +State before the merge + + $ hg status + $ hg id + e45016d2b3d3 tip + $ hg summary + parent: 3:e45016d2b3d3 tip + D + branch: default + commit: (clean) + update: 2 new changesets, 2 branch heads (merge) + phases: 4 draft + +Testing the abort functionality first in case of conflicts + + $ hg abort + abort: no operation in progress + [255] + $ hg merge + merging A + warning: conflicts while merging A! (edit, then use 'hg resolve --mark') + 1 files updated, 0 files merged, 0 files removed, 1 files unresolved + use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon + [1] + +when in dry-run mode + $ hg abort --dry-run + aborting merge + +when in no-backup mode + $ hg abort --no-backup + abort: merge does not support no-backup flag + [255] + +when dry-run mode is used with no backup + $ hg abort --dry-run --no-backup + aborting merge + abort: merge does not support no-backup flag + [255] + +normal abort + $ hg abort + aborting the merge, updating back to e45016d2b3d3 + 1 files updated, 0 files merged, 1 files removed, 0 files unresolved + diff --git a/mercurial/state.py b/mercurial/state.py --- a/mercurial/state.py +++ b/mercurial/state.py @@ -205,13 +205,6 @@ 'To mark the changeset bad: hg bisect --bad\n' 'To abort: hg bisect --reset\n') ) -addunfinished( -'merge', fname=None, clearable=True, allowcommit=True, -cmdmsg=_('outstanding uncommitted merge'), -statushint=_('To continue:hg commit\n' - 'To abort: hg merge --abort'), -cmdhint=_("use 'hg commit' or 'hg merge --abort'") -) def getrepostate(repo): # experimental config: commands.status.skipstates diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -956,23 +956,11 @@ abort=False): """Branch merge with node, resolving changes. Return true if any unresolved conflicts.""" -if not abort: -stats = mergemod.update(repo, node, branchmerge=True, force=force, -mergeforce=mergeforce, labels=labels) -else: -ms = mergemod.mergestate.read(repo) -if ms.active(): -# there were conflicts -node = ms.localctx.hex() -else: -# there were no conficts, mergestate was not stored -node = repo['.'].hex() - -repo.ui.status(_("aborting the merge, updating back to" - " %s\n") % node[:12]) -stats = mergemod.update(repo, node, branchmerge=False, force=True, -labels=labels) - +if abort: +return abortmerge(repo.ui, repo, labels=labels) + +stats = mergemod.update(repo, node, branchmerge=True, force=force, +mergeforce=mergeforce, labels=labels) _showstats(repo, stats) if stats.unresolvedcount: repo.ui.status(_("use 'hg resolve' to retry unresolved file merges " @@ -981,6 +969,25 @@ repo.ui.status(_("(branch merge, don't forget to commit)\n")) return stats.unresolvedcount > 0 +def abortmerge(ui, repo, labels=None, **opts): +if opts.get('no_backup'): +raise error.Abort(_("merge does not support no-backup flag")) +if opts.get('dry_run'): +return 0 +ms = mergemod.mergestate.read(repo) +if ms.active(): +# there were conflicts +node = ms.localctx.hex() +else: +# there were no
D6588: abort: added support for merge
taapas1128 updated this revision to Diff 15749. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D6588?vs=15706=15755 CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D6588/new/ REVISION DETAIL https://phab.mercurial-scm.org/D6588 AFFECTED FILES mercurial/commands.py mercurial/hg.py mercurial/state.py tests/test-abort.t CHANGE DETAILS diff --git a/tests/test-abort.t b/tests/test-abort.t --- a/tests/test-abort.t +++ b/tests/test-abort.t @@ -661,9 +661,8 @@ Unshelve abort fails with appropriate message if there's no unshelve in progress $ hg abort - abort: merge does not support 'hg abort' - (use 'hg commit' or 'hg merge --abort') - [255] + aborting the merge, updating back to 9451eaa6eee3 + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ cd .. Abort due to pending changes @@ -978,3 +977,75 @@ $ hg abort abort: no operation in progress [255] + $ cd .. + +TEST `hg abort` operation merge + + $ addcommit () { + > echo $1 > $1 + > hg add $1 + > hg commit -d "${2} 0" -m $1 + > } + + $ commit () { + > hg commit -d "${2} 0" -m $1 + > } + + $ hg init a + $ cd a + $ addcommit "A" 0 + $ addcommit "B" 1 + $ echo "C" >> A + $ commit "C" 2 + + $ hg update -C 0 + 1 files updated, 0 files merged, 1 files removed, 0 files unresolved + $ echo "D" >> A + $ commit "D" 3 + created new head + +State before the merge + + $ hg status + $ hg id + e45016d2b3d3 tip + $ hg summary + parent: 3:e45016d2b3d3 tip + D + branch: default + commit: (clean) + update: 2 new changesets, 2 branch heads (merge) + phases: 4 draft + +Testing the abort functionality first in case of conflicts + + $ hg abort + abort: no operation in progress + [255] + $ hg merge + merging A + warning: conflicts while merging A! (edit, then use 'hg resolve --mark') + 1 files updated, 0 files merged, 0 files removed, 1 files unresolved + use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon + [1] + +when in dry-run mode + $ hg abort --dry-run + abort: aborting merge + [255] + +when in no-backup mode + $ hg abort --no-backup + abort: merge does not support no-backup + [255] + +when dry-run mode is used with no backup + $ hg abort --dry-run --no-backup + abort: merge does not support no-backup + [255] + +normal abort + $ hg abort + aborting the merge, updating back to e45016d2b3d3 + 1 files updated, 0 files merged, 1 files removed, 0 files unresolved + diff --git a/mercurial/state.py b/mercurial/state.py --- a/mercurial/state.py +++ b/mercurial/state.py @@ -205,13 +205,6 @@ 'To mark the changeset bad: hg bisect --bad\n' 'To abort: hg bisect --reset\n') ) -addunfinished( -'merge', fname=None, clearable=True, allowcommit=True, -cmdmsg=_('outstanding uncommitted merge'), -statushint=_('To continue:hg commit\n' - 'To abort: hg merge --abort'), -cmdhint=_("use 'hg commit' or 'hg merge --abort'") -) def getrepostate(repo): # experimental config: commands.status.skipstates diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -960,18 +960,8 @@ stats = mergemod.update(repo, node, branchmerge=True, force=force, mergeforce=mergeforce, labels=labels) else: -ms = mergemod.mergestate.read(repo) -if ms.active(): -# there were conflicts -node = ms.localctx.hex() -else: -# there were no conficts, mergestate was not stored -node = repo['.'].hex() - -repo.ui.status(_("aborting the merge, updating back to" - " %s\n") % node[:12]) -stats = mergemod.update(repo, node, branchmerge=False, force=True, -labels=labels) +ui = repo.ui +stats = abortmerge(ui, repo, labels=labels, asflag=True) _showstats(repo, stats) if stats.unresolvedcount: @@ -981,6 +971,23 @@ repo.ui.status(_("(branch merge, don't forget to commit)\n")) return stats.unresolvedcount > 0 +def abortmerge(ui, repo, labels=None, asflag=False): +ms = mergemod.mergestate.read(repo) +if ms.active(): +# there were conflicts +node = ms.localctx.hex() +else: +# there were no conficts, mergestate was not stored +node = repo['.'].hex() + +repo.ui.status(_("aborting the merge, updating back to" + " %s\n") % node[:12]) +stats = mergemod.update(repo, node, branchmerge=False, force=True, +labels=labels) +if asflag: +return stats +_showstats(repo, stats) + def _incoming(displaychlist, subreporecurse, ui, repo, source, opts, buffered=False): """ diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py
D6588: abort: added support for merge
pulkit added inline comments. INLINE COMMENTS > hg.py:964 > +ui = repo.ui > +stats = abortmerge(ui, repo, labels=labels, asflag=True) > we can directly pass repo.ui here. No need to have a ui variable > hg.py:964 > +ui = repo.ui > +stats = abortmerge(ui, repo, labels=labels, asflag=True) > we actually don't need stats back here is we call `_showstats()` in abort merge. The stats related lines below can be moved to if condition above. Hence removing the asflag argument. REPOSITORY rHG Mercurial CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D6588/new/ REVISION DETAIL https://phab.mercurial-scm.org/D6588 To: taapas1128, #hg-reviewers Cc: pulkit, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D6588: abort: added support for merge
pulkit added inline comments. INLINE COMMENTS > commands.py:151 > raise error.Abort(_('no operation in progress')) > +if abortstate._opname == 'merge': > +return hg.merge(repo, abort=True) let's refactor some code and create a function for merge abort instead of special casing it. > hg.py:963 > else: > ms = mergemod.mergestate.read(repo) > if ms.active(): We can compute node required here again, and hence take this abort related code into a separate function. REPOSITORY rHG Mercurial CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D6588/new/ REVISION DETAIL https://phab.mercurial-scm.org/D6588 To: taapas1128, #hg-reviewers Cc: pulkit, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D6588: abort: added support for merge
taapas1128 created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY This adds support of `hg merge --abort` to `hg abort`. Results are shown as tests. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D6588 AFFECTED FILES mercurial/commands.py mercurial/hg.py tests/test-abort.t CHANGE DETAILS diff --git a/tests/test-abort.t b/tests/test-abort.t --- a/tests/test-abort.t +++ b/tests/test-abort.t @@ -628,9 +628,8 @@ Unshelve abort fails with appropriate message if there's no unshelve in progress $ hg abort - abort: merge does not support 'hg abort' - (use 'hg commit' or 'hg merge --abort') - [255] + aborting the merge, updating back to 9451eaa6eee3 + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ cd .. Abort due to pending changes @@ -902,3 +901,59 @@ $ hg abort abort: no operation in progress [255] + $ cd .. + +TEST `hg abort` operation merge + + $ addcommit () { + > echo $1 > $1 + > hg add $1 + > hg commit -d "${2} 0" -m $1 + > } + + $ commit () { + > hg commit -d "${2} 0" -m $1 + > } + + $ hg init a + $ cd a + $ addcommit "A" 0 + $ addcommit "B" 1 + $ echo "C" >> A + $ commit "C" 2 + + $ hg update -C 0 + 1 files updated, 0 files merged, 1 files removed, 0 files unresolved + $ echo "D" >> A + $ commit "D" 3 + created new head + +State before the merge + + $ hg status + $ hg id + e45016d2b3d3 tip + $ hg summary + parent: 3:e45016d2b3d3 tip + D + branch: default + commit: (clean) + update: 2 new changesets, 2 branch heads (merge) + phases: 4 draft + +Testing the abort functionality first in case of conflicts + + $ hg abort + abort: no operation in progress + [255] + $ hg merge + merging A + warning: conflicts while merging A! (edit, then use 'hg resolve --mark') + 1 files updated, 0 files merged, 0 files removed, 1 files unresolved + use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon + [1] + + $ hg abort + aborting the merge, updating back to e45016d2b3d3 + 1 files updated, 0 files merged, 1 files removed, 0 files unresolved + diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -952,8 +952,8 @@ return ret -def merge(repo, node, force=None, remind=True, mergeforce=False, labels=None, - abort=False): +def merge(repo, node=None, force=None, remind=True, mergeforce=False, + labels=None, abort=False): """Branch merge with node, resolving changes. Return true if any unresolved conflicts.""" if not abort: diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -148,6 +148,8 @@ break if not abortstate: raise error.Abort(_('no operation in progress')) +if abortstate._opname == 'merge': +return hg.merge(repo, abort=True) if abortstate._abortfunc: return abortstate._abortfunc(ui, repo) raise error.Abort((_("%s does not support 'hg abort'") % To: taapas1128, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel