changeset 24:8df754d9b36a 1.0

#10527: not all Mercurial versions we support have bookmarks (closes #10908)
author Christian Boos <cboos@edgewall.org>
date Wed, 17 Oct 2012 20:31:01 +0200
parents 7a8fec72f18e
children 546d3f11ac7a
files tracext/hg/backend.py
diffstat 1 files changed, 12 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/tracext/hg/backend.py	Mon Sep 17 21:09:36 2012 +0200
+++ b/tracext/hg/backend.py	Wed Oct 17 20:31:01 2012 +0200
@@ -109,7 +109,8 @@
     else:
         from mercurial.scmutil import match
 
-    
+    has_bookmarks = None
+
 except ImportError, e:
     hg_import_error = e
     ui = object
@@ -144,6 +145,15 @@
     if check(s):
         return s
 
+def get_bookmarks(ctx):
+    global has_bookmarks
+    if has_bookmarks:
+        return ctx.bookmarks()
+    if has_bookmarks is None:
+        has_bookmarks = hasattr(ctx, 'bookmarks')
+        if has_bookmarks:
+            return get_bookmarks(ctx)
+    return ()
         
 class trac_ui(ui):
     # Note: will be dropped in 0.13, see MercurialConnector._setup_ui
@@ -1220,7 +1230,7 @@
         tags = self.get_tags()
         if len(tags):
             properties['hg-Tags'] = (self.repos, tags) 
-        bookmarks = self.ctx.bookmarks()
+        bookmarks = get_bookmarks(self.ctx)
         if len(bookmarks):
             properties['hg-Bookmarks'] = (self.repos, bookmarks) 
         for k, v in self.ctx.extra().iteritems():