comparison mercurial/tagmerge.py @ 33421:d1aa3fee4ca4

tagmerge: use workingfilectx to write merged tags This function already does an excellent job of reading from context objects; we simply need to change the single write call to eliminate all uses of the wvfs. As with past changes, the effect should be a no-op but opens the door to in-memory merge later by using different context objects.
author Phil Cohen <phillco@fb.com>
date Tue, 11 Jul 2017 16:48:15 -0700
parents 5d92107dfb9b
children 66250de006c6
comparison
equal deleted inserted replaced
33420:e80041832eec 33421:d1aa3fee4ca4
134 groupednodes[-1][1].append(hexnode) 134 groupednodes[-1][1].append(hexnode)
135 if linenum is not None: 135 if linenum is not None:
136 prevlinenum = linenum 136 prevlinenum = linenum
137 return groupednodes 137 return groupednodes
138 138
139 def writemergedtags(repo, mergedtags): 139 def writemergedtags(fcd, mergedtags):
140 ''' 140 '''
141 write the merged tags while trying to minimize the diff to the first parent 141 write the merged tags while trying to minimize the diff to the first parent
142 142
143 This function uses the ordering info stored on the merged tags dict to 143 This function uses the ordering info stored on the merged tags dict to
144 generate an .hgtags file which is correct (in the sense that its contents 144 generate an .hgtags file which is correct (in the sense that its contents
167 finaltags.sort(key=operator.itemgetter(0)) 167 finaltags.sort(key=operator.itemgetter(0))
168 168
169 # finally we can join the sorted groups to get the final contents of the 169 # finally we can join the sorted groups to get the final contents of the
170 # merged .hgtags file, and then write it to disk 170 # merged .hgtags file, and then write it to disk
171 mergedtagstring = '\n'.join([tags for rank, tags in finaltags if tags]) 171 mergedtagstring = '\n'.join([tags for rank, tags in finaltags if tags])
172 fp = repo.wvfs('.hgtags', 'wb') 172 fcd.write(mergedtagstring + '\n', fcd.flags())
173 fp.write(mergedtagstring + '\n')
174 fp.close()
175 173
176 def singletagmerge(p1nodes, p2nodes): 174 def singletagmerge(p1nodes, p2nodes):
177 ''' 175 '''
178 merge the nodes corresponding to a single tag 176 merge the nodes corresponding to a single tag
179 177
266 ui.warn(_('automatic .hgtags merge failed\n' 264 ui.warn(_('automatic .hgtags merge failed\n'
267 'the following %d tags are in conflict: %s\n') 265 'the following %d tags are in conflict: %s\n')
268 % (numconflicts, ', '.join(sorted(conflictedtags)))) 266 % (numconflicts, ', '.join(sorted(conflictedtags))))
269 return True, 1 267 return True, 1
270 268
271 writemergedtags(repo, mergedtags) 269 writemergedtags(fcd, mergedtags)
272 ui.note(_('.hgtags merged successfully\n')) 270 ui.note(_('.hgtags merged successfully\n'))
273 return False, 0 271 return False, 0
274 272