diff --git a/hgext/remotenames.py b/hgext/remotenames.py --- a/hgext/remotenames.py +++ b/hgext/remotenames.py @@ -230,7 +230,7 @@ class remotenames(object): self._nodetohoists.setdefault(node[0], []).append(name) return self._nodetohoists -def wrapprintbookmarks(orig, ui, repo, bmarks, **opts): +def wrapprintbookmarks(orig, ui, repo, fm, bmarks): if 'remotebookmarks' not in repo.names: return ns = repo.names['remotebookmarks'] @@ -243,7 +243,7 @@ def wrapprintbookmarks(orig, ui, repo, b bmarks[name] = (node, ' ', '') - return orig(ui, repo, bmarks, **opts) + return orig(ui, repo, fm, bmarks) def extsetup(ui): extensions.wrapfunction(bookmarks, '_printbookmarks', wrapprintbookmarks) diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py --- a/mercurial/bookmarks.py +++ b/mercurial/bookmarks.py @@ -915,14 +915,12 @@ def addbookmarks(repo, tr, names, rev=No elif cur != tgt and newact == repo._activebookmark: deactivate(repo) -def _printbookmarks(ui, repo, bmarks, **opts): +def _printbookmarks(ui, repo, fm, bmarks): """private method to print bookmarks Provides a way for extensions to control how bookmarks are printed (e.g. prepend or postpend names) """ - opts = pycompat.byteskwargs(opts) - fm = ui.formatter('bookmarks', opts) hexfn = fm.hexfunc if len(bmarks) == 0 and fm.isplain(): ui.status(_("no bookmarks set\n")) @@ -937,10 +935,9 @@ def _printbookmarks(ui, repo, bmarks, ** repo.changelog.rev(n), hexfn(n), label=label) fm.data(active=(activebookmarklabel in label)) fm.plain('\n') - fm.end() -def printbookmarks(ui, repo, **opts): - """print bookmarks to a formatter +def printbookmarks(ui, repo, fm): + """print bookmarks by the given formatter Provides a way for extensions to control how bookmarks are printed. """ @@ -954,7 +951,7 @@ def printbookmarks(ui, repo, **opts): prefix, label = ' ', '' bmarks[bmark] = (n, prefix, label) - _printbookmarks(ui, repo, bmarks, **opts) + _printbookmarks(ui, repo, fm, bmarks) def preparehookargs(name, old, new): if new is None: diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -1011,7 +1011,9 @@ def bookmark(ui, repo, *names, **opts): return 1 ui.write("%s\n" % book, label=bookmarks.activebookmarklabel) else: # show bookmarks - bookmarks.printbookmarks(ui, repo, **opts) + opts = pycompat.byteskwargs(opts) + with ui.formatter('bookmarks', opts) as fm: + bookmarks.printbookmarks(ui, repo, fm) @command('branch', [('f', 'force', None,