Mercurial > evolve
changeset 1500:b4dfafda72c2
next: add support for --dry-run
also adds support to prev
author | timeless@mozdev.org |
---|---|
date | Thu, 10 Sep 2015 16:24:50 -0400 |
parents | c936a243346a |
children | 094b54a72c1d |
files | hgext/evolve.py tests/test-prev-next.t |
diffstat | 2 files changed, 43 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/evolve.py Wed Sep 09 22:25:37 2015 -0400 +++ b/hgext/evolve.py Thu Sep 10 16:24:50 2015 -0400 @@ -1988,12 +1988,14 @@ @command('^previous', [('B', 'move-bookmark', False, _('move active bookmark after update')), - ('', 'merge', False, _('bring uncommitted change along'))], - '[-B]') + ('', 'merge', False, _('bring uncommitted change along')), + ('n', 'dry-run', False, _('do not perform actions, just print what would be done'))], + '[OPTION]...') def cmdprevious(ui, repo, **opts): """update to parent and display summary lines""" wkctx = repo[None] wparents = wkctx.parents() + dryrunopt = opts['dry_run'] if len(wparents) != 1: raise util.Abort('merge in progress') if not opts['merge']: @@ -2009,13 +2011,18 @@ p = parents[0] bm = bmactive(repo) shouldmove = opts.get('move_bookmark') and bm is not None - ret = hg.update(repo, p.rev()) - if not ret: + if dryrunopt: + ui.write('hg update %s;\n' % p.rev()) if shouldmove: - repo._bookmarks[bm] = p.node() - repo._bookmarks.write() - else: - bmdeactivate(repo) + ui.write('hg bookmark %s -r %s;\n' % (bm, p.rev())) + else: + ret = hg.update(repo, p.rev()) + if not ret: + if shouldmove: + repo._bookmarks[bm] = p.node() + repo._bookmarks.write() + else: + bmdeactivate(repo) displayer.show(p) return 0 else: @@ -2028,8 +2035,9 @@ [('B', 'move-bookmark', False, _('move active bookmark after update')), ('', 'merge', False, _('bring uncommitted change along')), - ('', 'evolve', False, _('evolve the next changeset if necessary'))], - '[-B]') + ('', 'evolve', False, _('evolve the next changeset if necessary')), + ('n', 'dry-run', False, _('do not perform actions, just print what would be done'))], + '[OPTION]...') def cmdnext(ui, repo, **opts): """update to next child @@ -2038,6 +2046,7 @@ The summary line of the destination is displayed for clarity""" wkctx = repo[None] wparents = wkctx.parents() + dryrunopt = opts['dry_run'] if len(wparents) != 1: raise util.Abort('merge in progress') if not opts['merge']: @@ -2053,13 +2062,18 @@ c = children[0] bm = bmactive(repo) shouldmove = opts.get('move_bookmark') and bm is not None - ret = hg.update(repo, c.rev()) - if not ret: + if dryrunopt: + ui.write('hg update %s;\n' % c.rev()) if shouldmove: - repo._bookmarks[bm] = c.node() - repo._bookmarks.write() - else: - bmdeactivate(repo) + ui.write('hg bookmark %s -r %s;\n' % (bm, c.rev())) + else: + ret = hg.update(repo, c.rev()) + if not ret: + if shouldmove: + repo._bookmarks[bm] = c.node() + repo._bookmarks.write() + else: + bmdeactivate(repo) displayer.show(c) result = 0 elif children: @@ -2085,7 +2099,7 @@ return 1 else: cmdutil.bailifchanged(repo) - result = _solveone(ui, repo, repo[aspchildren[0]], False, + result = _solveone(ui, repo, repo[aspchildren[0]], dryrunopt, False, lambda:None, category='unstable') if not result: ui.status(_('working directory now at %s\n') % repo['.'])
--- a/tests/test-prev-next.t Wed Sep 09 22:25:37 2015 -0400 +++ b/tests/test-prev-next.t Thu Sep 10 16:24:50 2015 -0400 @@ -22,6 +22,10 @@ * mark 0:a154386e50d1 hg next -B should move active bookmark + $ hg next -B --dry-run + hg update 1; + hg bookmark mark -r 1; + [1] added b $ hg next -B 1 files updated, 0 files merged, 0 files removed, 0 files unresolved [1] added b @@ -29,6 +33,9 @@ * mark 1:6e742c9127b3 hg prev should unset active bookmark + $ hg prev --dry-run + hg update 0; + [0] added a $ hg prev 0 files updated, 0 files merged, 1 files removed, 0 files unresolved [0] added a @@ -152,6 +159,11 @@ no children (1 unstable changesets to be evolved here, do you want --evolve?) [1] + $ hg next --evolve --dry-run + move:[2] added c + atop:[3] added b (2) + hg rebase -r 4e26ef31f919 -d 9ad178109a19 + working directory now at 9ad178109a19 $ hg next --evolve move:[2] added c atop:[3] added b (2)