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

Peter Williams pwil3058 at bigpond.net.au
Tue Aug 25 01:43:50 CDT 2009


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

diff -r 37042e8b3b34 -r fdab99c0e59e hgext/mq.py
--- a/hgext/mq.py	Mon Jun 29 01:33:26 2009 +0900
+++ b/hgext/mq.py	Tue Aug 25 16:43:17 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 'rebase' to graft a patch series from one part
+    of history onto another. This can be useful for updating a patch
+    series 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 there unapplied patches (including those excluded by guards),
+    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 (len(q.applied) != len(q.series)) and not opts.get('force'):
+        raise util.Abort(_('there are unapplied patches (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