Patchwork [4,of,7,V2] tags: make argument 'tagtype' optional in '_updatetags'

login
register
mail settings
Submitter Pierre-Yves David
Date March 28, 2017, 12:03 p.m.
Message ID <be443f8dd6a9faaafd0c.1490702627@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/19782/
State Accepted
Headers show

Comments

Pierre-Yves David - March 28, 2017, 12:03 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
# Date 1490679550 -7200
#      Tue Mar 28 07:39:10 2017 +0200
# Node ID be443f8dd6a9faaafd0c91199808becd8fbd19a0
# Parent  c12b84af5cc12e2021793cfa431f234c5a01b66f
# EXP-Topic tags
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r be443f8dd6a9
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.

Patch

diff --git a/mercurial/tags.py b/mercurial/tags.py
--- a/mercurial/tags.py
+++ b/mercurial/tags.py
@@ -223,15 +223,22 @@  def _readtags(ui, repo, lines, fn, recod
         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 @@  def _updatetags(filetags, alltags, tagty
         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