topics: use scmutil.cleanupnodes to create markers while changing topics
authorPulkit Goyal <7895pulkit@gmail.com>
Thu, 05 Oct 2017 19:20:20 +0530
changeset 3038 103244e34a9c
parent 3037 5c8d5f980f49
child 3039 5b24ed4b3e9c
topics: use scmutil.cleanupnodes to create markers while changing topics Earlier if we change topics on changesets with bookmark, the bookmark is not moved to the new changeset as we didn't add that logic and we were creating obsmarkers directly. This patch calls scmutil.cleanupnodes to create obsmarkes which also handles the bookmark movement.
hgext3rd/topic/__init__.py
tests/test-topic-change.t
--- a/hgext3rd/topic/__init__.py	Thu Oct 05 18:13:52 2017 +0530
+++ b/hgext3rd/topic/__init__.py	Thu Oct 05 19:20:20 2017 +0530
@@ -718,25 +718,27 @@
         p1 = c.p1().node()
         p2 = c.p2().node()
         if p1 in successors:
-            p1 = successors[p1]
+            p1 = successors[p1][0]
         if p2 in successors:
-            p2 = successors[p2]
+            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)
-        successors[c.node()] = newnode
+        successors[c.node()] = (newnode,)
         ui.debug('new node id is %s\n' % node.hex(newnode))
-        obsolete.createmarkers(repo, [(c, (repo[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.
     if len(wctx.parents()) == 1:
         newid = successors.get(wctx.p1().node())
         if newid is not None:
-            hg.update(repo, newid, quietempty=True)
+            hg.update(repo, newid[0], quietempty=True)
     return rewrote
 
 def _listtopics(ui, repo, opts):
--- a/tests/test-topic-change.t	Thu Oct 05 18:13:52 2017 +0530
+++ b/tests/test-topic-change.t	Thu Oct 05 19:20:20 2017 +0530
@@ -294,7 +294,6 @@
      Added a  ()
   
 On clearing the topic
-XXX: the bookmark must have moved
 
   $ hg topic -r . --clear
   clearing empty topic "watwat"
@@ -303,10 +302,7 @@
 
   $ hg glog
   @  31:c48d6d71b2d9 {}
-  |  Added h  ()
-  |
-  | x  30:a24c31c35013 {watwat}
-  |/   Added h  (book)
+  |  Added h  (book)
   |
   o  26:7c76c271395f {bar}
   |  Added g  ()
@@ -331,7 +327,6 @@
   
 
 On changing the topic
-XXX: the bookmark must have moved
 
   $ hg bookmark bookboo
   $ hg topic -r . movebook
@@ -339,13 +334,7 @@
   changed topic on 1 changes
   $ hg glog
   @  32:1b83d11095b9 {movebook}
-  |  Added h  ()
-  |
-  | x  31:c48d6d71b2d9 {}
-  |/   Added h  (bookboo)
-  |
-  | x  30:a24c31c35013 {watwat}
-  |/   Added h  (book)
+  |  Added h  (book bookboo)
   |
   o  26:7c76c271395f {bar}
   |  Added g  ()