Bookmarks with hg update question

Jensen, Aaron ajensen at webmd.net
Wed Jun 22 22:49:23 UTC 2016


> Unfortunately, this is the expected behaviour. When using bookmarks, 
> hg update with no argument should be avoided except if you really 
> know what you are doing. The problem is that most users are used to 
> call hg up with no arguments because even hg pull write a hint to do 
> 'hg update' to update the working directory.

This is the one behavior of Mercurial with which I vehemently disagree and would love to see change. Here is a bug that requests this change get made: [hg update moves bookmarks](https://bz.mercurial-scm.org/show_bug.cgi?id=5273). If you'd like to see this strange, unexpected behavior change, please add a comment to that bug report.

Here's my argument for the change from the bug report:

When I create a branch, I'm told I probably want to use a bookmark. Unfortunately, bookmarks and branches do not behave equivalently. When I `hg update` on a branch, I move to the tip of the branch. When I'm on an active bookmark and run `hg update`, my bookmark moves. 

This causes update to behave unexpectedly in different situations, which is a usability bug. The `update` command is doing more than one thing: updating *and* moving my bookmark. The `update` command should only update to the tip of what I'm on. If I want to move my bookmark, there should be a parameter on the `update` command, similar to the `-u` switch on the `pull` command which does a pull *and* update.

Because of this behavior, we can't recommend or adopt bookmarks. Some will argue that we should remind people not to run `hg update` without arguments when on a bookmark. This is not reasonable. We use Mercurial because of its simplicity. One of the reasons it is simple is because we don't have to remember things like this. Most of our users are and will always be novice source control users and they will never remember, usually because they don't use it often enough to remember. Even expert users will forget. If I'm on a bookmark, go on vacation, and come back, the first think I'm going to do is `hg pull ; hg update`. My bookmark just moved and I may have not even noticed.

We would love, love, love to use bookmarks. Our repository currently has hundreds of feature branches. If we were to switch to bookmarks, we are going to get a lot of support requests asking why features, which aren't ready for live yet, suddenly appeared on the default branch. Because bookmarks don't leave a permanent record, we'll then have to do some research to figure out where the bookmark used to be and move it back.

I know the Mercurial developers are very, very reticent to break backwards-compatibility. I think this is a good time to do it. If you compare the amount of time people will lose because they have to use a command line option to update to move their bookmark versus the amount of time people lose to fixing problems when a bookmark moves unintentionally, I think the change will be worth it just in terms of the hours you'll save people and organizations. (Don't believe me? Just look at the history on the Mercurial mailing list. I know of at least three times someone has written in about the strangeness of this behavior.)

Please, please, please change this behavior. Add a command line option to the update command to move a bookmark instead of doing it implicitly.


More information about the Mercurial mailing list