tags: make argument 'tagtype' optional in '_updatetags'
authorPierre-Yves David <pierre-yves.david@ens-lyon.org>
Tue, 28 Mar 2017 07:39:10 +0200
changeset 31708 d0e7c70f14b7
parent 31707 9cd640e5c1ba
child 31709 c34c170b25f3
tags: make argument 'tagtype' optional in '_updatetags' This is the next step from the previous changesets, we are now ready to use this function in a simpler way.
mercurial/tags.py
--- a/mercurial/tags.py	Tue Mar 28 07:38:10 2017 +0200
+++ b/mercurial/tags.py	Tue Mar 28 07:39:10 2017 +0200
@@ -223,15 +223,22 @@
         newtags[tag] = (taghist[-1], taghist[:-1])
     return newtags
 
-def _updatetags(filetags, alltags, tagtype, tagtypes):
-    '''Incorporate the tag info read from one file into the two
-    dictionaries, alltags and tagtypes, that contain all tag
-    info (global across all heads plus local).'''
+def _updatetags(filetags, alltags, tagtype=None, tagtypes=None):
+    """Incorporate the tag info read from one file into dictionnaries
+
+    The first one, 'alltags', is a "tagmaps" (see 'findglobaltags' for details).
+
+    The second one, 'tagtypes', is optional and will be updated to track the
+    "tagtype" of entries in the tagmaps. When set, the 'tagtype' argument also
+    needs to be set."""
+    if tagtype is None:
+        assert tagtypes is None
 
     for name, nodehist in filetags.iteritems():
         if name not in alltags:
             alltags[name] = nodehist
-            tagtypes[name] = tagtype
+            if tagtype is not None:
+                tagtypes[name] = tagtype
             continue
 
         # we prefer alltags[name] if:
@@ -243,7 +250,7 @@
         if (bnode != anode and anode in bhist and
             (bnode not in ahist or len(bhist) > len(ahist))):
             anode = bnode
-        else:
+        elif tagtype is not None:
             tagtypes[name] = tagtype
         ahist.extend([n for n in bhist if n not in ahist])
         alltags[name] = anode, ahist