[PATCH 2 of 2 evolve-ext:stable] evolve: active bookmark should move when using prev/next (#37)

Pierre-Yves David pierre-yves.david at ens-lyon.org
Thu Mar 27 13:27:14 CDT 2014



On 03/26/2014 04:48 PM, Olle Lundberg wrote:
> # HG changeset patch
> # User Olle Lundberg <geek at nerd.sh>
> # Date 1395874725 -3600
> #      Wed Mar 26 23:58:45 2014 +0100
> # Branch stable
> # Node ID 02d88a51cdb9e5d2dbcad01a721fc8cff51c7425
> # Parent  37c58378ad6bd3b82905f2aec3a6658a1242d3ee
> evolve: active bookmark should move when using prev/next (#37)
>
> This patch adds a new default argument to _bookmarksupdater that
> controls whether we move inactive bookmarks for a current node or
> not. This change does not break existing usage, but will allow us
> to move active bookmarks when we traverse the history with previous
> and next.
>
> The #37 references the bitbucket issue for mutable-history, that
> can be found here:
> https://bitbucket.org/marmoute/mutable-history/issue/37/
>
> diff --git a/hgext/evolve.py b/hgext/evolve.py
> --- a/hgext/evolve.py
> +++ b/hgext/evolve.py
> @@ -786,21 +786,23 @@
>       except util.Abort:
>           # Invalidate the previous setparents
>           repo.dirstate.invalidate()
>           raise
>
> -def _bookmarksupdater(repo, oldid):
> +def _bookmarksupdater(repo, oldid, moveinactive=True):
>       """Return a callable update(newid) updating the current bookmark
>       and bookmarks bound to oldid to newid.
>       """
>       bm = bookmarks.readcurrent(repo)
>       def updatebookmarks(newid):
>           dirty = False
>           if bm:
>               repo._bookmarks[bm] = newid
>               dirty = True
> -        oldbookmarks = repo.nodebookmarks(oldid)
> +        oldbookmarks = None
> +        if moveinactive:
> +            oldbookmarks = repo.nodebookmarks(oldid)
>           if oldbookmarks:
>               for b in oldbookmarks:
>                   repo._bookmarks[b] = newid
>               dirty = True
>           if dirty:

I'm not sure this belong to _bookmarksupdater, the function is more 
intended to update bookmark afater a rewriting, ho just letting the 
active bookmark follow the current position.

> @@ -1281,11 +1283,14 @@
>
>       parents = wparents[0].parents()
>       displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate})
>       if len(parents) == 1:
>           p = parents[0]
> +        bmupdate = _bookmarksupdater(repo, wparents[0].node(),
> +                                     moveinactive=False)
>           hg.update(repo, p.rev())
> +        bmupdate(p.node())
>           displayer.show(p)
>           return 0
>       else:
>           for p in parents:
>               displayer.show(p)
> @@ -1307,11 +1312,14 @@
>       if not children:
>           ui.warn(_('no non-obsolete children\n'))
>           return 1
>       if len(children) == 1:
>           c = children[0]
> +        bmupdate = _bookmarksupdater(repo, wparents[0].node(),
> +                                     moveinactive=False)
>           hg.update(repo, c.rev())
> +        bmupdate(c.node())
>           displayer.show(c)
>           return 0
>       else:
>           for c in children:
>               displayer.show(c)
> diff --git a/tests/test-bookmarks.t b/tests/test-bookmarks.t
> new file mode 100644
> --- /dev/null
> +++ b/tests/test-bookmarks.t


Thanks for the extensive testing. But they need a bit more documentation 
to be maintable.

Also consider a custom log template for more compact output.


-- 
Pierre-Yves David


More information about the Mercurial-devel mailing list