How to *not* export a bookmark?
Matt Mackall
mpm at selenic.com
Sat Sep 27 17:46:41 UTC 2014
On Wed, 2014-09-24 at 12:01 -0700, Andi McClure wrote:
> Here is a common mistake I make:
>
> hg pull -r basebranch
> hg up basebranch
> [some trivial change]
Are you using a recent hg that says:
(activating bookmark basebranch)
?
> hg commit -m "Trivial change"
> hg book basebranch_modified
> hg push --book basebranch_modified
>
> My intent here is to go to a particular bookmark; make a change and check
> it in; and then create and push a new bookmark for the new changeset, while
> leaving the old bookmark alone. However, I made a mistake: I should have
> said book *before* commit, or deactivated the bookmark before I committed.
> Since I instead committed first, basebranch (which was activated when I
> updated) will move up to my new commit, and when I push it will set both
> basebranch and basebranch_modified on the server as being equal to my new
> commit.
>
> There is something weird about this to me: When I pushed, I instructed it
> to push basebranch_modified, but did not instruct it to push basebranch.
> But, it pushed basebranch anyway. I think this is because when hg pushes
> a changeset it also pushes all bookmarks associated with that changeset,
> regardless of how the changeset was specified.
>
> I would like to be able to push a bookmark and *only that bookmark*, not
> exporting anything I didn't request. Is there a way to do this? Should
> there be?
>
> On a related note: So that I could make these errors less likely in the
> first place, is there some way to update to a bookmark without activating
> it? Should there be? (*This* I think I could achieve myself using a
> post-update hook or something that automatically book -i's after each
> update, but it seems like a fundamentally useful thing.)
No, we've not seen sufficient need for such a feature. However, you can
use this trick:
$ hg up :mybookmark
Probably some explanation is required, though. When you give the update
command just a bookmark, it says "ah, this means we want to activate a
bookmark".
But when you hand update a revset, it chooses the last element of the
set as a plain revision to update to. So given the revset above, which
means "all commits numerically from the start of time to my bookmark",
it'll simply update to your bookmark.. without activating it.
--
Mathematics is the supreme nostalgia of our time.
More information about the Mercurial
mailing list