Hi. I tried mercurial-plugin-1.0 with mercurial-2.9, and get following 
error.

    AttributeError: 'localrepository' object has no attribute 'branchtags'

Because branchtags method deleated in mercurial-2.9.
see http://selenic.com/hg/rev/4274eda143cb.

Same problem will also occur in 0.12 branch.

This is a monky patch.

# HG changeset patch
# User Takumi IINO <[email protected]>
# Date 1391665445 -32400
#      Thu Feb 06 14:44:05 2014 +0900
# Branch 1.0
# Node ID be9d923c8817ef46685d224e933cf8d476fcd505
# Parent  8df754d9b36a8bd5c7385f8ebebbf0069d2088d6
add helper method that deleted in mercurial-2.9

diff -r 8df754d9b36a -r be9d923c8817 tracext/hg/backend.py
--- a/tracext/hg/backend.py     Wed Oct 17 20:31:01 2012 +0200
+++ 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():

-- 
You received this message because you are subscribed to the Google Groups "Trac 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/trac-dev.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to