I've been using git for quite some time, and just changed to mercurial to use kiln. Issue here is that git branch is an essential part of my development strategy. I usually have 2 or 3 branches at any moment and change between them. How can I do this with mercurial ? I looked at bookmark's but changing between bookmarks is just not possible, can anyone explain. This is the #1 point on: http://whygitisbetterthanx.com/ And I concur, without this mercurial is almost useless for me.
Steve Coffee gives absolutely phenomenal advice for using named branches, and I'm very happy he's an active user on the Kiln forums, but I respectfully disagree that Mercurial's native branches are exactly equivalent to Git's branches—especially if you're a user coming from Git.
I'm going to ignore Mercurial's named branches for a moment, and focus purely on what Git users usually mean when they talk about branches (since it's the only form Git supports), which is "lightweight" branches.
Git branches are really just named heads. You've got a DAG, it has multiple heads, and each one has a name. Git has a concept that you can be "on" a given head, which means that when you commit, that head is "advanced"—i.e., will now reference your latest commit.
As Steve notes, Mercurial works this way just fine. The only difference is that you don't have to name the heads by default, so whereas in Git I'd have to immediately name whatever little branch I'm doing, Mercurial does not make me do that. These branches are all "anonymous heads", and Mercurial users do this all the time (usually with bookmarks—more on that in a second) to do lightweight experimental branching.
If you want to name your heads, you can use the bookmark extension. Contrary to what you apparently read at GitHub's evangelism site, it's very easy to jump between bookmarks. The command is simply
So if you generally just do local branches for experiments, anonymous heads or bookmarks really should be a direct analog for what you're used to in Kiln.
That takes us to what happens when we need to interact with the server. Git's insistence that all heads be named does make it do one key thing very differently from Mercurial: Git by default pushes only the "active" head, whereas Mercurial pushes all heads. Whether you use Mercurial's named branches, anonymous heads, or bookmarks, this difference holds.
The good news is that we're talking about defaults, not The One True Way. You can tell Git to push all heads every time, and it's easy to add a command called
And this comes up to why Kiln doesn't encourage the use of named branches: we like the Git style of development a bit more. We like to have control over what we're pushing, rather than pushing all branches at once, and just because something started as an experiment, we don't really care about that fact when going through the history. Mercurial's native named branches record the branch name in the commit itself, which means that once it's there, it's there. While
This is personal preference. Steve Coffee has gotten tremendous leverage out of Mercurial's native named branch support, and we're working actively right now to figure out how to vastly increase Kiln's support of named branches in a very near release. For the above reasons, the Kiln team itself doesn't like them.
Of course, we still like having multiple heads in our local repository. We don't have to have three clones each for Kiln 2.0, Kiln 2.0SP1, and Kiln 2.1. And that's where Kiln's branch repositories combine really nicely with bookmarks to get the job done.
What we do is have separate repositories on the server for these kind of major releases. But (most of) the Kiln team only has a single clone for each general concept. What we'll do is pull from each of those repositories into a single clone, use bookmarks or hg-remotebranches to tag which head is which, and then just
So Mercurial's branching model is if anything more powerful than Git, simply because there are many more ways to accomplish variations on a theme.
Git-style lightweight branches are there through anonymous heads and bookmarks.
Git-style lightweight remote branches are there through the above, plus Kiln-style branch repositories.
Permanent historical branches, which lack a Git analog, are available through Mercurial's native named branch support.
All three work both for long-term release management and short-term feature development, with different features and trade-offs.
Mercurial's native branches are functionally equivalent to git branches. The problem with Kiln's implementation (and to a lesser extent the Mercurial community in general) is that they create full repository clones and insist on calling that "branching" instead of "cloning". This causes a great deal of unnecessary confusion, of which your question is a prime example.
Native branches come in two flavors in Mercurial: named and anonymous.
You can easily create anonymous branches by simply updating your working directory to a node that already has a child and committing a new change there.
A named branch can be created at any node with an explicit command. This is most similar to git, but the implementation is slightly different. Mercurial's docs on named branches may be helpful.
The primary drawback is that deleting a branch is nontrivial (but possible) in the current version of Kiln and Mercurial.