Mercurial > hg
comparison hgext/mq.py @ 9145:6b03f93b8ff3
localrepo: factor _findtags() out of tags() (issue548).
This makes in-memory caching the sole responsibility of localrepo,
eliminating some localrepo code that was duplicated in mq and
bookmarks.
author | Greg Ward <greg-hg@gerg.ca> |
---|---|
date | Thu, 16 Jul 2009 10:39:41 -0400 |
parents | ac3f1e6696eb |
children | b67adc2daa15 |
comparison
equal
deleted
inserted
replaced
9144:ad72e3b08bc0 | 9145:6b03f93b8ff3 |
---|---|
2413 def push(self, remote, force=False, revs=None): | 2413 def push(self, remote, force=False, revs=None): |
2414 if self.mq.applied and not force and not revs: | 2414 if self.mq.applied and not force and not revs: |
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 |
2449 if not q.applied: | 2448 if not q.applied: |
2450 return super(mqrepo, self)._branchtags(partial, lrev) | 2449 return super(mqrepo, self)._branchtags(partial, lrev) |