evolve: fix confusion in branch heads checking logic when topic in play
authorSushil khanchi <sushilkhanchi97@gmail.com>
Tue, 25 Jun 2019 21:54:22 +0530
changeset 4704 5f90eb8fd63c
parent 4703 e15dc6defc99
child 4705 c63f47a4f5ec
evolve: fix confusion in branch heads checking logic when topic in play To provide some context, when topics are in play the branchmap cache we store contains the branch info of a rev as "branch:topic" format IIUC. Assuming that is right, now in present code we don't actually cover this part that "when looking for branch heads where we also have active topic we should look for branch='branch_name:topic' instead". And we get wrong branch heads as a result. This patch make sure that we pass right candidate to find branch heads using branchmap.branchheads() by overriding the localrepo.branchheads() Changes in test file reflect the fixed behavior.
CHANGELOG
hgext3rd/topic/__init__.py
tests/test-topic-stack-data.t
tests/test-topic-stack.t
tests/test-topic.t
--- a/CHANGELOG	Sun Apr 14 12:55:46 2019 +0530
+++ b/CHANGELOG	Tue Jun 25 21:54:22 2019 +0530
@@ -7,6 +7,8 @@
   * evolve: use the same wording as core in case of unresolved conflict
   * evolve: minor output message improvements
   * evolve: improve `hg evolve --all` behavior when "." is obsolete
+  * topic: fix confusion in branch heads checking logic
+
 
 9.0.0 -- 2019-06-06
 -------------------
--- a/hgext3rd/topic/__init__.py	Sun Apr 14 12:55:46 2019 +0530
+++ b/hgext3rd/topic/__init__.py	Tue Jun 25 21:54:22 2019 +0530
@@ -436,6 +436,15 @@
                 return super(topicrepo, self).branchmap()
             return self.filtered(topicfilter).branchmap()
 
+        def branchheads(self, branch=None, start=None, closed=False):
+            if branch is None:
+                branch = self[None].branch()
+            if self.currenttopic:
+                branch = "%s:%s" % (branch, self.currenttopic)
+            return super(topicrepo, self).branchheads(branch=branch,
+                                                      start=start,
+                                                      closed=closed)
+
         def invalidatevolatilesets(self):
             # XXX we might be able to move this to something invalidated less often
             super(topicrepo, self).invalidatevolatilesets()
--- a/tests/test-topic-stack-data.t	Sun Apr 14 12:55:46 2019 +0530
+++ b/tests/test-topic-stack-data.t	Tue Jun 25 21:54:22 2019 +0530
@@ -116,7 +116,7 @@
    add foo_b
   branch: lake
   commit: (clean)
-  update: 2 new changesets (update)
+  update: (current)
   phases: 22 draft
   orphan: 3 changesets
   topic:  foo
--- a/tests/test-topic-stack.t	Sun Apr 14 12:55:46 2019 +0530
+++ b/tests/test-topic-stack.t	Tue Jun 25 21:54:22 2019 +0530
@@ -315,7 +315,7 @@
    c_d
   branch: default
   commit: (clean)
-  update: (current)
+  update: 2 new changesets (update)
   phases: 4 draft
   topic:  foo
 
--- a/tests/test-topic.t	Sun Apr 14 12:55:46 2019 +0530
+++ b/tests/test-topic.t	Tue Jun 25 21:54:22 2019 +0530
@@ -1084,11 +1084,9 @@
   changed topic on 1 changesets to "foo"
 
 Try to put a tag on current rev which also has an active topic:
-XXX: it shouldn't have aborted here
   $ hg tag 1.0
-  abort: working directory is not at a branch head (use -f to force)
-  [255]
   $ hg tags
-  tip                                2:3bbb3fdb2546
+  tip                                3:9efc5c3ac635
+  1.0                                2:3bbb3fdb2546
 
   $ cd ..