Mercurial > hg > mercurial-crew-with-dirclash
comparison hgext/mq.py @ 2723:04d9b31faeca
mq: do not hold a reference to repo in tags override
Instead, replace repo's class object with a subclass.
author | Brendan Cully <brendan@kublai.com> |
---|---|
date | Fri, 28 Jul 2006 13:08:21 -0700 |
parents | c91ca61c8953 |
children | 9c41ae1908c7 |
comparison
equal
deleted
inserted
replaced
2722:10e95059ffd7 | 2723:04d9b31faeca |
---|---|
1386 """print the version number""" | 1386 """print the version number""" |
1387 ui.write("mq version %s\n" % versionstr) | 1387 ui.write("mq version %s\n" % versionstr) |
1388 return 0 | 1388 return 0 |
1389 | 1389 |
1390 def reposetup(ui, repo): | 1390 def reposetup(ui, repo): |
1391 class MqRepo(repo.__class__): | |
1392 def tags(self): | |
1393 if self.tagscache: | |
1394 return self.tagscache | |
1395 | |
1396 tagscache = super(self.__class__, self).tags() | |
1397 | |
1398 q = repomap[repo] | |
1399 if not q.applied: | |
1400 return tagscache | |
1401 | |
1402 mqtags = [patch.split(':') for patch in q.applied] | |
1403 mqtags.append((mqtags[-1][0], 'qtip')) | |
1404 mqtags.append((mqtags[0][0], 'qbase')) | |
1405 for patch in mqtags: | |
1406 if patch[1] in tagscache: | |
1407 self.ui.warn('Tag %s overrides mq patch of the same name\n' % patch[1]) | |
1408 else: | |
1409 tagscache[patch[1]] = revlog.bin(patch[0]) | |
1410 | |
1411 return tagscache | |
1412 | |
1413 repo.__class__ = MqRepo | |
1391 repomap[repo] = queue(ui, repo.join("")) | 1414 repomap[repo] = queue(ui, repo.join("")) |
1392 oldtags = repo.tags | |
1393 | |
1394 def qtags(): | |
1395 if repo.tagscache: | |
1396 return repo.tagscache | |
1397 | |
1398 tagscache = oldtags() | |
1399 | |
1400 q = repomap[repo] | |
1401 if len(q.applied) == 0: | |
1402 return tagscache | |
1403 | |
1404 mqtags = [patch.split(':') for patch in q.applied] | |
1405 mqtags.append((mqtags[-1][0], 'qtip')) | |
1406 mqtags.append((mqtags[0][0], 'qbase')) | |
1407 for patch in mqtags: | |
1408 if patch[1] in tagscache: | |
1409 repo.ui.warn('Tag %s overrides mq patch of the same name\n' % patch[1]) | |
1410 else: | |
1411 tagscache[patch[1]] = revlog.bin(patch[0]) | |
1412 | |
1413 return tagscache | |
1414 | |
1415 repo.tags = qtags | |
1416 | 1415 |
1417 cmdtable = { | 1416 cmdtable = { |
1418 "qapplied": (applied, [], 'hg qapplied [PATCH]'), | 1417 "qapplied": (applied, [], 'hg qapplied [PATCH]'), |
1419 "qclone": (clone, | 1418 "qclone": (clone, |
1420 [('', 'pull', None, _('use pull protocol to copy metadata')), | 1419 [('', 'pull', None, _('use pull protocol to copy metadata')), |