Bookmarks with hg update question
James Reynolds
james.glenn.reynolds at gmail.com
Thu Jun 23 15:07:06 UTC 2016
On Wed, Jun 22, 2016 at 6:49 PM, Jensen, Aaron <ajensen at webmd.net> wrote:
> > 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.
>
Glad to see I'm not not alone in this.
regarding backwards compatibility, I was tinkering around internally in
Mercurial and came up with a patch that maintains backwards compatibility
via an .hgrc setting (in .hg/hgrc or some other place) you would set:
[bookmarks]
> noupdate =
I haven't gotten around to submitting this yet, because the way of
submitting patches is rather arcane (not sure why simple pull requests on
bitbucket won't suffice) nor have I added documentation or testing for it.
I'm honestly not all that familiar with Mercurial internals, so writing
tests against it would probably be more time then I'd like to spend on this.
looks like this:
>
> # HG changeset patch
> # User james Reynolds <james.glenn.reynolds at gmail.com>
> # Date 1465936885 14400
> # Tue Jun 14 16:41:25 2016 -0400
> # Node ID 6bc70c5a0d0e33d7ae07af90c372da42dd888758
> # Parent 60621cecc8c53d3a27e9984fb06fefc1f99797b3
> update: don't move bookmark if nopupdate in bookmarks is set.
> diff -r 60621cecc8c5 -r 6bc70c5a0d0e mercurial/hg.py
> --- a/mercurial/hg.py Thu Jun 09 13:47:42 2016 -0500
> +++ b/mercurial/hg.py Tue Jun 14 16:41:25 2016 -0400
> @@ -717,7 +717,9 @@
> with repo.wlock():
> movemarkfrom = None
> warndest = False
> - if checkout is None:
> + _nobmupdate = repo.ui.config("bookmarks", "noupdate")
> + nobmupdate = True if _nobmupdate is "" else False
> + if checkout is None and not nobmupdate:
> updata = destutil.destupdate(repo, clean=clean, check=check)
> checkout, movemarkfrom, brev = updata
> warndest = True
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial/attachments/20160623/41b6b48b/attachment-0002.html>
More information about the Mercurial
mailing list