changeset 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 b13fdcc4e700
children 70ac5f724fbd
files mercurial/commands.py mercurial/destutil.py mercurial/merge.py
diffstat 3 files changed, 29 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Tue Oct 13 10:57:54 2015 -0700
+++ b/mercurial/commands.py	Tue Sep 29 01:03:26 2015 -0700
@@ -6573,6 +6573,7 @@
 
     Returns 0 on success, 1 if there are unresolved files.
     """
+    movemarkfrom = None
     if rev and node:
         raise error.Abort(_("please specify just one revision"))
 
@@ -6588,9 +6589,6 @@
                 raise error.Abort(_("you can't specify a revision and a date"))
             rev = cmdutil.finddate(ui, repo, date)
 
-        # with no argument, we also move the active bookmark, if any
-        rev, movemarkfrom = bookmarks.calculateupdate(ui, repo, rev)
-
         # if we defined a bookmark, we have to remember the original name
         brev = rev
         rev = scmutil.revsingle(repo, rev, rev).rev()
@@ -6602,7 +6600,8 @@
         if check:
             cmdutil.bailifchanged(repo, merge=False)
         if rev is None:
-            rev = destutil.destupdate(repo, clean=clean, check=check)
+            updata =  destutil.destupdate(repo, clean=clean, check=check)
+            rev, movemarkfrom, brev = updata
 
         repo.ui.setconfig('ui', 'forcemerge', tool, 'update')
 
--- 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
--- a/mercurial/merge.py	Tue Oct 13 10:57:54 2015 -0700
+++ b/mercurial/merge.py	Tue Sep 29 01:03:26 2015 -0700
@@ -1027,7 +1027,8 @@
             pas = [repo[ancestor]]
 
         if node is None:
-            node = repo[destutil.destupdate(repo)].node()
+            rev, _mark, _act = destutil.destupdate(repo)
+            node = repo[rev].node()
 
         overwrite = force and not branchmerge