Five Features from Mercurial That Would Make Git Suck Less
nubyonrails.com
nubyonrails.com
The one big issue is the branching comments. Creating named branches like he's doing here is very problematic, especially if you're at all used to Git branches. Running '--close-branch' doesn't really remove the branch, it adds another commit that has some metadata saying it's closed - but older versions of hg won't recognize that (the feature is very, very new - it was introduced in 1.2) and even if you have a version of hg that supports it, the last I tried it won't hide the closed branches by default, you have to provide a switch to 'hg branch' to hide them ('hg branch --active'), which is pretty annoying. If I created named branches for all the topic branches I've made in my various Git projects, I'd have hundreds or thousands of named branches littering up many of them.
There are tons of other serious problems with Hg's concepts of lightweight branching - for instance, you can't NOT push all of your branches to a repo when you push, meaning you can't have any branches that are just for you to test stuff out in - if you create what Git users think of as a 'topic branch', it's basically there forever - no way to ever really remove it or not share it. If you use the Bookmarks extension, which is meant to more closely mimic Git branching, you have the opposite problem - you can't push the bookmarks up to a shared server, you have to SCP them separately. I believe the heads will be there, but that's even more confusing because now you just have a bunch of unnamed heads...
Speaking of namespace issues, named branches are way worse for that - if you create a named branch locally and someone else creates the same named branch locally and then you clone from them, you'll have two heads with the same branch name, which could have totally different lines of work on them and Hg doesn't complain - that could get ridiculously confusing.
Most Hg users I know only very rarely use named branches - the online book recommends doing a local clone instead of a named branch for branching. Many serious Hg users instead use the 'mq' extension, which provides a patch queue toolset for Hg and allows you to do some revlog editing - allowing you to do development much more similarly to how Git devs do, but the toolset and paradigm are _much_ more convoluted and confusing than the problems he states about Git branches, IMHO.
There are certainly a number of UI improvements that Git could make (and Hg, too) but I really don't think Hg's branching model is something to emulate.
Also, you totally can push all of your branches to a repo - that's just not the behavior that is allowed by default because often that isn't what the user meant. It's also confusing because bookmarks aren't push-pull capable (yet).
To correct another common misconception, you can absolutely push only certain heads of a repository. The command is "hg push -r <head of relevant branch>". If you have bookmarks installed, that can be as easy as "hg push -r <bookmark name>".
Please, Git maintainers, don't listen to this guy and don't ever change the current behavior. I've come to rely on staging my commits incrementally.
I really care about keeping a pristine history with isolated and understandable commits. Being able to commit pieces without including temporary code or debugging comments is invaluable to my workflow. I want to be able to modify source code without worrying about any piece of it getting committed accidentally. I also want all edits I made, including uncommitted ones, to stick around until I explicitly remove them.
Maybe Mercurial can do this also, but Git has been almost completely do-what-I-mean with regard to making sure I don't lose any changes or confuse myself about where they went.
I suppose it's a matter of what the common case is. For me, the majority of my commits are either one or two files, or the whole working tree -- so Mercurial's defaults make sense with that usage pattern. Of course, other usage patterns would dictate more of a "massage the commit" style.
And since you've got both "git commit --amend" and "git rebase -i" to hand, it's trivial to later on fix up any mistakes you do make.
Honestly, having a clean history is an enormous win - it far outweighs the minor cost of making the odd wrong but easily-correctable-after-the-fact commit.
git add -i
git commit
git stash
./some_tests # ...shoot, forgot something
git add . # whatever I forgot
git commit --amend
./some_tests # now we're good
git stash apply
git stash clear
git push
On the hg side, you can use mq and record to get yourself in and out of the same kind of trouble, as someone else mentioned. I think these are essential but dangerous features that any good DVCS should have.A better safety mechanism (than deleting the feature) is a pre-push hook that runs the test suite on every commit since the remote head. Not everyone needs that level of strictness, though.
sub foo {
+ warn "made it here";
actual code;
}
This stuff, I never want to commit. Sure, I haven't tested
the code without it, but I'm sure it works.Subversion-style committing sucks hard; worst idea ever. (And besides, svn still lets you do this; svn commit one-file. Untested tree committed, with no possibility of ever backing out the change. Not good.)
Been a Merucial enangelist some time ago, since about 0.9. Once switched to git, I had never looked back but for the ease of `hg serve'. Anyway, git's branch handling is a killer advantage, matches the workflows I use (small team, and single developer on multiple machines) much better than the branches with one global namespace in Hg.
About that reset/update/revert, you may want to define an alias in your ~/.gitconfig; simple as that.
In theory, a small happy number is easy to deal with. In practice, a team of two developers doing pushes and pulls with auto-merging will have sequences that don't line up so they can't use them to talk about revisions anyway.
git's "describe" output is the best of all worlds.