topics: handle phase correctly while changing topics
authorPulkit Goyal <7895pulkit@gmail.com>
Thu, 05 Oct 2017 19:35:58 +0530
changeset 3040 a05b6580f71c
parent 3039 5b24ed4b3e9c
child 3041 e162597b375a
topics: handle phase correctly while changing topics
hgext3rd/topic/__init__.py
tests/test-topic-change.t
--- a/hgext3rd/topic/__init__.py	Thu Oct 05 19:30:22 2017 +0530
+++ b/hgext3rd/topic/__init__.py	Thu Oct 05 19:35:58 2017 +0530
@@ -721,17 +721,28 @@
             p1 = successors[p1][0]
         if p2 in successors:
             p2 = successors[p2][0]
-        mc = context.memctx(
-            repo, (p1, p2), c.description(),
-            c.files(), filectxfn,
-            user=c.user(), date=c.date(), extra=fixedextra)
-        newnode = repo.commitctx(mc)
+        mc = context.memctx(repo,
+                            (p1, p2),
+                            c.description(),
+                            c.files(),
+                            filectxfn,
+                            user=c.user(),
+                            date=c.date(),
+                            extra=fixedextra)
+
+        # phase handling
+        commitphase = c.phase()
+        overrides = {('phases', 'new-commit'): commitphase}
+        with repo.ui.configoverride(overrides, 'changetopic'):
+            newnode = repo.commitctx(mc)
+
         successors[c.node()] = (newnode,)
         ui.debug('new node id is %s\n' % node.hex(newnode))
         rewrote += 1
 
     # create obsmarkers and move bookmarks
     scmutil.cleanupnodes(repo, successors, 'changetopics')
+
     # move the working copy too
     wctx = repo[None]
     # in-progress merge is a bit too complex for now.
--- a/tests/test-topic-change.t	Thu Oct 05 19:30:22 2017 +0530
+++ b/tests/test-topic-change.t	Thu Oct 05 19:35:58 2017 +0530
@@ -401,7 +401,5 @@
   o  8:86a186070af2 {}
      Added a  ()
   
-XXX: the phase must be preserved and hence must be secret
-
   $ hg phase -r .
-  33: draft
+  33: secret