[PATCH RFC] update: skip bookmarked heads when running a bare "hg update"
Matt Mackall
mpm at selenic.com
Wed Jun 6 21:37:00 CDT 2012
On Fri, 2012-05-25 at 16:25 +0200, Angel Ezquerra wrote:
> # HG changeset patch
> # User Angel Ezquerra <angel.ezquerra at 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".
Interesting. This seems in line with what I've proposed here:
http://markmail.org/message/qugvrgamwudgsdbq
and our recent change to the behavior of merge with bookmarks:
http://www.selenic.com/hg/rev/4a02cf4fbb2e
So I'm inclined to accept it. But I think we need an informative error
message here rather than simply saying "up to date", something like:
abort: branch head is on a bookmark
(use 'hg update <branch>' to update anyway)
We are probably overdue for a bookmarks help topic explaining how they
interact with things.
> 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
> --- a/mercurial/merge.py
> +++ b/mercurial/merge.py
> @@ -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
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
--
Mathematics is the supreme nostalgia of our time.
More information about the Mercurial-devel
mailing list