diff mercurial/commands.py @ 19523:f37b5a17e6a0 stable 2.7

bookmarks: pull --update updates to active bookmark if it moved (issue4007) This makes `hg pull --update` behave the same wrt the active bookmark as `hg pull && hg update` does as of 2096e025a728. A helper function, bookmarks.calculateupdate, is added to prevent code duplication between postincoming and update.
author Kevin Bullock <kbullock@ringworld.org>
date Thu, 01 Aug 2013 21:43:14 -0500
parents 607191a45f8c
children f959b60e3025
line wrap: on
line diff
--- a/mercurial/commands.py	Thu Aug 01 20:06:00 2013 -0500
+++ b/mercurial/commands.py	Thu Aug 01 21:43:14 2013 -0500
@@ -4520,7 +4520,7 @@
     if modheads == 0:
         return
     if optupdate:
-        movemarkfrom = repo['.'].node()
+        checkout, movemarkfrom = bookmarks.calculateupdate(ui, repo, checkout)
         try:
             ret = hg.update(repo, checkout)
         except util.Abort, inst:
@@ -5829,14 +5829,7 @@
     cmdutil.clearunfinished(repo)
 
     # with no argument, we also move the current bookmark, if any
-    movemarkfrom = None
-    if rev is None:
-        curmark = repo._bookmarkcurrent
-        if bookmarks.iscurrent(repo):
-            movemarkfrom = repo['.'].node()
-        elif curmark:
-            ui.status(_("updating to active bookmark %s\n") % curmark)
-            rev = curmark
+    rev, movemarkfrom = bookmarks.calculateupdate(ui, repo, rev)
 
     # if we defined a bookmark, we have to remember the original bookmark name
     brev = rev