# HG changeset patch # User Takumi IINO # Date 1391665445 -32400 # Node ID 7aaccb9f649ae50dabede545337ae4b17aabbc67 # Parent 546d3f11ac7a1653c331f94e5c75e0e4227ecfd1 add helper method that deleted in mercurial-2.9 diff -r 546d3f11ac7a -r 7aaccb9f649a tracext/hg/backend.py --- a/tracext/hg/backend.py Thu Feb 06 19:56:06 2014 +0100 +++ b/tracext/hg/backend.py Thu Feb 06 14:44:05 2014 +0900 @@ -155,6 +155,26 @@ return get_bookmarks(ctx) return () +# Note: localrepository.branchtags deleated in mercurial-2.9. +# see http://selenic.com/hg/rev/4274eda143cb +def get_branchtags(repo): + '''return a dict where branch names map to the tipmost head of + the branch, open heads come before closed''' + + def branchtip(repo, heads): + '''return the tipmost branch head in heads''' + tip = heads[-1] + for h in reversed(heads): + if not repo[h].closesbranch(): + tip = h + break + return tip + + bt = {} + for bn, heads in repo.branchmap().iteritems(): + bt[bn] = branchtip(repo, heads) + return bt + class trac_ui(ui): # Note: will be dropped in 0.13, see MercurialConnector._setup_ui def __init__(self, *args, **kwargs): @@ -453,7 +473,7 @@ repos = rm.get_repository(reponame) if repos: if ns == 'branch': - for b, n in repos.repo.branchtags().items(): + for b, n in get_branchtags(repos.repo).items(): if repos.to_u(b) == rev: rev = repos.repo.changelog.rev(n) break @@ -616,7 +636,7 @@ # map ctx to (unicode) branch branches = {} closed_branches = {} - for b, n in self.repo.branchtags().items(): + for b, n in get_branchtags(self.repo).items(): b = self.to_u(b) ctx = self.repo[n] if 'close' in ctx.extra():