# HG changeset patch # User Christian Boos # Date 1350498661 -7200 # Node ID 8df754d9b36a8bd5c7385f8ebebbf0069d2088d6 # Parent 7a8fec72f18e4654bf31c302a1ec380b8d6f9d5a #10527: not all Mercurial versions we support have bookmarks (closes #10908) diff -r 7a8fec72f18e -r 8df754d9b36a tracext/hg/backend.py --- 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():