Mercurial > public > mercurial-scm > hg-stable
diff mercurial/localrepo.py @ 31996:e6e1884df298
track-tags: write all tag changes to a file
The tag changes information we compute is now written to disk. This gives
hooks full access to that data.
The format picked for that file uses a 2 characters prefix for the action:
-R: tag removed
+A: tag added
-M: tag moved (old value)
+M: tag moved (new value)
This format allows hooks to easily select the line that matters to them without
having to post process the file too much. Here is a couple of examples:
* to select all newly tagged changeset, match "^+",
* to detect tag move, match "^.M",
* to detect tag deletion, match "-R".
Once again we rely on the fact the tag tests run through all possible
situations to test this change.
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Tue, 28 Mar 2017 10:15:02 +0200 |
parents | fe9c4d614600 |
children | e9d325cfe071 265782c4a400 |
line wrap: on
line diff
--- a/mercurial/localrepo.py Tue Mar 28 10:14:55 2017 +0200 +++ b/mercurial/localrepo.py Tue Mar 28 10:15:02 2017 +0200 @@ -1015,6 +1015,25 @@ # and do not use caches as much as it could. The current focus is on # the behavior of the feature so we disable it by default. The flag # will be removed when we are happy with the performance impact. + # + # Once this feature is no longer experimental move the following + # documentation to the appropriate help section: + # + # The ``HG_TAG_MOVED`` variable will be set if the transaction touched + # tags (new or changed or deleted tags). In addition the details of + # these changes are made available in a file at: + # ``REPOROOT/.hg/changes/tags.changes``. + # Make sure you check for HG_TAG_MOVED before reading that file as it + # might exist from a previous transaction even if no tag were touched + # in this one. Changes are recorded in a line base format:: + # + # <action> <hex-node> <tag-name>\n + # + # Actions are defined as follow: + # "-R": tag is removed, + # "+A": tag is added, + # "-M": tag is moved (old value), + # "+M": tag is moved (new value), tracktags = lambda x: None # experimental config: experimental.hook-track-tags shouldtracktags = self.ui.configbool('experimental', 'hook-track-tags', @@ -1031,6 +1050,12 @@ changes = tagsmod.difftags(repo.ui, repo, oldfnodes, newfnodes) if changes: tr2.hookargs['tag_moved'] = '1' + with repo.vfs('changes/tags.changes', 'w', + atomictemp=True) as changesfile: + # note: we do not register the file to the transaction + # because we needs it to still exist on the transaction + # is close (for txnclose hooks) + tagsmod.writediff(changesfile, changes) def validate(tr2): """will run pre-closing hooks""" # XXX the transaction API is a bit lacking here so we take a hacky