Mercurial > evolve
changeset 127:7e113963f2c8
Add gup and gdown command to mimic qpop and qpush command
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Mon, 09 Jan 2012 20:25:48 +0100 |
parents | c083fb43daee |
children | 6bcbf7f6ceed |
files | hgext/evolution.py |
diffstat | 1 files changed, 48 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/evolution.py Sun Jan 08 18:43:49 2012 +0100 +++ b/hgext/evolution.py Mon Jan 09 20:25:48 2012 +0100 @@ -21,7 +21,8 @@ from mercurial import commands from mercurial import util from mercurial.i18n import _ -from mercurial.commands import walkopts, commitopts, commitopts2, logopts +from mercurial.commands import walkopts, commitopts, commitopts2, logopt +from mercurial import hg ### util function ############################# @@ -170,25 +171,54 @@ target = newer[-1] repo.ui.status('hg relocate --rev %s %s\n' % (repo[next], repo[target])) -@command('^relocate', - [ - ('r', 'rev', '.', - _('revision to relocate')), - ], - '') -def cmdrelocate(ui, repo, dest, rev='.'): - """relocate a changeset""" - wlock = repo.wlock() - try: - src = scmutil.revsingle(repo, rev, rev) - dest = scmutil.revsingle(repo, dest, dest) - if src == src.ancestor(dest): - raise util.Abort(_('source is ancestor of destination')) - relocate(repo, src.rev(), dest.rev()) +shorttemplate = '[{rev}] {desc|firstline}\n' + +@command('^gdown', + [], + 'update to working directory parent an display summary lines') +def cmdgdown(ui, repo): + wkctx = repo[None] + wparents = wkctx.parents() + if len(wparents) != 1: + raise util.Abort('merge in progress') + + parents = wparents[0].parents() + displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate}) + if len(parents) == 1: + p = parents[0] + hg.update(repo, p.rev()) + displayer.show(p) return 0 - finally: - wlock.release() + else: + for p in parents: + displayer.show(p) + ui.warn(_('multiple parents, explicitly update to one\n')) + return 1 + +@command('^gup', + [], + 'update to working directory children an display summary lines') +def cmdup(ui, repo): + wkctx = repo[None] + wparents = wkctx.parents() + if len(wparents) != 1: + raise util.Abort('merge in progress') + children = [ctx for ctx in wparents[0].children() if not ctx.obsolete()] + displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate}) + if not children: + ui.warn(_('No non-obsolete children\n')) + return 1 + if len(children) == 1: + c = children[0] + hg.update(repo, c.rev()) + displayer.show(c) + return 0 + else: + for c in children: + displayer.show(c) + ui.warn(_('Multiple non-obsolete children, explicitly update to one\n')) + return 1 @command('^kill',