[PATCH 2 of 4 V2] destutil: allow to specify an explicit source for the merge
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Sun Feb 14 11:40:00 EST 2016
On 02/14/2016 04:37 PM, Martin von Zweigbergk wrote:
>
>
> On Sun, Feb 14, 2016, 07:38 Pierre-Yves David
> <pierre-yves.david at ens-lyon.org <mailto:pierre-yves.david at ens-lyon.org>>
> wrote:
>
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david at fb.com
> <mailto:pierre-yves.david at fb.com>>
> # Date 1454956349 -3600
> # Mon Feb 08 19:32:29 2016 +0100
> # Node ID 6b38d0c01aeca0d3c2a2bbf3a0eadd04e37803e8
> # Parent 0ffdd65816fcde6f970e60830fad8aa0bc67b970
> # EXP-Topic destination
> # Available At http://hg.netv6.net/marmoute-wip/mercurial/
> # hg pull http://hg.netv6.net/marmoute-wip/mercurial/
> -r 6b38d0c01aec
> destutil: allow to specify an explicit source for the merge
>
> We can now specify from where the merge is performed. The
> experimental revset
> is updated to take revisions as argument, allowing to test the feature.
>
> This will become very useful for pick the 'rebase' default
> destination. For this
> reason, we also exclude all descendants from the rebased set from
> the candidate
> destinations. This descendants exclusion was not necessary for merge
> as default
> destination would not be picked from anything else than a head.
>
> I'm not super excited with the current error messages, but I would
> prefer to
> delay an overall messages rework once 'hg rebase' is done getting a
> default
> destination aligned with 'hg merge'.
>
> diff --git a/mercurial/destutil.py b/mercurial/destutil.py
> --- a/mercurial/destutil.py
> +++ b/mercurial/destutil.py
> @@ -183,13 +183,23 @@ msgdestmerge = {
> 'notatheads':
> {'merge':
> (_('working directory not at a head revision'),
> _("use 'hg update' or merge with an explicit revision"))
> },
> + 'emptysourceset':
> + {'merge':
> + (_('source set is empty'),
> + None)
> + },
> + 'multiplebranchessourceset':
> + {'merge':
> + (_('source set is rooted in multiple branches'),
> + None)
> + },
> }
>
> -def _destmergebook(repo, action='merge'):
> +def _destmergebook(repo, action='merge', sourceset=None):
> """find merge destination in the active bookmark case"""
> node = None
> bmheads = repo.bookmarkheads(repo._activebookmark)
> curhead = repo[repo._activebookmark].node()
> if len(bmheads) == 2:
> @@ -204,30 +214,42 @@ def _destmergebook(repo, action='merge')
> msg, hint = msgdestmerge['nootherbookmarks'][action]
> raise error.Abort(msg, hint=hint)
> assert node is not None
> return node
>
> -def _destmergebranch(repo, action='merge'):
> +def _destmergebranch(repo, action='merge', sourceset=None):
> """find merge destination based on branch heads"""
> node = None
> - parent = repo.dirstate.p1()
> - branch = repo.dirstate.branch()
> +
> + if sourceset is None:
> + sourceset = [repo[repo.dirstate.p1()].rev()]
> + branch = repo.dirstate.branch()
> + elif not sourceset:
> + msg, hint = msgdestmerge['emptysourceset'][action]
> + raise error.Abort(msg, hint=hint)
> + else:
> + branch = None
> + for ctx in repo.set('roots(%ld::%ld)', sourceset, sourceset):
>
>
> Can this ever be different from just
> repo.set('roots(%ld)', sourceset)? Typo? If it really is different,
> perhaps it deserves a comment about what it does?
If the sourceset is non-continuous (some hole in an ancestry line) roots
would not return the roots of the planned rebase.
Mostly being safe as the function "contract" does not requires it.
--
Pierre-Yves David
More information about the Mercurial-devel
mailing list