[PATCH] mq: Add a new command, 'qrebase', to obviate need for 'qsave'

Peter Williams pwil3058 at bigpond.net.au
Sun Aug 23 23:44:03 CDT 2009


# HG changeset patch
# User Peter Williams <pwil3058 at bigpond.net.au>
# Date 1251088950 -36000
# Node ID 6b070b840907062dd1b65da17581ca3da75df8d1
# Parent  37042e8b3b342b2e380d8be3e3f7692584c92d33
mq: Add a new command, 'qrebase', to obviate need for 'qsave'

diff -r 37042e8b3b34 -r 6b070b840907 hgext/mq.py
--- a/hgext/mq.py	Mon Jun 29 01:33:26 2009 +0900
+++ b/hgext/mq.py	Mon Aug 24 14:42:30 2009 +1000
@@ -27,6 +27,8 @@ Common tasks (use "hg help command" for 
   add known patch to applied stack          qpush
   remove patch from applied stack           qpop
   refresh contents of top applied patch     qrefresh
+
+  reparent the patch series                 qreparent
 '''
 
 from mercurial.i18n import _
@@ -2165,6 +2167,31 @@ def pop(ui, repo, patch=None, **opts):
     q.save_dirty()
     return ret
 
+def qreparent(ui, repo, **opts):
+    """move all applied patches to a different parent revision
+
+    qreparent uses repeated merging to graft a patch series from one part
+    of history onto another. This can be useful for updating the
+    patches when the master development tree is updated.
+
+    If a qreparent is interrupted to manually resolve a merge, it can be
+    continued with --continue/-c or aborted with --abort/-a.
+
+    If all patches are not applied, qreparent will abort unless the
+    -f/--force option is specified.
+    """
+
+    q = repo.mq
+
+    if len(q.applied) == 0:
+        ui.warn(_("no patches applied\n"))
+        return
+    if not q.isapplied(q.series[-1]) and not opts.get('force'):
+        raise util.Abort(_('not all patches applied (use -f to force)'))
+    from hgext import rebase
+    opts['base'] = 'qbase'
+    return rebase.rebase(ui, repo, **opts)
+ 
 def rename(ui, repo, patch, name=None, **opts):
     """rename a patch
 
@@ -2614,6 +2641,15 @@ cmdtable = {
          _('hg qrefresh [-I] [-X] [-e] [-m TEXT] [-l FILE] [-s] [FILE]...')),
     'qrename|qmv':
         (rename, [], _('hg qrename PATCH1 [PATCH2]')),
+	"qreparent":
+        (qreparent,
+         [('d', 'dest', '', _('reparent to the given revision')),
+          ('f', 'force', None, _('reparent partially applied series')),
+          ('', 'keep', False, _('keep original revisions')),
+          ('c', 'continue', False, _('continue an interrupted reparenting')),
+          ('a', 'abort', False, _('abort an interrupted rebase')),] +
+          commands.templateopts,
+         _('hg qreparent [-d REV] [--keep] | [-c] | [-a]')),
     "qrestore":
         (restore,
          [('d', 'delete', None, _('delete save entry')),


More information about the Mercurial-devel mailing list