##// END OF EJS Templates
localrepo: factor _findtags() out of tags() (issue548)....
Greg Ward -
r9145:6b03f93b default
parent child Browse files
Show More
@@ -293,14 +293,11 b' def reposetup(ui, repo):'
293 write(self, marks)
293 write(self, marks)
294 return result
294 return result
295
295
296 def tags(self):
296 def _findtags(self):
297 """Merge bookmarks with normal tags"""
297 """Merge bookmarks with normal tags"""
298 if self.tagscache:
298 (tags, tagtypes) = super(bookmark_repo, self)._findtags()
299 return self.tagscache
299 tags.update(parse(self))
300
300 return (tags, tagtypes)
301 tagscache = super(bookmark_repo, self).tags()
302 tagscache.update(parse(self))
303 return tagscache
304
301
305 repo.__class__ = bookmark_repo
302 repo.__class__ = bookmark_repo
306
303
@@ -2415,34 +2415,33 b' def reposetup(ui, repo):'
2415 raise util.Abort(_('source has mq patches applied'))
2415 raise util.Abort(_('source has mq patches applied'))
2416 return super(mqrepo, self).push(remote, force, revs)
2416 return super(mqrepo, self).push(remote, force, revs)
2417
2417
2418 def tags(self):
2418 def _findtags(self):
2419 if self.tagscache:
2419 '''augment tags from base class with patch tags'''
2420 return self.tagscache
2420 result = super(mqrepo, self)._findtags()
2421
2422 tagscache = super(mqrepo, self).tags()
2423
2421
2424 q = self.mq
2422 q = self.mq
2425 if not q.applied:
2423 if not q.applied:
2426 return tagscache
2424 return result
2427
2425
2428 mqtags = [(bin(patch.rev), patch.name) for patch in q.applied]
2426 mqtags = [(bin(patch.rev), patch.name) for patch in q.applied]
2429
2427
2430 if mqtags[-1][0] not in self.changelog.nodemap:
2428 if mqtags[-1][0] not in self.changelog.nodemap:
2431 self.ui.warn(_('mq status file refers to unknown node %s\n')
2429 self.ui.warn(_('mq status file refers to unknown node %s\n')
2432 % short(mqtags[-1][0]))
2430 % short(mqtags[-1][0]))
2433 return tagscache
2431 return result
2434
2432
2435 mqtags.append((mqtags[-1][0], 'qtip'))
2433 mqtags.append((mqtags[-1][0], 'qtip'))
2436 mqtags.append((mqtags[0][0], 'qbase'))
2434 mqtags.append((mqtags[0][0], 'qbase'))
2437 mqtags.append((self.changelog.parents(mqtags[0][0])[0], 'qparent'))
2435 mqtags.append((self.changelog.parents(mqtags[0][0])[0], 'qparent'))
2436 tags = result[0]
2438 for patch in mqtags:
2437 for patch in mqtags:
2439 if patch[1] in tagscache:
2438 if patch[1] in tags:
2440 self.ui.warn(_('Tag %s overrides mq patch of the same name\n')
2439 self.ui.warn(_('Tag %s overrides mq patch of the same name\n')
2441 % patch[1])
2440 % patch[1])
2442 else:
2441 else:
2443 tagscache[patch[1]] = patch[0]
2442 tags[patch[1]] = patch[0]
2444
2443
2445 return tagscache
2444 return result
2446
2445
2447 def _branchtags(self, partial, lrev):
2446 def _branchtags(self, partial, lrev):
2448 q = self.mq
2447 q = self.mq
@@ -233,8 +233,24 b' class localrepository(repo.repository):'
233
233
234 def tags(self):
234 def tags(self):
235 '''return a mapping of tag to node'''
235 '''return a mapping of tag to node'''
236 if self.tagscache:
236 if self.tagscache is None:
237 return self.tagscache
237 (self.tagscache, self._tagstypecache) = self._findtags()
238
239 return self.tagscache
240
241 def _findtags(self):
242 '''Do the hard work of finding tags. Return a pair of dicts
243 (tags, tagtypes) where tags maps tag name to node, and tagtypes
244 maps tag name to a string like \'global\' or \'local\'.
245 Subclasses or extensions are free to add their own tags, but
246 should be aware that the returned dicts will be retained for the
247 duration of the localrepo object.'''
248
249 # XXX what tagtype should subclasses/extensions use? Currently
250 # mq and bookmarks add tags, but do not set the tagtype at all.
251 # Should each extension invent its own tag type? Should there
252 # be one tagtype for all such "virtual" tags? Or is the status
253 # quo fine?
238
254
239 globaltags = {}
255 globaltags = {}
240 tagtypes = {}
256 tagtypes = {}
@@ -318,15 +334,13 b' class localrepository(repo.repository):'
318 except IOError:
334 except IOError:
319 pass
335 pass
320
336
321 self.tagscache = {}
337 tags = {}
322 self._tagstypecache = {}
323 for k, nh in globaltags.iteritems():
338 for k, nh in globaltags.iteritems():
324 n = nh[0]
339 n = nh[0]
325 if n != nullid:
340 if n != nullid:
326 self.tagscache[k] = n
341 tags[k] = n
327 self._tagstypecache[k] = tagtypes[k]
342 tags['tip'] = self.changelog.tip()
328 self.tagscache['tip'] = self.changelog.tip()
343 return (tags, tagtypes)
329 return self.tagscache
330
344
331 def tagtype(self, tagname):
345 def tagtype(self, tagname):
332 '''
346 '''
General Comments 0
You need to be logged in to leave comments. Login now