167 points · by gitdude · 11y ago · 132 comments
"In my time with Mercurial, I have seen it grow in fascinating ways. These include the concept of changeset evolution coming to life and the announcement of both Facebook and Google choosing Mercurial over Git. The future of Mercurial is that of scalability and because of that, I believe the best days of Mercurial are ahead."
Is it time to give Mercurial another shot? I first migrated from SVN to Mercurial way back when - but after the massive increase in Git's popularity I bit the bullet and switched.
What does Mercurial have over Git today?
There exists no easy tutorial, that takes a beginner up to speed with git. You need to read almost a book length of material and familiarize yourself with some of the git's internals, and to some extent build your own mental model of git by experimentation, before you can use git without regular wtf-moments.
Well, there is also no tutorial that would provide the same level of understanding of the internals of Mercurial, but by some magic it seems that beginners do not need to acquire the same depth of understanding of Mercurial that they need to acquire about git, before they can start to work with Mercurial without wtf's and frustration.
Once you have a solid understanding of how DVCS's work, you can use both Mercurial and git without problems. But if you need to bring a bunch of beginners up to speed, somehow it goes easier with Mercurial.
At least, this is my experience. If someone else has experience in training teams to start using a DVCS, and has compared both git and Mercurial, and has opposite experiences, I'd be interested to hear.
I used git for a couple of years and definitely had regular wtf moments. Switched to Mercurial and they just went away.
The complexity and counter-intuitive (to me, at least) nature of git's model was a major barrier to entry.
I still use git now and then because github is so popular, but for a small team on a moderate-sized project I really prefer Mercurial for its ease of use.
fetch/merge/pull/remotes can be pretty confusing without really wrapping your head around it.
Needing to know anything about git's internals to be able to use git is FUD.
Beyond that, though, the team itself is leveraging that extensibility to continue to evolve Mercurial in new directions. Years ago, I was able to ship a third-party largefiles extension that worked similar to the GitHub external files thing launched a few weeks ago, and was able to get it integrated into Mercurial easily, where it was heavily used for years by people in the games industry. The team took "bookmarks" (Git-style branches) under its wing when they proved valuable, and have now added a ton of behavior to improve bookmark workflows.
They can even add huge new features. the big one that Git lacks is changeset evolution. Evolution allows you to get all of the benefits of rebasing and squashing, and all the benefits of a traditional DVCS merge-based workflow. Specifically, you can see all the previous versions of a given changeset, but those versions don't need to clutter up the history unless you're specifically interested. This means you're dramatically less likely to lose critical forensics information over the course of developing a new feature, and much more likely to be able to sanely see where, over the course of several rebases, you mucked up how a chunk of code actually worked.
That's not entirely true. For instance, some of the scaling is going to require a new manifest format that is not going to be backwards compatible.
* revsets -- feature-rich DSL for querying your history, my presentation on them:
https://www.youtube.com/watch?feature=player_embedded&v=NSLv...
* templates -- the output of just about any hg command can be customised:
http://mercurial.selenic.com/wiki/GenericTemplatingPlan
http://jordi.inversethought.com/blog/customising-mercurial-l...
* Evolve -- safely rewrite commits as a team, a safe replacement for `git push --force`:
https://www.youtube.com/watch?v=4OlDm3akbqg
* Very easy to write extensions:
http://mercurial.selenic.com/wiki/UsingExtensions
* Mercurial scales well to gigantic monolithic repos:
https://code.facebook.com/posts/218678814984400/scaling-merc...
That's all I can think of for now.
http://doitlive.readthedocs.org/en/latest/
I hope you were able to pay attention to the talk instead of the gimmick.
http://mercurial.selenic.com/wiki/Phases
http://mercurial.selenic.com/wiki/ChangesetEvolution
The latter is embodied in the Evolve extension, which I use for day-to-day stuff and find incredibly useful.
http://mercurial.selenic.com/wiki/EvolveExtension
The reason Google and Facebook are interested in mercurial is based on the remotefilelog extension:
http://mercurial.selenic.com/wiki/ScaleMercurial
https://bitbucket.org/facebook/remotefilelog
https://code.facebook.com/posts/218678814984400/scaling-merc...
Performance on huge monolithic repositories like the ones Facebook, Google, and Mozilla work with is actively considered by the mercurial developers when integrating new features.
Aside from what others have mentioned, the biggest thing for me personally is hg share, i.e. the ability to have two or more independent checkouts of the same repository. Git does not really support this. Your options are (1) git-new-workdir, which is not safe and can lose data and (2) doing a complete clone, which is cumbersome, because you can't directly diff/merge against branches in the other repository, but have to push/fetch first.
Disclaimer: I'm one of the strange people who (by preference) still uses Bazaar over Git and Mercurial whenever possible, so that may skew my preferences.
> Quote from Google: "We're excited about the work Facebook is doing with Mercurial and glad to be collaborating with Facebook on Mercurial development." (Well, I guess the cat is finally out of the bag: Google is working on Mercurial. This was kind of an open secret for months. But I guess now it is official.)
As well, if you search the Mercurial-devel mailing list[1], you'll see that Google engineers has been committing to Mercurial for a bit now. (Looks like they started in Aug 2014, and really picked up in Nov 2014).
[0] http://gregoryszorc.com/blog/2015/03/28/notes-from-facebook%...
[1] http://mercurial.markmail.org/search/?q=list%3Acom.selenic.m...
On the other hand, the company I currently work for also uses Mercurial, but all the developers besides maybe the founder (I haven't asked) prefer Git. I don't know the specifics about why everyone feels that way but from what I gather it has to do with branching being easier.
The other big thing git has is startup speed. Python is slow. Something like chg helps, but it's a workaround.
Startup speed for hg is on my machine below 100ms, less than the time most people need to type a single letter.
Git's branches introduce too much fragility in the system for end user consumption (because branches are responsible for both naming and keeping commits alive) and do not allow you to describe sets of commits (nor is there an alternative feature for that), Mercurial's branches are too permanent in that they cannot even be renamed (well, there's an extension for that, but that's not without issues). Mercurial bookmarks still do not allow you to label sets of commits, but at least aren't responsible for the liveness of a commit.
In practice, I like both Fossil's and Bazaar's model better.
Not related to the core product but still very important for the experience: A decent Windows gui, tortiose hg. I have tried all the guis for git, both commercial and free, and they all suck rats ass. Either they are slow, they only support github, they look like shit, they only support the most basic commit operations, they can't show the diff between selected revisions, they destroy your merges and simply make everything related to source control a pita. There are many many of them available that can do some of the things I listed above but none that does all of it.
Mercurial made VCS fun. I recently moved on to Fossil, because I do like the integrated wiki and ticket system for smallish projects, but without Mercurial I never would have gotten there.
I also like Mercurial's hooks. I am not sure if other DCVS support that, but hooks are great. (Fossil doesn't appear to have them)
Git has various hooks (client and server), Darcs I do not know.
That sounded to me like Mercurial has started to carve their own niche after losing the popularity war to git (maybe just my wishful thinking?), and this may have very good outcomes since currently all scalable mainstream vcs choices are centralized.
Git developers showed they're hardly interested in this area, and Mercurial have had some head start with the contributions from Facebook. I don't think anybody would object it if we had a free dvcs that can respond to very high scalability needs without hacking around its deficiencies. This is the point where Mercurial project should reconsider its priorities and even put some of their current priorities into back seat if that's what it gets to achieve their new goals with no compromises.
My best wishes for Mercurial, go for it!
Perhaps this is true for Facebook. But I can say that Google most certainly does not use Hg over Git. The Go source code used to be under Hg, but they've recently migrated to git.
Today, right now, neither Facebook nor Google are fully centralized on Mercurial. Facebook uses a mixture of Subversion of Git, and Google uses a mixture of a system that is totally not Perforce why do you ask please do not look behind the curtain, and Git.
Moving forward, this statement will be true for both companies. In Facebook's case, they are narrowly focused on truly moving everything into Mercurial, and are heavily using Mercurial's extensibility to facilitate that. remotefilelog (https://bitbucket.org/facebook/remotefilelog) is a key part of this, but they've been doing lots of other stuff that's not public that I can't link to that lets them get further. This process is well underway, but (last I heard anything) is incomplete.
Google is going a different direction, because Google. They're aiming to extend out their not-Perforce system to speak scalable Mercurial protocols. Given that they have experience storing Mercurial and Git inside Subversion repositories on top of Bigtable, this actually strikes me as a relatively sane engineering decision, from their perspective. This project is not ready for use. Even when it is, public Google projects will continue living on GitHub, which means that Go will continue being Git for the foreseeable future (as will FOAM, Blaze, and anything else they want contributions on).
Presumably this is all about replacing the massive Perforce repository for Google's production codebase using similar Mercurial scaling tricks as Facebook. https://code.facebook.com/posts/218678814984400/scaling-merc...
Also, just because they're using git for public projects doesn't rule out that they may be using mercurial internally. Google pays a number of people to work on mercurial... I'm not sure if that's the same for git.
We do have some hg contributors like augie, but we have way more git contributors, includes git project Lead Junio.
I'm excited about Mercurial's future. There are so many great things coming out. New ways to handle branching, shallow and narrow clones, an experimental interface for running hg over a git store...
It would make me very happy to be able to interact with Git repos through an interface that didn't make me want to kill myself with a rusty railroad spike.
I gather the difference is that hg-git has a mercurial repo locally and maps hg bookmarks to git branches and commits at push/pull time, while it seems like this experimental interface is using the HG UI against a git repo locally, but why is this better?
Why is it better? Converting a git repo to hg takes a long time, you need a way to translate hashes back and forth between the two repos, bookmarks in hg are not exactly the same as branches in git. Or in the words of Cervantes, "translation from one language into another [...] is like gazing at a Flemish tapestry with the wrong side out."
We still use mercurial for most of our repositories just because they're dated and not likely to see more than a handful of commits a year, but most of our active development work has already converted to git.
If your workflow fits better with git-style branches, you should use Mercurial bookmarks, not Mercurial named branches.
Mercurial even tells you:
(branches are permanent and global, did you want a bookmark?)
every time you create a named branch.https://bitbucket.org/site/master/issue/5811/support-two-fac...
If you look through the changelogs, you'll find that it's mostly adding a lot of optional features, not frantically fixing bugs in the core.
I will take small, incremental improvements over massive upgrades always. If something goes wrong in a monthly release, the change log is short enough for me to read every item and probably figure it out in a few minutes.
I cannot think of any benefit to a slow release cycle with large changes bunched up into versions, and consider it a major negative when I am choosing software (I'm currently upgrading to Drupal 7 from 6 and its been almost funny how much of a disaster it's been).
There's a reason Chrome and Firefox and Manny others do rapid rolling releases. It simply delivers better software faster and with less likelihood of catastrophic problems. Small changesets are just easier to fit into a human mind.
I refuse to do that out of principle. I think Mercurial should have taken the place of git as the widely used DVCS. And I try to be THAT change I want to see.
That being said, It would be great if someone can get the hg-git plugin to work seamlessly with newer versions of Mercurial on Windows and Linux, so that I can keep using Mercurial even if a project I am involved in uses git.
This fake interview is pretty funny:
"Linus: Git has taken over where Linux left off separating the geeks into know-nothings and know-it-alls. I didn’t really expect anyone to use it because it’s so hard to use, but that turns out to be its big appeal. No technology can ever be too arcane or complicated for the black t-shirt crowd."
http://typicalprogrammer.com/linus-torvalds-goes-off-on-linu...
tl;dr: the interface of mercurial may be more straightforward, but git won because it allowed people to work better.
I have to disagree about the index, though. I use Git every day, and i'm still struck by how pointless the index and the idea of staging is.
Ditto rebase. The routine use of rebase still seems completely wrongheaded to me. Mercurial's convention of preferring merges is better, and the last few years' developments around safe evolution of history really show rebase up as the misconceived hack it is.
Mercurial got 'commit --amend' a long time ago, but even before that, it had 'rollback', which undoes the last commit, leaving the working tree untouched (that is, with the state it had in the commit), so you can make your fixes and commit again.
I'd entertain the argument that Git won because it was better if even a handful of the people who now use Git had learned both Git and Mercurial and made an informed choice between them. That simply does not appear to be the case. Git got ahead because Linus invented it, and won because of GitHub.
This is quite subjective. A more probable reason is that git is popular because of github..
And once git gained some popularity, people started viewing other DVCS as inferior because they were doing things differently from Git. For eg, the branching in Mercurial. People are appalled when they see how named branches can be done in Mercurial. Without going into any thought or reflection on how Mercurial's named branching can be useful in certain situations, they call it braindead. But actually git's branching is quite simple and less powerful than the methods offered by Mercurial. Less powerful, because Mercurial offers multiple methods to make a branch so that you can use the right one for a particular situtation. Note that this actually asks for more experience from the user. He needs to have experience with using each of these methods and should know how each of them may be useful in the future. It also stores more metadata and tools like revset which lets you to build powerful queries. So in that sense, Mercurial is also more complex than Git. But that is in a good way and unlike git's, it is not the complexity that gets in your way.
So in short, I think git is actually quite simple than Mercurial, but hides that simplicity behind a complex interface with non-intuitive naming and weird combination of flags and stuff. This causes the 'Aha' moments when one can finally see the simplicity that hides behind that interface, which trigger a huge release of Dopamine and prompts the user to write his own set of Git revelations that (used to) flood the internet, which in turn increases the popularity of Git...
My team started using Mercurial a couple years before Git but eventually migrated over because in practice Git was less surprising and nobody had lost data using it.
Or rather (in many cases) how good it makes people feel to use and tell other people they use something incredibly complicated, whether they actually understand it or not.
I'd venture that a fairly large amount of the people who use git don't really understand it fully, they just understand some very small subset of what they picked up from whatever "best git flow" website or book they happened to read.
Lest anyone think I'm being elitist here, I'll come right out and admit there's a ton of stuff in git I've never bothered to really understand. I'm okay with standard push/pull commits, stashing and rebasing, but I still kinda think of these things as sort of interpretations of concepts I'm used to from older non-DVCS systems, I don't "grok" git, not really -- never really bothered since I find source control systems incredibly useful but not inherently interesting (to me personally).
All that said, I don't use git to show off, I use it because virtually everyone else does and there is a certain pragmatic benefit to going with the flow on something like that even if I think it is overkill for a lot of the projects I need a VCS for.
https://static.googleusercontent.com/media/research.google.c...
Your idea (my interpretation) that the industry mostly consists of people having productive discussions seems more off base. Yes, that's the way it should be, and usually is on HN and similar forums, but out in the larger real world, arrogance, superiority, etc are the order of the day.
It is of course possible that performance follows a saddle like curve (or hump depending on how you look at it). For up to some size, git is faster. But at much larger ones a different algorithm wins out and hg could be end up being faster.
The main problem is that mercurial never got real branches, which is git's wheelhouse, forcing gross things like the "forest" extension (which I believe is now unmaintained). Maybe it's gotten better since then, but this was about 3-4 years ago.
The way I see it, git has all the powertools you'd need, and you don't have to use them most of the time, where as mercurial feels generally stripped down to be "easy", and when you want to do the hard things, it's not so good at it.
One of those examples might be something like grafting a repo into another repo at a arbitrary root, or some of the tricks you can do to edit previous commits (say if you mispelled your username all the way down).
My main point of switching originally was when I believe it mixed up a lot of commits in a merge and lost some changes. I also recall hearing about a patch for predictable ordering in diff output being rejected.
git's really gotten TONS better -- way back, I would say mercurial was easier to use, and git really excels at branch based workflows which at this point I can't live without.
Of course, a worse thing from having to work at a mercurial shop after loving git is having to work at a SVN shop :)
What we've learned is that these two things are actually liabilities.
git is a good example that the syntax of the command line is of no consequence. git's CLI is notoriously horrendous and bizarre, yet it didn't stop its adoption. And this is a problem that's easily worked around by creating tools (graphical ones and also porcelaines) around it.
The fact that Mercurial is written in Python has a big impact on its performance, and git is running rings around it as a result. When you run tens of commands every day, it adds up.
Strangely enough even git's initial hostility to running on Windows didn't stop its adoption.
git's features and modeling of source control system is so powerful and flexible that git became successful in spite of all these other aspects.
Frankly, I think it's silly to use any other source control these days: embrace git and get used to it because it's going to be around for a while.
This wasn't the case at all. In their early years, some operations were faster on git, and others, faster on Mercurial[1]. I don't remember any recent benchmarks, but early last year, there were reports of Facebook making Mercurial faster [2].
> Frankly, I think it's silly to use any other source control these days
You might get that impression if your work is centered around github, but I have friends who use enterprise-specific extensions on Mercurial that structure their workflow.
[1] http://draketo.de/proj/hg-vs-git-server/test-results.html
No, it doesn't.
You know why git won? HG was slow as molasses when they both showed up on the scene. That and git's branches are a dream come true. I think back then, an HG branch was a clone of the repo.
I can't figure out what sort of suffering people are talking about.
There are ways around it like hg-git, but they can't really hide the git underneath. We have to use git or be computer hermits.
Most of the git commands I use are about as straight forward and simple as they could be. If ever I manage to screw something up, the archeology commands I end up using are obtuse, but it's rare that I need them. And I'm glad they are there when I do.
If you are having to download 3rd party extensions, then that's a different problem.
I've somehow created a branch that couldn't be deleted. Instead of being really deleted it appeared in remote repository as some kind of a "tombstone".
I've tried to rebase, but to do that I had to fiddle with settings and enable plugins.
My impression was that Mercurial is a higher-level version of git, with the sugary layer doing things that I don't want.
The problem here is one of conflicting terminology. What Git calls a branch, no other version control system calls a branch. A branch in Git is really a moving pointer to the head of a branch as other VCSs would see it.
The confusion can go both ways, by the way. I.e. when a user who is used to another VCS expects a branch to be a persistent label for a set of commits and then discovers that it doesn't work like that for Git repositories and that your branches may "move" or "disappear" and don't even describe sets of commits but individual commits.
Except Git tracks history of the named branch in the reflog, and SVN (and others, I would guess) track it inside the repository. This is a huge difference for archeologists, but quite minor in practice from my experience.
Eventually, just less than a year ago, I bit the bullet and made the switch to git. What did the trick for me was a list of short aliases I copied from somewhere, tweaked and have been maintaining in my ~/.bash_aliases ever since. Some aliases are just shortcuts for super common commands (such as "alias gts='git status'") but others remove the burden of remembering what combination of commands and arguments make sense to me ("do i undo a change with revert, reset, checkout or something else? well it depends.."). I still can't claim I know git in depth but it's good enough for day to day usage.
Can you elaborate and/or point to an issue tracker that describes the problems?
The Windows malfunction may be more work than a reasonable person would want to bite off, but getting it to work on Linux should be feasible.
Mecurial is super easy to learn - there is no reason not to be comfortable with both.
Git has git style branches which make it really easy to work on different things. Apparently hg added some of that later but it's not the main workflow
git also has a "staging area". You put things into the staging area and then commit. So for example the equivalent of "hg commit" in git is "git commit -a". The -a means "copy everything that's changed to the staging area".
The advantage of the staging area is it's easy to commit just a few files even if many have changed. It's even easy to commit just a few changed lines from a file and leave the other lines un-commmited.
There are other advantages I'm sure and I'm sure I didn't explain the branching one well. I can point out that I have repos with completely unrelated branches. One branch is the website, another branch is the docs, another branch is the source code, branches in hg, at least the default ones, are assumed to be something that will eventually be merged back. hg complains forever until you merge the branch back. git branches are effectively unrelated to each other, although by default git will track where it branched and if you happen to merge them where they merged. branches can be pushed and pulled to other repos or not, it's up to you.
Someone above said hg has bookmarks that are similar to git branches but I'd be curious if they're actually the same.
I've heard hg since then has added features that make it possible to have a more git like workflow but AFAICT it's still not the "recommended" at least not the default workflow which means I have no desire to switch back.