hgext/mq.py
changeset 4432 905397be7688
parent 4430 94cb7561337d
child 4437 a210b40d0860
--- a/hgext/mq.py	Tue May 08 11:51:16 2007 -0700
+++ b/hgext/mq.py	Tue May 08 13:10:27 2007 -0700
@@ -1762,6 +1762,17 @@
     q.delete(repo, patches, opts)
     q.save_dirty()
 
+def goto(ui, repo, patch, **opts):
+    '''push or pop patches until named patch is at top of stack'''
+    q = repo.mq
+    patch = q.lookup(patch)
+    if q.isapplied(patch):
+        ret = q.pop(repo, patch, force=opts['force'])
+    else:
+        ret = q.push(repo, patch, force=opts['force'])
+    q.save_dirty()
+    return ret
+
 def guard(ui, repo, *args, **opts):
     '''set or print guards for a patch
 
@@ -2202,6 +2213,8 @@
           ('k', 'keep', None, _('keep folded patch files'))
           ] + commands.commitopts,
          'hg qfold [-e] [-m <text>] [-l <file] PATCH...'),
+    'qgoto': (goto, [('f', 'force', None, _('overwrite any local changes'))],
+              'hg qgoto [OPT]... PATCH'),
     'qguard': (guard, [('l', 'list', None, _('list all patches and guards')),
                        ('n', 'none', None, _('drop all guards'))],
                'hg qguard [PATCH] [+GUARD]... [-GUARD]...'),