# HG changeset patch # User Anton Shestakov # Date 1621018751 -28800 # Node ID e8cc899a085a6c9180fa8cd96dff6d1140229066 # Parent e682bbe66e37eca245794e64f583818374d51b84 next: add an --abort flag diff -r e682bbe66e37 -r e8cc899a085a hgext3rd/evolve/__init__.py --- a/hgext3rd/evolve/__init__.py Sat May 15 02:58:04 2021 +0800 +++ b/hgext3rd/evolve/__init__.py Sat May 15 02:59:11 2021 +0800 @@ -819,7 +819,8 @@ (b'', b'evolve', True, _(b'evolve the next changeset if necessary')), (b'', b'no-topic', False, _(b'ignore topic and move topologically')), (b'n', b'dry-run', False, - _(b'do not perform actions, just print what would be done'))], + _(b'do not perform actions, just print what would be done')), + (b'', b'abort', False, _(b'abort the interrupted next'))], b'[OPTION]...', helpbasic=True, **compat.helpcategorykwargs('CATEGORY_WORKING_DIRECTORY')) @@ -833,6 +834,26 @@ """ wlock = None dryrunopt = opts['dry_run'] + abortopt = opts['abort'] + + compat.check_incompatible_arguments(opts, 'abort', ['move_bookmark', 'merge']) + if abortopt: + evolvestate = state.cmdstate(repo) + if not evolvestate: + raise error.Abort(_(b'no interrupted next to abort')) + + evolvestate.load() + if evolvestate[b'command'] != b'next': + raise error.Abort(_(b'no interrupted next to abort')) + + pctx = repo[b'.'] + compat.clean_update(pctx) + ui.status(_(b'next aborted\n')) + ui.status(_(b'working directory is now at %s\n') + % ui.label(bytes(pctx), b'evolve.node')) + evolvestate.delete() + return 0 + if not dryrunopt: wlock = repo.wlock() try: diff -r e682bbe66e37 -r e8cc899a085a tests/test-prev-next.t --- a/tests/test-prev-next.t Sat May 15 02:58:04 2021 +0800 +++ b/tests/test-prev-next.t Sat May 15 02:59:11 2021 +0800 @@ -608,3 +608,46 @@ move:[4] B atop:[5] B modified working directory is now at 1b434459c7e7 + + $ cd .. + +hg next --abort + + $ hg init next-abort + $ cd next-abort + + $ echo apple > a + $ hg ci -qAm apple + $ echo banana > b + $ hg ci -qAm banana + $ hg up 0 + 0 files updated, 0 files merged, 1 files removed, 0 files unresolved + $ echo blueberry > b + $ hg ci -qAm 'apple and blueberry' --amend + 1 new orphan changesets + + $ hg next + move:[1] banana + atop:[2] apple and blueberry + merging b + warning: conflicts while merging b! (edit, then use 'hg resolve --mark') + unresolved merge conflicts + (see 'hg help evolve.interrupted') + [240] + + $ hg next --abort + next aborted + working directory is now at 1c7f51cf0ef0 + $ hg next --abort + abort: no interrupted next to abort + [255] + $ hg evolve --abort + abort: no interrupted evolve to abort + [255] + + $ hg next --abort --move-bookmark + abort: cannot specify both --abort and --move-bookmark + [10] + $ hg next --abort --merge + abort: cannot specify both --abort and --merge + [10]