changeset 15927:2eec74d7ce95

mq: qimporting revision set them to secret
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Tue, 17 Jan 2012 02:26:00 +0100
parents f94513971767
children 3a51eb88046a
files hgext/mq.py tests/test-mq-qimport.t
diffstat 2 files changed, 18 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/mq.py	Wed Jan 18 16:53:49 2012 +0100
+++ b/hgext/mq.py	Tue Jan 17 02:26:00 2012 +0100
@@ -1814,6 +1814,9 @@
 
                 self.added.append(patchname)
                 patchname = None
+            if rev:
+                # if we added anything with rev, we must move the secret root
+                phases.retractboundary(repo, phases.secret, [n])
             self.parseseries()
             self.applieddirty = True
             self.seriesdirty = True
@@ -1988,16 +1991,21 @@
 
     Returns 0 if import succeeded.
     """
-    q = repo.mq
+    lock = repo.lock() # cause this may move phase
     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'))
+        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'))
+        finally:
+            q.savedirty()
+
+
+        if opts.get('push') and not opts.get('rev'):
+            return q.push(repo, None)
     finally:
-        q.savedirty()
-
-    if opts.get('push') and not opts.get('rev'):
-        return q.push(repo, None)
+        lock.release()
     return 0
 
 def qinit(ui, repo, create):
--- a/tests/test-mq-qimport.t	Wed Jan 18 16:53:49 2012 +0100
+++ b/tests/test-mq-qimport.t	Tue Jan 17 02:26:00 2012 +0100
@@ -165,6 +165,8 @@
   patch b.diff finalized without changeset message
   patch another.diff finalized without changeset message
   $ hg qimport -rtip -P
+  $ hg phase -r qbase
+  2: secret
   $ hg qpop -a
   popping 2.diff
   patch queue now empty