mq: make qimport --push push all imported patches (issue3130) stable
authorPatrick Mezard <patrick@mezard.eu>
Tue, 14 Feb 2012 14:31:40 +0100
branchstable
changeset 16119 5de83d9ca79c
parent 16118 d554a3dcae5a
child 16121 ccba74472af2
mq: make qimport --push push all imported patches (issue3130) Only the first imported one was pushed.
hgext/mq.py
tests/test-mq-qimport.t
--- a/hgext/mq.py	Wed Feb 15 11:21:24 2012 +0100
+++ b/hgext/mq.py	Tue Feb 14 14:31:40 2012 +0100
@@ -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
--- a/tests/test-mq-qimport.t	Wed Feb 15 11:21:24 2012 +0100
+++ b/tests/test-mq-qimport.t	Tue Feb 14 14:31:40 2012 +0100
@@ -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