changeset 16027:29ea059be33c stable

qimport: when mq.secret=True set qimported revision as secret
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Mon, 30 Jan 2012 17:37:45 +0100
parents 31c02546e6de
children 922c0e9b40be
files hgext/mq.py tests/test-mq-qimport.t
diffstat 2 files changed, 32 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/mq.py	Mon Jan 30 17:36:30 2012 +0100
+++ b/hgext/mq.py	Mon Jan 30 17:37:45 2012 +0100
@@ -1832,6 +1832,9 @@
 
                 self.added.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
+                phases.retractboundary(repo, phases.secret, [n])
             self.parseseries()
             self.applieddirty = True
             self.seriesdirty = True
@@ -2006,16 +2009,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	Mon Jan 30 17:36:30 2012 +0100
+++ b/tests/test-mq-qimport.t	Mon Jan 30 17:37:45 2012 +0100
@@ -226,3 +226,19 @@
   $ cd ../repo
   $ hg qimport http://localhost:$HGPORT/raw-rev/0///
   adding 0 to series file
+
+check qimport phase:
+
+  $ hg -q qpush
+  now at: 0
+  $ hg phase qparent
+  1: draft
+  $ hg qimport -r qparent
+  $ hg phase qbase
+  1: draft
+  $ hg qfinish qbase
+  $ echo '[mq]' >> $HGRCPATH
+  $ echo 'secret=true' >> $HGRCPATH
+  $ hg qimport -r qparent
+  $ hg phase qbase
+  1: secret