Mercurial > hg > mercurial-source
comparison mercurial/tags.py @ 32775: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 (2017-03-28) |
parents | fe9c4d614600 |
children | 4f3f08262eb4 |
comparison
equal
deleted
inserted
replaced
32774:fe9c4d614600 | 32775:e6e1884df298 |
---|---|
126 old = _nulltonone(old) | 126 old = _nulltonone(old) |
127 if old is not None: | 127 if old is not None: |
128 entries.append((tag, old, None)) | 128 entries.append((tag, old, None)) |
129 entries.sort() | 129 entries.sort() |
130 return entries | 130 return entries |
131 | |
132 def writediff(fp, difflist): | |
133 """write tags diff information to a file. | |
134 | |
135 Data are stored with a line based format: | |
136 | |
137 <action> <hex-node> <tag-name>\n | |
138 | |
139 Action are defined as follow: | |
140 -R tag is removed, | |
141 +A tag is added, | |
142 -M tag is moved (old value), | |
143 +M tag is moved (new value), | |
144 | |
145 Example: | |
146 | |
147 +A 875517b4806a848f942811a315a5bce30804ae85 t5 | |
148 | |
149 See documentation of difftags output for details about the input. | |
150 """ | |
151 add = '+A %s %s\n' | |
152 remove = '-R %s %s\n' | |
153 updateold = '-M %s %s\n' | |
154 updatenew = '+M %s %s\n' | |
155 for tag, old, new in difflist: | |
156 # translate to hex | |
157 if old is not None: | |
158 old = hex(old) | |
159 if new is not None: | |
160 new = hex(new) | |
161 # write to file | |
162 if old is None: | |
163 fp.write(add % (new, tag)) | |
164 elif new is None: | |
165 fp.write(remove % (old, tag)) | |
166 else: | |
167 fp.write(updateold % (old, tag)) | |
168 fp.write(updatenew % (new, tag)) | |
131 | 169 |
132 def findglobaltags(ui, repo): | 170 def findglobaltags(ui, repo): |
133 '''Find global tags in a repo: return a tagsmap | 171 '''Find global tags in a repo: return a tagsmap |
134 | 172 |
135 tagsmap: tag name to (node, hist) 2-tuples. | 173 tagsmap: tag name to (node, hist) 2-tuples. |