topic: preserve topic during evolve
authorPierre-Yves David <pierre-yves.david@fb.com>
Thu, 17 Mar 2016 10:04:30 -0700
changeset 1627 a91115687a7e
parent 1626 0edb545503fe
child 1628 db19b1dc5c45
topic: preserve topic during evolve previously, topic handling was absent leading to whatever the active topic was when `hg evolve` was run to be used for all evolve results
README
hgext/evolve.py
tests/test-evolve-topic.t
--- a/README	Thu Mar 17 09:39:35 2016 -0700
+++ b/README	Thu Mar 17 10:04:30 2016 -0700
@@ -60,6 +60,7 @@
 
 - Some collaboration with the topic experimental extensions
   - hg evolve --all with consider all trouble in your current topic
+  - preserve 'topic' during evolve
 
 5.3.0 -- 2016-02-11
 
--- a/hgext/evolve.py	Thu Mar 17 09:39:35 2016 -0700
+++ b/hgext/evolve.py	Thu Mar 17 10:04:30 2016 -0700
@@ -3838,6 +3838,14 @@
     bmdeactivate(repo)
     if keepbranch:
        repo.dirstate.setbranch(orig.branch())
+    if util.safehasattr(repo, 'currenttopic'):
+        # uurrgs
+        # there no other topic setter yet
+        if not orig.topic() and repo.vfs.exists('topic'):
+                repo.vfs.unlink('topic')
+        else:
+            with repo.vfs.open('topic', 'w') as f:
+                f.write(orig.topic())
 
     try:
        r = merge.graft(repo, orig, pctx, ['local', 'graft'], True)
--- a/tests/test-evolve-topic.t	Thu Mar 17 09:39:35 2016 -0700
+++ b/tests/test-evolve-topic.t	Thu Mar 17 10:04:30 2016 -0700
@@ -157,3 +157,37 @@
   o  0 - {} 199cc73e9a0b add aaa (draft)
   
 
+Test that evolve does not loose topic information
+-------------------------------------------------
+
+  $ hg evolve --rev 'topic(bar)'
+  move:[6] add ggg
+  atop:[15] add fff
+  move:[7] add hhh
+  atop:[16] add ggg
+  move:[8] add iii
+  atop:[17] add hhh
+  move:[9] add jjj
+  atop:[18] add iii
+  working directory is now at 9bf430c106b7
+  $ hg log -G
+  @  19 - {bar} 9bf430c106b7 add jjj (draft)
+  |
+  o  18 - {bar} d2dc89c57700 add iii (draft)
+  |
+  o  17 - {bar} 20bc4d02aa62 add hhh (draft)
+  |
+  o  16 - {bar} 16d6f664b17c add ggg (draft)
+  |
+  o  15 - {foo} 070c5573d8f9 add fff (draft)
+  |
+  o  14 - {foo} 42b49017ff90 add eee (draft)
+  |
+  o  11 - {foo} d9cacd156ffc add ddd (draft)
+  |
+  o  2 - {foo} cced9bac76e3 add ccc (draft)
+  |
+  o  1 - {} a4dbed0837ea add bbb (draft)
+  |
+  o  0 - {} 199cc73e9a0b add aaa (draft)
+