diff mercurial/destutil.py @ 26641:5c57d01fe64e

destupdate: also include bookmark related logic For the same reason, we move the bookmark related update logic into the 'destupdate' function. This requires to extend the returns of the function to include the bookmark that needs to move (more or less) and the bookmark to activate at the end of the function. See function documentation for details on this returns.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Tue, 29 Sep 2015 01:03:26 -0700
parents ae5f7be2b4ab
children 634666c48b7d
line wrap: on
line diff
--- a/mercurial/destutil.py	Tue Oct 13 10:57:54 2015 -0700
+++ b/mercurial/destutil.py	Tue Sep 29 01:03:26 2015 -0700
@@ -7,25 +7,39 @@
 
 from .i18n import _
 from . import (
+    bookmarks,
     error,
     obsolete,
 )
 
 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.
     """
-    # Here is where we should consider bookmarks, divergent bookmarks, and tip
-    # of current branch; but currently we are only checking the branch tips.
     node = None
     wc = repo[None]
     p1 = wc.p1()
-    try:
-        node = repo.branchtip(wc.branch())
-    except error.RepoLookupError:
-        if wc.branch() == 'default': # no default branch!
-            node = repo.lookup('tip') # update to tip
-        else:
-            raise error.Abort(_("branch %s not found") % wc.branch())
+    activemark = 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())
+        except error.RepoLookupError:
+            if wc.branch() == 'default': # no default branch!
+                node = repo.lookup('tip') # update to tip
+            else:
+                raise error.Abort(_("branch %s not found") % wc.branch())
 
     if p1.obsolete() and not p1.children():
         # allow updating to successors
@@ -76,4 +90,4 @@
                     hint = _("merge or update --check to force update")
                     raise error.Abort(msg, hint=hint)
 
-    return rev
+    return rev, movemark, activemark