atom feed4 messages in com.selenic.mercurial-devel[PATCH RFC] update: skip bookmarked h...
FromSent OnAttachments
Angel EzquerraMay 25, 2012 7:25 am 
Matt MackallJun 6, 2012 7:36 pm 
Angel EzquerraJun 8, 2012 2:40 am 
Matt MackallJun 13, 2012 12:52 pm 
Subject:[PATCH RFC] update: skip bookmarked heads when running a bare "hg update"
From:Angel Ezquerra (
Date:May 25, 2012 7:25:26 am

# HG changeset patch # User Angel Ezquerra <> # Date 1337955724 -7200 # Node ID cb06046e10797e569bed05850318068f4a5d535c # Parent 2ac08d8b21aa7b6e0a062afed5a3f357ccef67f9 update: skip bookmarked heads when running a bare "hg update"

When running a bare "hg update" without specifying a revision, we used to update to the tip of the current branch, even if it were bookmarked. This is inconvenient when using bookmarks for feature branches, since pulling new bookmarks will make "hg update" update to those bookmarked "feature branches".

This patch changes this behavior. "hg update" will look for the tipmost head of the current branch that is not bookmarked. If none is found the old behavior is used (i.e. we will update to the tip of the current branch).

This is missing tests and possibly a comment on the update command help.

diff --git a/mercurial/ b/mercurial/ --- a/mercurial/ +++ b/mercurial/ @@ -527,9 +527,18 @@ try: wc = repo[None] if node is None: - # tip of current branch + # tipmost, non bookmarked head of current branch + # if all heads on the current branch are bookmarked, + # go to the tip of the current branch try: - node = repo.branchtip(wc.branch()) + # brancheads returns the branch heads sorted from max to min
rev + for head in repo.branchheads(wc.branch()): + if repo[head].bookmarks() == []: + node = head + break + if node is None: + # all heads are bookmarked, go to the tip of current branch + node = repo.branchtip(wc.branch()) except error.RepoLookupError: if wc.branch() == "default": # no default branch! node = repo.lookup("tip") # update to tip