# HG changeset patch # User Brendan Cully # Date 1153941724 25200 # Node ID 4e2dc5c16e61b5ba1178b3f27fc77df4c5db37ae # Parent 259acfb963d137c8436d0c9d2f6e0745e7c681c2 Add mq patch names to tagscache instead of overriding lookup. This makes mq patch names visible in hg log and hg tags. It also resolves the names only once, rather than on every lookup. diff --git a/hgext/mq.py b/hgext/mq.py --- a/hgext/mq.py +++ b/hgext/mq.py @@ -1280,28 +1280,30 @@ def version(ui, q=None): def reposetup(ui, repo): repomap[repo] = queue(ui, repo.join("")) - oldlookup = repo.lookup + oldtags = repo.tags + + def qtags(): + if repo.tagscache: + return repo.tagscache - def qlookup(key): - try: - return oldlookup(key) - except hg.RepoError: - q = repomap[repo] + tagscache = oldtags() + + q = repomap[repo] + if len(q.applied) == 0: + return tagscache - qpatchnames = { 'qtip': -1, 'qbase': 0 } - if key in qpatchnames: - if len(q.applied) == 0: - self.ui.warn('No patches applied\n') - raise - patch = q.applied[qpatchnames[key]].split(':')[0] - return revlog.bin(patch) + mqtags = [patch.split(':') for patch in q.applied] + mqtags.append((mqtags[-1][0], 'qtip')) + mqtags.append((mqtags[0][0], 'qbase')) + for patch in mqtags: + if patch[1] in tagscache: + repo.ui.warn('Tag %s overrides mq patch of the same name\n' % patch[1]) + else: + tagscache[patch[1]] = revlog.bin(patch[0]) - patch = q.isapplied(key) - if not patch: - raise - return revlog.bin(patch[1]) + return tagscache - repo.lookup = qlookup + repo.tags = qtags cmdtable = { "qapplied": (applied, [], 'hg qapplied [PATCH]'),