hgext/mq.py
changeset 16128 004982e5d782
parent 16102 50682c07a8d0
parent 16119 5de83d9ca79c
child 16152 816211dfa3a5
--- a/hgext/mq.py	Thu Feb 16 15:58:51 2012 -0600
+++ b/hgext/mq.py	Thu Feb 16 16:40:29 2012 -0600
@@ -1796,6 +1796,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.
@@ -1848,6 +1849,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
@@ -1902,9 +1904,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')),
@@ -2030,15 +2034,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