changeset 16026:31c02546e6de stable

qrefresh: keep changeset phase during refresh
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Mon, 30 Jan 2012 17:36:30 +0100
parents 6697498bdd83
children 29ea059be33c
files hgext/mq.py tests/test-mq-qrefresh.t
diffstat 2 files changed, 31 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/mq.py	Mon Jan 30 17:33:09 2012 +0100
+++ b/hgext/mq.py	Mon Jan 30 17:36:30 2012 +0100
@@ -1511,6 +1511,8 @@
 
                 user = ph.user or changes[1]
 
+                oldphase = repo[top].phase()
+
                 # assumes strip can roll itself back if interrupted
                 repo.dirstate.setparents(*cparents)
                 self.applied.pop()
@@ -1523,8 +1525,15 @@
 
             try:
                 # might be nice to attempt to roll back strip after this
-                n = secretcommit(repo, message, user, ph.date, match=match,
-                                 force=True)
+                backup = repo.ui.backupconfig('phases', 'new-commit')
+                try:
+                    # Ensure we create a new changeset in the same phase than
+                    # the old one.
+                    repo.ui.setconfig('phases', 'new-commit', oldphase)
+                    n = repo.commit(message, user, ph.date, match=match,
+                                    force=True)
+                finally:
+                    repo.ui.restoreconfig(backup)
                 # only write patch after a successful commit
                 patchf.close()
                 self.applied.append(statusentry(n, patchfn))
--- a/tests/test-mq-qrefresh.t	Mon Jan 30 17:33:09 2012 +0100
+++ b/tests/test-mq-qrefresh.t	Mon Jan 30 17:36:30 2012 +0100
@@ -523,3 +523,23 @@
   diff --git a/a b/a
   new file mode 100644
   $ cd ..
+
+Refresh with phase data:
+
+
+
+  $ cd repo
+  $ echo 'babar' >> a
+  $ hg qnew -m 'update a' p2.diff
+  $ hg phase p2.diff
+  2: draft
+  $ echo 'beber' >> a
+  $ hg qref
+  $ hg phase p2.diff
+  2: draft
+  $ hg phase --force --secret p2.diff
+  $ echo 'bibir' >> a
+  $ hg qref
+  $ hg phase p2.diff
+  2: secret
+