[PATCH 7 of 7 bm-refactor V3] bookmarks: factor method _printer out of for loop in printbookmarks

Martin von Zweigbergk martinvonz at google.com
Fri Jun 23 14:55:02 EDT 2017


On Fri, Jun 23, 2017 at 11:33 AM, Sean Farley <sean at farley.io> wrote:
> # HG changeset patch
> # User Sean Farley <sean at farley.io>
> # Date 1498004300 25200
> #      Tue Jun 20 17:18:20 2017 -0700
> # Branch bm-refactor
> # Node ID 1e90be070c35665fb3d75657563349650cc523a1
> # Parent  5caa40d7fa1be3ff13a2e80a91234809cff5307a
> bookmarks: factor method _printer out of for loop in printbookmarks
>
> This allows even further customization via extensions for printing
> bookmarks. For example, in hg-git this would allow printing remote refs
> by just modifying the 'bmarks' parameter instead of reimplementing the
> old commands.bookmarks method.
>
> Furthermore, there is another benefit: now multiple extensions can
> chain their custom data to bookmark printing. Previously, an extension
> could have conflicting bookmark output due to which loaded first and
> overrode commands.bookmarks. Now they can all play nicely together.
>
> diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
> index 518b362..797e3c1 100644
> --- a/mercurial/bookmarks.py
> +++ b/mercurial/bookmarks.py
> @@ -765,32 +765,43 @@ def addbookmarks(repo, tr, names, rev=No
>          activate(repo, newact)
>      elif cur != tgt and newact == repo._activebookmark:
>          deactivate(repo)
>      marks.recordchange(tr)
>
> +def _printer(ui, repo, bmarks, **opts):

nit: This actually prints the bookmarks. The name made me think it
would return an object that could be used for printing.


More information about the Mercurial-devel mailing list