Mercurial > public > mercurial-scm > hg-stable
diff mercurial/bookmarks.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 | 741d94aa92e4 |
children | 37c0d93fb166 |
line wrap: on
line diff
--- a/mercurial/bookmarks.py Thu Aug 01 20:06:00 2013 -0500 +++ b/mercurial/bookmarks.py Thu Aug 01 21:43:14 2013 -0500 @@ -170,6 +170,19 @@ deleted = True return deleted +def calculateupdate(ui, repo, checkout): + '''Return a tuple (targetrev, movemarkfrom) indicating the rev to + check out and where to move the active bookmark from, if needed.''' + movemarkfrom = None + if checkout is None: + curmark = repo._bookmarkcurrent + if iscurrent(repo): + movemarkfrom = repo['.'].node() + elif curmark: + ui.status(_("updating to active bookmark %s\n") % curmark) + checkout = curmark + return (checkout, movemarkfrom) + def update(repo, parents, node): deletefrom = parents marks = repo._bookmarks