diff hgext3rd/topic/destination.py @ 1986:042356d5ba59

ngtip: rely on topicmap for 'ngtip' ngtip is an old function that predates the introduction of a more proper topic aware 'topicmap'. We replace the old code with a call to the new one. This change set function return type and have minor effect in a couple of place.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Tue, 16 Aug 2016 15:32:54 +0200
parents 2a07df823588
children 093af1c7d58d
line wrap: on
line diff
--- a/hgext3rd/topic/destination.py	Sun Aug 14 19:57:58 2016 +0200
+++ b/hgext3rd/topic/destination.py	Tue Aug 16 15:32:54 2016 +0200
@@ -8,6 +8,7 @@
     extensions,
     util,
 )
+from . import topicmap
 from .evolvebits import builddependencies
 
 def _destmergebranch(orig, repo, action='merge', sourceset=None,
@@ -40,7 +41,7 @@
             if not bhead:
                 raise error.NoMergeDestAbort(_("nothing to merge"))
             elif 1 == len(bhead):
-                return bhead.first()
+                return bhead[0]
             else:
                 msg = _("branch '%s' has %d heads "
                         "- please merge with an explicit rev")
@@ -88,16 +89,14 @@
     # but that is expensive
     #
     # we should write plain code instead
-    subquery = '''heads(
-                    parents(
-                       ancestor(
-                         (head() and branch(%s)
-                         or (topic() and branch(%s)))))
-                   ::(head() and branch(%s))
-                   - topic())'''
-    if not all:
-        subquery = 'max(%s)' % subquery
-    return repo.revs(subquery, branch, branch, branch)
+    with topicmap.usetopicmap(repo):
+        tmap = repo.branchmap()
+        if branch not in tmap:
+            return []
+        elif all:
+            return tmap.branchheads(branch)
+        else:
+            return [tmap.branchtip(branch)]
 
 def modsetup(ui):
     """run a uisetup time to install all destinations wrapping"""