tags: only return 'alltags' in 'findglobaltags'
authorPierre-Yves David <pierre-yves.david@ens-lyon.org>
Tue, 28 Mar 2017 07:41:23 +0200
changeset 31709 c34c170b25f3
parent 31708 d0e7c70f14b7
child 31710 510267cf6c58
tags: only return 'alltags' in 'findglobaltags' This is minor update along the way. We simplify the 'findglobaltags' function to only return the tags. Since no existing data is reused, we know that all tags returned are global and we can let the caller get that information if it cares about it.
mercurial/localrepo.py
mercurial/tags.py
--- a/mercurial/localrepo.py	Tue Mar 28 07:39:10 2017 +0200
+++ b/mercurial/localrepo.py	Tue Mar 28 07:41:23 2017 +0200
@@ -708,9 +708,10 @@
         # quo fine?
 
 
-        globaldata = tagsmod.findglobaltags(self.ui, self)
-        alltags = globaldata[0]   # map tag name to (node, hist)
-        tagtypes = globaldata[1]  # map tag name to tag type
+        # map tag name to (node, hist)
+        alltags = tagsmod.findglobaltags(self.ui, self)
+        # map tag name to tag type
+        tagtypes = dict((tag, 'global') for tag in alltags)
 
         tagsmod.readlocaltags(self.ui, self, alltags, tagtypes)
 
--- a/mercurial/tags.py	Tue Mar 28 07:39:10 2017 +0200
+++ b/mercurial/tags.py	Tue Mar 28 07:41:23 2017 +0200
@@ -79,17 +79,13 @@
 # setting it) for each tag is last.
 
 def findglobaltags(ui, repo):
-    '''Find global tags in a repo: return (alltags, tagtypes)
+    '''Find global tags in a repo: return a tagsmap
 
-    "alltags" maps tag name to (node, hist) 2-tuples.
-
-    "tagtypes" maps tag name to tag type. Global tags always have the
-    "global" tag type.
+    tagsmap: tag name to (node, hist) 2-tuples.
 
     The tags cache is read and updated as a side-effect of calling.
     '''
     alltags = {}
-    tagtypes = {}
 
     (heads, tagfnode, valid, cachetags, shouldwrite) = _readtagcache(ui, repo)
     if cachetags is not None:
@@ -97,8 +93,8 @@
         # XXX is this really 100% correct?  are there oddball special
         # cases where a global tag should outrank a local tag but won't,
         # because cachetags does not contain rank info?
-        _updatetags(cachetags, alltags, 'global', tagtypes)
-        return alltags, tagtypes
+        _updatetags(cachetags, alltags)
+        return alltags
 
     seen = set()  # set of fnode
     fctx = None
@@ -115,12 +111,12 @@
                 fctx = fctx.filectx(fnode)
 
             filetags = _readtags(ui, repo, fctx.data().splitlines(), fctx)
-            _updatetags(filetags, alltags, 'global', tagtypes)
+            _updatetags(filetags, alltags)
 
     # and update the cache (if necessary)
     if shouldwrite:
         _writetagcache(ui, repo, valid, alltags)
-    return alltags, tagtypes
+    return alltags
 
 def readlocaltags(ui, repo, alltags, tagtypes):
     '''Read local tags in repo. Update alltags and tagtypes.'''