equal
deleted
inserted
replaced
71 # - put blocks whose nodes come all from p2 first |
71 # - put blocks whose nodes come all from p2 first |
72 # - write the tag blocks in the sorted order |
72 # - write the tag blocks in the sorted order |
73 |
73 |
74 from __future__ import absolute_import |
74 from __future__ import absolute_import |
75 |
75 |
76 import operator |
|
77 |
|
78 from .i18n import _ |
76 from .i18n import _ |
79 from .node import ( |
77 from .node import ( |
80 hex, |
78 hex, |
81 nullid, |
79 nullid, |
82 ) |
80 ) |
162 |
160 |
163 # the tag groups are linked to a "position" that can be used to sort them |
161 # the tag groups are linked to a "position" that can be used to sort them |
164 # before writing them |
162 # before writing them |
165 # the position is calculated to ensure that the diff of the merged .hgtags |
163 # the position is calculated to ensure that the diff of the merged .hgtags |
166 # file to the first parent's .hgtags file is as small as possible |
164 # file to the first parent's .hgtags file is as small as possible |
167 finaltags.sort(key=operator.itemgetter(0)) |
165 finaltags.sort(key=lambda x: -1 if x[0] is None else x[0]) |
168 |
166 |
169 # finally we can join the sorted groups to get the final contents of the |
167 # finally we can join the sorted groups to get the final contents of the |
170 # merged .hgtags file, and then write it to disk |
168 # merged .hgtags file, and then write it to disk |
171 mergedtagstring = '\n'.join([tags for rank, tags in finaltags if tags]) |
169 mergedtagstring = '\n'.join([tags for rank, tags in finaltags if tags]) |
172 fcd.write(mergedtagstring + '\n', fcd.flags()) |
170 fcd.write(mergedtagstring + '\n', fcd.flags()) |