[PATCH] Add a --all option to qfold that fold all unapplied patch in the current one

Pierre-Yves David pierre-yves.david at ens-lyon.org
Tue Sep 21 12:07:09 CDT 2010


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1285028334 -7200
# Node ID 1ada9dc8dee5ae2345cf619a6186cff79531c6d3
# Parent  d0a97814b7d7f7eb6790d00813848dfc9ea82193
Add a --all option to qfold that fold all unapplied patch in the current one.

This options is not compatible with explicite patch name.

The need for such feature have been express on stack overflow:
    http://stackoverflow.com/questions/3715016/mercurial-qfold-all-patches

diff -r d0a97814b7d7 -r 1ada9dc8dee5 hgext/mq.py
--- a/hgext/mq.py	Mon Sep 20 23:42:23 2010 +0200
+++ b/hgext/mq.py	Tue Sep 21 02:18:54 2010 +0200
@@ -2103,7 +2103,11 @@
 
     q = repo.mq
 
-    if not files:
+    if opts['all']:
+      if files:
+         raise util.Abort(_('option "-a" incompatible with explicit patch name'))
+      files = [patches for idx, patches in q.unapplied(repo)]
+    elif not files:
         raise util.Abort(_('qfold requires at least one patch name'))
     if not q.check_toppatch(repo)[0]:
         raise util.Abort(_('no patches applied'))
@@ -2978,6 +2982,7 @@
         (fold,
          [('e', 'edit', None, _('edit patch header')),
           ('k', 'keep', None, _('keep folded patch files')),
+          ('a', 'all',  None, _('fold all unapplied patches')),
          ] + commands.commitopts,
          _('hg qfold [-e] [-k] [-m TEXT] [-l FILE] PATCH...')),
     'qgoto':
diff -r d0a97814b7d7 -r 1ada9dc8dee5 tests/test-mq-qfold.t
--- a/tests/test-mq-qfold.t	Mon Sep 20 23:42:23 2010 +0200
+++ b/tests/test-mq-qfold.t	Tue Sep 21 02:18:54 2010 +0200
@@ -139,6 +139,42 @@
    a
    b
   +b
+  $ hg qpop
+  popping git
+  now at: p1
+  $ hg qdel git
+
+% fold all expect all unapplied patch to be folded
+  $ hg qdel p3
+  $ echo c >> a
+  $ hg qnew p2
+  $ echo d >> a
+  $ hg qnew p3
+  $ echo e >> a
+  $ hg qnew p4
+  $ hg qpop p2
+  popping p4
+  popping p3
+  now at: p2
+  $ hg qfold -a
+  $ cat .hg/patches/p2
+  # HG changeset patch
+  # Parent ........................................
+  
+  diff -r ............ a
+  --- a/a
+  +++ b/a
+  @@ -1,3 +1,6 @@
+   a
+   a
+   b
+  +c
+  +d
+  +e
+  $ hg qpop
+  popping p2
+  now at: p1
+  $ hg qdel p2
 
   $ cd ..
 


More information about the Mercurial-devel mailing list