diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -3013,7 +3013,10 @@ output = [hexrev] fm.data(id=hexrev) + bmscache = [None] def getbms(): + if bmscache[0] is not None: + return bmscache[0] bms = [] if 'bookmarks' in peer.listkeys('namespaces'): @@ -3021,19 +3024,20 @@ bms = [bm for bm, bmr in peer.listkeys('bookmarks').iteritems() if bmr == hexremoterev] - return sorted(bms) - - bms = getbms() + bmscache[0] = sorted(bms) + return bmscache[0] + if bookmarks: - output.extend(bms) + output.extend(getbms()) elif default and not ui.quiet: # multiple bookmarks for a single parent separated by '/' - bm = '/'.join(bms) + bm = '/'.join(getbms()) if bm: output.append(bm) fm.data(node=hex(remoterev)) - fm.data(bookmarks=fm.formatlist(bms, name='bookmark')) + if 'bookmarks' in fm.datahint(): + fm.data(bookmarks=fm.formatlist(getbms(), name='bookmark')) else: if rev: repo = scmutil.unhidehashlikerevs(repo, [rev], 'nowarn')