Commits

Pierre-Yves David committed 7e11396

Add gup and gdown command to mimic qpop and qpush command

Comments (0)

Files changed (1)

hgext/evolution.py

 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
 #############################
     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',