# HG changeset patch # User Pierre-Yves David <pierre-yves.david@fb.com> # Date 1444871743 -3600 # Thu Oct 15 02:15:43 2015 +0100 # Node ID 52d08a93de1f54a23f8fb3ebb58eb8502af699c8 # Parent 6cd643a1d32c89e39db4cdf9da87781a44443516 destupdate: extract logic based on obsolescence marker in 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 --git a/mercurial/destutil.py b/mercurial/destutil.py --- a/mercurial/destutil.py +++ b/mercurial/destutil.py @@ -40,20 +40,12 @@ hint = _("merge or update --check to force update") raise error.UpdateAbort(msg, hint=hint) -def destupdate(repo, clean=False, check=False): - """destination for bare update operation - - return (rev, movemark, activemark) - - - rev: the revision to update to, - - movemark: node to move the active bookmark from - (cf bookmark.calculate update), - - activemark: a bookmark to activate at the end of the update. - """ +def _destupdateobs(repo, clean, check): + """decide of an update destination from obsolescence markers""" node = None wc = repo[None] p1 = wc.p1() - movemark = activemark = None + movemark = None if p1.obsolete() and not p1.children(): # allow updating to successors @@ -82,6 +74,23 @@ node = repo.revs('max(%ln)', successors).first() if bookmarks.isactivewdirparent(repo): movemark = repo['.'].node() + return node, movemark, None + +def destupdate(repo, clean=False, check=False): + """destination for bare update operation + + return (rev, movemark, activemark) + + - rev: the revision to update to, + - movemark: node to move the active bookmark from + (cf bookmark.calculate update), + - activemark: a bookmark to activate at the end of the update. + """ + node = None + wc = repo[None] + movemark = activemark = None + + node, movemark, activemark = _destupdateobs(repo, clean, check) if node is None: # we also move the active bookmark, if any