changeset 26723:52d08a93de1f

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.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Thu, 15 Oct 2015 02:15:43 +0100
parents 6cd643a1d32c
children 7fc759c0c430
files mercurial/destutil.py
diffstat 1 files changed, 20 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/destutil.py	Thu Oct 15 02:12:55 2015 +0100
+++ b/mercurial/destutil.py	Thu Oct 15 02:15:43 2015 +0100
@@ -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