Show More
@@ -1028,7 +1028,8 b' class localrepository(object):' | |||||
1028 | newfnodes = tagsmod.fnoderevs(repo.ui, repo, newheads) |
|
1028 | newfnodes = tagsmod.fnoderevs(repo.ui, repo, newheads) | |
1029 | # notes: we compare lists here. |
|
1029 | # notes: we compare lists here. | |
1030 | # As we do it only once buiding set would not be cheaper |
|
1030 | # As we do it only once buiding set would not be cheaper | |
1031 |
if oldfnodes |
|
1031 | changes = tagsmod.difftags(repo.ui, repo, oldfnodes, newfnodes) | |
|
1032 | if changes: | |||
1032 | tr2.hookargs['tag_moved'] = '1' |
|
1033 | tr2.hookargs['tag_moved'] = '1' | |
1033 | def validate(tr2): |
|
1034 | def validate(tr2): | |
1034 | """will run pre-closing hooks""" |
|
1035 | """will run pre-closing hooks""" |
@@ -90,6 +90,45 b' def fnoderevs(ui, repo, revs):' | |||||
90 | fnodes = _filterfnodes(fnodes, nodes) |
|
90 | fnodes = _filterfnodes(fnodes, nodes) | |
91 | return fnodes |
|
91 | return fnodes | |
92 |
|
92 | |||
|
93 | def _nulltonone(value): | |||
|
94 | """convert nullid to None | |||
|
95 | ||||
|
96 | For tag value, nullid means "deleted". This small utility function helps | |||
|
97 | translating that to None.""" | |||
|
98 | if value == nullid: | |||
|
99 | return None | |||
|
100 | return value | |||
|
101 | ||||
|
102 | def difftags(ui, repo, oldfnodes, newfnodes): | |||
|
103 | """list differences between tags expressed in two set of file-nodes | |||
|
104 | ||||
|
105 | The list contains entries in the form: (tagname, oldvalue, new value). | |||
|
106 | None is used to expressed missing value: | |||
|
107 | ('foo', None, 'abcd') is a new tag, | |||
|
108 | ('bar', 'ef01', None) is a deletion, | |||
|
109 | ('baz', 'abcd', 'ef01') is a tag movement. | |||
|
110 | """ | |||
|
111 | if oldfnodes == newfnodes: | |||
|
112 | return [] | |||
|
113 | oldtags = _tagsfromfnodes(ui, repo, oldfnodes) | |||
|
114 | newtags = _tagsfromfnodes(ui, repo, newfnodes) | |||
|
115 | ||||
|
116 | # list of (tag, old, new): None means missing | |||
|
117 | entries = [] | |||
|
118 | for tag, (new, __) in newtags.items(): | |||
|
119 | new = _nulltonone(new) | |||
|
120 | old, __ = oldtags.pop(tag, (None, None)) | |||
|
121 | old = _nulltonone(old) | |||
|
122 | if old != new: | |||
|
123 | entries.append((tag, old, new)) | |||
|
124 | # handle deleted tags | |||
|
125 | for tag, (old, __) in oldtags.items(): | |||
|
126 | old = _nulltonone(old) | |||
|
127 | if old is not None: | |||
|
128 | entries.append((tag, old, None)) | |||
|
129 | entries.sort() | |||
|
130 | return entries | |||
|
131 | ||||
93 | def findglobaltags(ui, repo): |
|
132 | def findglobaltags(ui, repo): | |
94 | '''Find global tags in a repo: return a tagsmap |
|
133 | '''Find global tags in a repo: return a tagsmap | |
95 |
|
134 |
@@ -230,7 +230,6 b" doesn't end with EOL" | |||||
230 | > f = file('.hgtags', 'w'); f.write(last); f.close() |
|
230 | > f = file('.hgtags', 'w'); f.write(last); f.close() | |
231 | > EOF |
|
231 | > EOF | |
232 | $ hg ci -m'broken manual edit of .hgtags' |
|
232 | $ hg ci -m'broken manual edit of .hgtags' | |
233 | hook: tag changes detected |
|
|||
234 |
$ cat .hgtags |
|
233 | $ cat .hgtags; echo | |
235 | acb14030fe0a21b60322c440ad2d20cf7685a376 foobar |
|
234 | acb14030fe0a21b60322c440ad2d20cf7685a376 foobar | |
236 | $ hg tag newline |
|
235 | $ hg tag newline | |
@@ -635,7 +634,6 b' handle the loss of tags' | |||||
635 | $ printf '' > .hgtags |
|
634 | $ printf '' > .hgtags | |
636 | $ hg commit -m 'delete all tags' |
|
635 | $ hg commit -m 'delete all tags' | |
637 | created new head |
|
636 | created new head | |
638 | hook: tag changes detected |
|
|||
639 | $ hg log -r 'max(t7::)' |
|
637 | $ hg log -r 'max(t7::)' | |
640 | changeset: 17:ffe462b50880 |
|
638 | changeset: 17:ffe462b50880 | |
641 | user: test |
|
639 | user: test |
General Comments 0
You need to be logged in to leave comments.
Login now