Why did "hg push", push my local bookmark to remote?
Bryan Murdock
bmurdock at gmail.com
Fri Feb 6 17:24:45 UTC 2015
On Thu, Feb 5, 2015 at 10:46 PM, Jaikiran Pai <jai.forums2013 at gmail.com> wrote:
> I used to be a git user but have been using mercurial in a recent project,
> for a while now. Just recently, I decided to use the "bookmark" feature of
> mercurial to have lightweight branches similar to git. The documentation at
> various places about bookmark suggests that if I have a (local) bookmark and
> commits in that booking and I'm pushing to a remote repository, then the
> commits to the bookmark will *not* be pushed to the remote repository unless
> the remote repository has that bookmark too. That's a good thing and that's
> what I want. However, that doesn't seem to be how it's working (I was on 2.8
> version of mercurial but it's the same with 3.3 too). Here's what I did:
>
> hg bookmark test-bookmark // create a new bookmark
> hg up test-bookmark // up to that bookmark
> ... update an existing file in the workspace
> hg commit -m "Dummy test commit in bookmark" // commit the local change
> hg push // push to remote
>
> To my surprise, the commit that I did to the bookmark got pushed to the
> remote repo and is now visible/available to everyone and has the potential
> to cause problems (since it was a work in progress change). I didn't
> explicitly push the bookmark, yet it got pushed to remote by a plain hg
> push. Did I miss something about how bookmarks work in mercurial?
I know you have already had some discussion with others on this, but I
thought I would throw in my 2 cents.
Basic mercurial is very simple. A push command with no arguments will
push every commit that is in your local repo that is not in the remote
repo. You can supply arguments to limit which commit will be pushed.
The outgoing command shows you what would be pushed without actually
pushing and it accepts the same arguments as push. Think of outgoing
as a push preview or a push dry run.
hg push # pushes everything not in remote
hg push -r . # pushes the current commit and any of its ancestors not in remote
hg outgoing # lists all commits not in remote
hg outgoing -r . # lists current commit and any of its ancestors not in remote
With git you have to be explicit about what you want pushed, with
mercurial you have to be explicit if you don't want to push
everything.
Also, keep in mind that a bookmark is not a commit (or list of
commits). It is a thing that *refers* to a commit. Git branches are
essentially the same thing (a reference to a commit), even though much
of the git documentation blurs the line between a commit and the thing
that refers to the commit.
I hope that helps.
Bryan
More information about the Mercurial
mailing list