[PATCH STABLE] mq: make qimport --push push all imported patches (issue3130)

Patrick Mezard patrick at mezard.eu
Tue Feb 14 07:43:52 CST 2012


# HG changeset patch
# User Patrick Mezard <patrick at mezard.eu>
# Date 1329226300 -3600
# Branch stable
# Node ID 65b6fddea34d5279215f08e5f5c998a42c934f0f
# Parent  f7e0d95d0a0bc5545f3dad40b9ceaee362d7c553
mq: make qimport --push push all imported patches (issue3130)

Only the first imported one was pushed.

diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -1795,6 +1795,7 @@
         if (len(files) > 1 or len(rev) > 1) and patchname:
             raise util.Abort(_('option "-n" not valid when importing multiple '
                                'patches'))
+        imported = []
         if rev:
             # If mq patches are applied, we can only import revisions
             # that form a linear path to qbase.
@@ -1847,6 +1848,7 @@
                 self.applied.insert(0, se)
 
                 self.added.append(patchname)
+                imported.append(patchname)
                 patchname = None
             if rev and repo.ui.configbool('mq', 'secret', False):
                 # if we added anything with --rev, we must move the secret root
@@ -1901,9 +1903,11 @@
             self.seriesdirty = True
             self.ui.warn(_("adding %s to series file\n") % patchname)
             self.added.append(patchname)
+            imported.append(patchname)
             patchname = None
 
         self.removeundo(repo)
+        return imported
 
 @command("qdelete|qremove|qrm",
          [('k', 'keep', None, _('keep patch file')),
@@ -2029,15 +2033,16 @@
     try:
         q = repo.mq
         try:
-            q.qimport(repo, filename, patchname=opts.get('name'),
-                  existing=opts.get('existing'), force=opts.get('force'),
-                  rev=opts.get('rev'), git=opts.get('git'))
+            imported = q.qimport(
+                repo, filename, patchname=opts.get('name'),
+                existing=opts.get('existing'), force=opts.get('force'),
+                rev=opts.get('rev'), git=opts.get('git'))
         finally:
             q.savedirty()
 
 
-        if opts.get('push') and not opts.get('rev'):
-            return q.push(repo, None)
+        if imported and opts.get('push') and not opts.get('rev'):
+            return q.push(repo, imported[-1])
     finally:
         lock.release()
     return 0
diff --git a/tests/test-mq-qimport.t b/tests/test-mq-qimport.t
--- a/tests/test-mq-qimport.t
+++ b/tests/test-mq-qimport.t
@@ -153,21 +153,41 @@
 
 try to import --push
 
-  $ echo another >> b
-  $ hg diff > another.diff
-  $ hg up -C
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ hg qimport --push another.diff
-  adding another.diff to series file
-  applying another.diff
-  now at: another.diff
+  $ cat > appendfoo.diff <<EOF
+  > append foo
+  >  
+  > diff -r 07f494440405 -r 261500830e46 baz
+  > --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  > +++ b/baz	Thu Jan 01 00:00:00 1970 +0000
+  > @@ -0,0 +1,1 @@
+  > +foo
+  > EOF
+
+  $ cat > appendbar.diff <<EOF
+  > append bar
+  >  
+  > diff -r 07f494440405 -r 261500830e46 baz
+  > --- a/baz	Thu Jan 01 00:00:00 1970 +0000
+  > +++ b/baz	Thu Jan 01 00:00:00 1970 +0000
+  > @@ -1,1 +1,2 @@
+  >  foo
+  > +bar
+  > EOF
+
+  $ hg qimport --push appendfoo.diff appendbar.diff
+  adding appendfoo.diff to series file
+  adding appendbar.diff to series file
+  applying appendfoo.diff
+  applying appendbar.diff
+  now at: appendbar.diff
   $ hg qfin -a
   patch b.diff finalized without changeset message
-  patch another.diff finalized without changeset message
-  $ hg qimport -rtip -P
+  $ hg qimport -r 'p1(.)::' -P
   $ hg qpop -a
+  popping 3.diff
   popping 2.diff
   patch queue now empty
+  $ hg qdel 3.diff
   $ hg qdel -k 2.diff
 
 qimport -e


More information about the Mercurial-devel mailing list