# HG changeset patch # User Pierre-Yves David # Date 1444875194 -3600 # Node ID 5b7fd48f9868ce57ae58c3d2d2366c75d82b3f2d # Parent 8e6649616699459223c41631a5897c36a1d35201 destmerge: extract logic based on bookmark into its own function One of the main goal of having consolidated destination function is to allow extension to play with this logic. We extract sub logic to make is wrapping more practical. diff -r 8e6649616699 -r 5b7fd48f9868 mercurial/destutil.py --- a/mercurial/destutil.py Thu Oct 15 03:00:09 2015 +0100 +++ b/mercurial/destutil.py Thu Oct 15 03:13:14 2015 +0100 @@ -131,23 +131,30 @@ return rev, movemark, activemark +def _destmergebook(repo): + """find merge destination in the active bookmark case""" + node = None + bmheads = repo.bookmarkheads(repo._activebookmark) + curhead = repo[repo._activebookmark].node() + if len(bmheads) == 2: + if curhead == bmheads[0]: + node = bmheads[1] + else: + node = bmheads[0] + elif len(bmheads) > 2: + raise error.Abort(_("multiple matching bookmarks to merge - " + "please merge with an explicit rev or bookmark"), + hint=_("run 'hg heads' to see all heads")) + elif len(bmheads) <= 1: + raise error.Abort(_("no matching bookmark to merge - " + "please merge with an explicit rev or bookmark"), + hint=_("run 'hg heads' to see all heads")) + assert node is not None + return node + def destmerge(repo): if repo._activebookmark: - bmheads = repo.bookmarkheads(repo._activebookmark) - curhead = repo[repo._activebookmark].node() - if len(bmheads) == 2: - if curhead == bmheads[0]: - node = bmheads[1] - else: - node = bmheads[0] - elif len(bmheads) > 2: - raise error.Abort(_("multiple matching bookmarks to merge - " - "please merge with an explicit rev or bookmark"), - hint=_("run 'hg heads' to see all heads")) - elif len(bmheads) <= 1: - raise error.Abort(_("no matching bookmark to merge - " - "please merge with an explicit rev or bookmark"), - hint=_("run 'hg heads' to see all heads")) + node = _destmergebook(repo) else: branch = repo[None].branch() bheads = repo.branchheads(branch)