changeset 26724:7fc759c0c430

destupdate: extract logic based on bookmarks 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.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Thu, 15 Oct 2015 02:27:30 +0100
parents 52d08a93de1f
children bde739aced83
files mercurial/destutil.py
diffstat 1 files changed, 11 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/destutil.py	Thu Oct 15 02:15:43 2015 +0100
+++ b/mercurial/destutil.py	Thu Oct 15 02:27:30 2015 +0100
@@ -76,6 +76,15 @@
                 movemark = repo['.'].node()
     return node, movemark, None
 
+def _destupdatebook(repo, clean, check):
+    """decide on an update destination from active bookmark"""
+    # we also move the active bookmark, if any
+    activemark = None
+    node, movemark = bookmarks.calculateupdate(repo.ui, repo, None)
+    if node is not None:
+        activemark = node
+    return node, movemark, activemark
+
 def destupdate(repo, clean=False, check=False):
     """destination for bare update operation
 
@@ -91,13 +100,10 @@
     movemark = activemark = None
 
     node, movemark, activemark = _destupdateobs(repo, clean, check)
+    if node is None:
+        node, movemark, activemark = _destupdatebook(repo, clean, check)
 
     if node is None:
-        # we also move the active bookmark, if any
-        node, movemark = bookmarks.calculateupdate(repo.ui, repo, None)
-        if node is not None:
-            activemark = node
-
         if node is None:
             try:
                 node = repo.branchtip(wc.branch())