Mercurial > evolve
diff hgext/evolve.py @ 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 |
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['.'])