# HG changeset patch
# User Angel Ezquerra <ange...@gmail.com>
# 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/merge.py b/mercurial/merge.py
@@ -527,9 +527,18 @@
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
- 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
+ if node is None:
+ # all heads are bookmarked, go to the tip of current branch
+ node = repo.branchtip(wc.branch())
if wc.branch() == "default": # no default branch!
node = repo.lookup("tip") # update to tip