News for hackers. Stuff that matters.
Re:Mercurial: Onward and upward by 100k on Thursday April 30, 2015 @04:26PM (#9467435)
I was really surprised that Git "won" because I thought that Mercurial's friendlier CLI and being written in Python would give it an advantage. I think I underestimated how good it makes people feel to understand something incredibly complicated. I guess immutable history was a turn off for many people as well.

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...

Re:Mercurial: Onward and upward by xiaomai on Thursday April 30, 2015 @05:18PM (#9467717)
That is a clever fake interview quote, but the whole notion that hg's "easier" interface should have made it won misses the point. hg's interface is more familiar (especially since we were mostly all coming from subversion at the time). Git won because it's workflow is so much better than mercurial's. Light-weight branches are better than hg branches (I know they have bookmarks now but I don't recall if they had them back then). The index is a fantastic idea that makes writing clean commits easy (I think the comparable hg option at the time was mercurial queues which are much more cumbersome to work with imo). Rebase is functionality that hg didn't include out of the box. Being able to edit commits in git is something I greatly appreciate for fixing typos and stuff.

tl;dr: the interface of mercurial may be more straightforward, but git won because it allowed people to work better.

Re:Mercurial: Onward and upward by twic on Thursday April 30, 2015 @05:31PM (#9467794)
You're right that Mercurial didn't have bookmarks until years after Git had branches. There were various things you could do to get a similar effect (eg having a branch with multiple heads), but none quite as good, and it took the Mercurial team a long time to come around to the idea.

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.

Re:Mercurial: Onward and upward by lobster_johnson on Thursday April 30, 2015 @09:13PM (#9468758)
I use Git every day, and i'm still struck by how pointless the index and the idea of staging is.

I find it amazingly useful. The staging area is for building your commit. I always ever use -p (ie., "add -p", "reset -p" and "checkout -p") and use it to construct the commit out of parts.

The way I work, I split my current work into multiple commits. I may have implemented a feature, fixed a bug I found along the way in the same file, and updated the readme with something unrelated; those are three separate commits. I do "add -p" to pick the fragments, and when I'm happy, I commit. Repeat until repo is clean.

Sometimes, my current work results in a whole bunch of such commits. Sometimes I have to split part of my current work into a separate branch. Again: Stage stuff, stash -k, checkout new branch, commit as a WIP commit, go back, unstash.

Darcs has "record", which is like "add -p" except it also commits at the same time, and back when I was using it, I remember hating the fact that it required that everything had to be recorded in one go. Git's incremental staging area is much more pleasant because you don't get stressed out by the impending commit that is looming over you.

Re:Mercurial: Onward and upward by ufo on Thursday April 30, 2015 @11:55PM (#9469288)
I prefer to use shelving / stashing to do this sort of stuff. This way you don't need to learn two ways to do the same thing and you can be sure that the code version that you commit is the same that you ran your tests on.
Re:Mercurial: Onward and upward by gknoy on Friday May 01, 2015 @02:20AM (#9469794)
In contrast, I never use `git stash`. Never-ever-ever-(ok-rarely). It bit me HARD early on, so I prefer to do it manually, or rebase branches.

One thing I really like about git is that it lets me be mindful of my actions in a way that hg didn't seem to encourage. In return, it gives me what feels like True Power to recover from _any_ mistake. Wrong branch? Accidentally merged (and pushed) my master branch? No problem, they're just bookmarks to commits anyways.

Mercurial, by contrast, felt Rather Convenient, with occasional chasms of despair if you strayed too far from the path. It's possible that my high opinion of Git is mainly from the fact that it forced me to learn more, but it really feels more flexible. I always have the right tool for whatever I need, and I know why and how to use them.

Re:Mercurial: Onward and upward by zak_mc_kracken on Thursday April 30, 2015 @05:51PM (#9467896)
> I use Git every day, and i'm still struck by how pointless the index and the idea of staging is.

This is probably more a symptom of the fact that either your workflow doesn't require an index or you don't understand its value.

Either way, the index is by far git's more popular and used feature, besides branches.

Re:Mercurial: Onward and upward by k__ on Thursday April 30, 2015 @08:34PM (#9468615)
Care to elaborate?

I use Git on a daily basis, but I never understood it.

If I just want to commit a specific part of my changes, I just do it. It's nice to see which files are staged for a commit, but I also see them in the commit msg comments.

Re:Mercurial: Onward and upward by brianwawok on Thursday April 30, 2015 @09:52PM (#9468913)
What if the same file has 2 separate commits you want to split up?
Re:Mercurial: Onward and upward by zak_mc_kracken on Thursday April 30, 2015 @10:40PM (#9469077)
Yes, this is a very underhyped feature.

They're called "hunks" in git parlance: sections of the file that define a "diff". A diff on a file can be made of multiple hunks.

Very often, my changes to a file are a mix of "fixing a serious bug" and "minor refactoring" and "removing dead code". When the time to commit comes, git makes it trivial to separate all these changes in different commits so that each commit does one thing and one thing only.

Re:Mercurial: Onward and upward by ngoldbaum on Thursday April 30, 2015 @11:28PM (#9469217)
You can use "hg commit -i". This is a new feature in hg 3.4, but in older versions you can turn on the record extension.
Re:Mercurial: Onward and upward by campers on Thursday April 30, 2015 @10:11PM (#9468989)
I just noticed recently that TortoiseHG lets you do that in the GUI. Definitely is a nice feature. I only just started using Git and did like the ability to cherry pick from a file, but happy to know I can still do that with hg.
Re:Mercurial: Onward and upward by imakesnowflakes on Friday May 01, 2015 @12:01AM (#9469319)
Actually Hg record can do this. It lets you 'edit' a hunk using a text editor, before adding it to the list of changes to include in the current commit....
Re:Mercurial: Onward and upward by LocalPCGuy on Friday May 01, 2015 @01:00AM (#9469565)
> 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.

I think you also underestimate the developer community (or may I overestimate them.) Regardless, my anecdotal evidence is that I did try HG and Git, and while I preferred HG when I first started evaluating them, as soon as I found out how to use Git branches, it was all over for HG. At work we currently inherited a project in HG and everyone that has to work on it complains about it. Some know Git, some are .Net or even old school CVS/SVN people (our VCS migration took a bit longer than it should have), but it doesn't matter. HG = hard to use for them, whereas Git make sense after getting over the initial hurdles. I see the same kind of path I took, where at first they are like, oh, Hg isn't bad, and then after using both, choosing Git as their preference.

Re:Mercurial: Onward and upward by zimpenfish on Friday May 01, 2015 @08:03AM (#9470751)
I used Mercurial for years because I tried early git and didn't like it. Then I tried it again, everything was easier than Mercurial and I wouldn't ever go back.
Re:Mercurial: Onward and upward by Skinney on Friday May 01, 2015 @03:27AM (#9469977)
Hey, if you don't use the index then don't use the index. Use git commit -a. If you wan't something like the index in Mercurial you have to specify which files you want to commit, or which to exclude, which IMHO is a lot more tedious and error prone. Then again I haven't used Hg in a couple of years, could be they have something like the index now.

Rebase is a hack? Rebase copies a series of commits on top of an immutable history at a certain point in time. This allows you to deal with merges a single conflict at a time, instead of dealing with all the conflicts at once with a merge. It also allows you to avoid cluttering your history with useless merge-commits when just syncing with another repo.

Merges have their place. I use them whenever I merge branches, using --no-ff so I can attach a "Fixes issue #77" in the merge commit message. Of course, before I do that, I sync the branch I'm merging into, then rebase on top of that (to have a clean merge). I might also rebase --interactive to clean up the commits of my branch, so that the history is as easy to read as possible.

Comparing rebase to rollback is wrong. Git has rollback (or revert) as well, and it's used for other usecases, like when reverting changes on a public branch (where rebase would fuck it up for everyone).

I'm sorry, but your comments make it sound like you don't really understand Git.

Re:Mercurial: Onward and upward by imakesnowflakes on Friday May 01, 2015 @10:03AM (#9471299)
>Rebase allows you to deal with merges a single conflict at a time, instead of dealing with all the conflicts at once with a merge...

Not sure what you mean by 'deal with a single conflict at a time'. To rebase or merge, you will have to resolve all conflicts that merge/rebase produce, right?

Re:Mercurial: Onward and upward by Skinney on Friday May 01, 2015 @06:53PM (#9475012)
Yes, but a rebase re-applies every commit to the new base. So you solve conflicts one commit at a time, instead of solving every conflict in a single merge commit.

It's easier to remember the intended behaviour when the code changes are as small as possible, and when you have a (hopefully) good commit message to look at.

Re:Mercurial: Onward and upward by imakesnowflakes on Friday May 01, 2015 @09:44PM (#9475540)
I am not sure it make any difference to the user at all. If you use a merge tool, it will present the conflicts one at a time for merging and re-basing.

If you are concerned about reading history, then a merge can give you more context regarding the commits. With re base, commits will jump between features. For example, You are looking at commit for feature 1, but the next series of commits are for a bug fix in feature 2. Next series of commits belong to minor tweaks in feature 3..

Re:Mercurial: Onward and upward by Skinney on Sunday May 03, 2015 @12:39AM (#9479949)
A merge will provide you with a single commit-message, rebasing will provide you a commit-message for every commit, making it easier to remember what the intent of a change was. Sometimes that isn't clear.

Regarding the "rebase, commits will jump between features" part: that really depends on how you do things. On my projects, we use git flow. In such a scheme, every branch you would rebase, belongs to the same feature or bugfix.

Re:Mercurial: Onward and upward by imakesnowflakes on Sunday May 03, 2015 @12:57AM (#9480003)
>In such a scheme, every branch you would rebase, belongs to the same feature or bugfix..

Not sure if I made that clear. But I was talking about the result of the rebase. Once you rebase, all the commits that were in different branch ends up being back to back, and hence become interleaved...

Re:Mercurial: Onward and upward by DigitalJack on Thursday April 30, 2015 @08:24PM (#9468558)
staging is wonderful. I'm sure hg must have something similar.

I can't tell you how many times I've shot myself in the foot accidentally committing stuff to svn when I just meant a single file.

Re:Mercurial: Onward and upward by reinhardt on Thursday April 30, 2015 @08:48PM (#9468658)
I don't use hg much these days but you can just pass the file(s) you want to commit to 'hg commit'; no need for staging. Even better, hg (or its shell integration at any rate) has tab completion so it's easy to go though the modified files and pick those you wanted to commit. I kinda miss this now I'm working with git mostly.
Re:Mercurial: Onward and upward by skybrian on Thursday April 30, 2015 @09:10PM (#9468748)
Do you know about commit --amend? Seems like having both is redundant.
Re:Mercurial: Onward and upward by ngoldbaum on Thursday April 30, 2015 @05:38PM (#9467834)
Nice comment. One gripe: "rollback" undoes the last transaction, which isn't necessarily the same as a commit. It's deprecated now for that reason.
Re:Mercurial: Onward and upward by imakesnowflakes on Friday May 01, 2015 @02:27AM (#9469810)
>Git won because it's workflow is so much better than mercurial's.

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...

Re:Mercurial: Onward and upward by acdha on Thursday April 30, 2015 @04:51PM (#9467568)
The main thing I found was that Mercurial was only easier for the simplest introductory tasks, where Git has largely compensated with tons of documentation, tutorials and, later, improved command-line UI. Once you needed to do anything more complicated (e.g. working on against an upstream repo you don't have commit access to) you tended to quickly end up in documentation lacunae and semi-supported extensions which rotated in and out of favor depending on which year the guide you'd found was written.

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.

Re:Mercurial: Onward and upward by georgemcbay on Thursday April 30, 2015 @05:18PM (#9467723)
"I underestimated how good it makes people feel to understand something incredibly complicated"

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.

Re:Mercurial: Onward and upward by ngoldbaum on Thursday April 30, 2015 @05:28PM (#9467770)
Here's an interesting paper that largely confirms your supposition:

https://static.googleusercontent.com/media/research.google.c...

Re:Mercurial: Onward and upward by andrewflnr on Thursday April 30, 2015 @11:19PM (#9469185)
This attitude of "oh, the only reason it's popular is because people want to feel superior for learning something hard" is poisonous to productive discussion. If you're going to be cynical about it, at least favor the "OMG Linus Torvalds maed it" explanation over the one that requires active assholery on the part of Git users. Better yet, try assuming that most people are making a reasonable effort to be rational based on their limited knowledge. But what you did right there, please don't do that.
Re:Mercurial: Onward and upward by mistermann on Friday May 01, 2015 @12:03AM (#9469323)
Anecdotal of course, but in my limited experience, I've seen plenty of superiority complexes and generally assholery, but no Linus fanboyism. I don't like it, but to me it seems like a perfectly unsurprising aspect of the software industry.

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.

Re:Mercurial: Onward and upward by woah on Friday May 01, 2015 @01:22AM (#9469640)
If I'm reading this thread correctly, hg doesn't even have a staging area! And you've got to come up with some far-fetched conspiracy theory?
Re:Mercurial: Onward and upward by andrewflnr on Friday May 01, 2015 @12:18AM (#9469380)
Yes, I know the real world sucks. In light of that, let's try not to actively make it worse. Applying Hanlon's Razor aggressively is the easiest thing we can do. And don't forget the selection bias from the fact that jerks are more likely to make themselves noticed than rational people.
Re:Mercurial: Onward and upward by reality_czech on Friday May 01, 2015 @04:01AM (#9470072)
Or you could mention the elephant in the room, the fact that git is orders of magnitude faster than mercurial when your project grows beyond the "small" size. Mercurial would be unusable on something like the Linux kernel, and uncomfortably slow on a lot of other projects. And big projects tend to have more developer mindshare-- funny how that works...
Re:Mercurial: Onward and upward by kyrra on Friday May 01, 2015 @10:54AM (#9471761)
Except there are large projects using Mercurial without issue. See Facebook for example. If you want to look at open source projects, all of Mozilla uses mercurial[0] with just the standard hg-web server. And it's size is comparable (same order of magnitude) as the linux kernel)[1].

If you want to make such claims, I'd love to see data backing it up.

[0] https://hg.mozilla.org/

[1] https://www.openhub.net/p/compare?project_0=Mozilla+Firefox&...

Re:Mercurial: Onward and upward by rdtsc on Thursday April 30, 2015 @05:38PM (#9467831)
It was performance that made git win initially. In benchmarks git did better in the past when there was still a great Cambrian explosion of DVCSs (Monotone, Bazaar, Hg, Git, Darcs,...)

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.

Re:Mercurial: Onward and upward by mpdehaan2 on Thursday April 30, 2015 @08:22PM (#9468548)
The friendliness in the mercurial CLI ceased to be an advantage just a few years after git came out, IMHO. git error messages got better. I had to re-use mercurial after leaving it for git at one workplace, and I was cringing most of the time.

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 :)

Re:Mercurial: Onward and upward by zak_mc_kracken on Thursday April 30, 2015 @05:49PM (#9467881)
> I was really surprised that Git "won" because I thought that Mercurial's friendlier CLI and being written in Python would give it an advantage.

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.

Re:Mercurial: Onward and upward by lake99 on Thursday April 30, 2015 @06:03PM (#9467950)
> 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.

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

[2] http://www.infoq.com/news/2014/01/facebook-scaling-hg

Re:Mercurial: Onward and upward by zak_mc_kracken on Friday May 01, 2015 @12:14AM (#9469366)
You're not really disputing what I said: Mercurial is much, much slower than Git. Facebook forked it and managed to make it faster but they never released their fork so nobody can actually use it.

The bottom line is that a program written in C will always be orders of magnitude faster than a program written in Python. This is not news.

Re:Mercurial: Onward and upward by lake99 on Friday May 01, 2015 @06:46AM (#9470517)
> You're not really disputing what I said: Mercurial is much, much slower than Git.

Yes, I am. And I gave a reference for it.

> Facebook forked it and managed to make it faster but they never released their fork so nobody can actually use it.

I invite you to look up the license that Mercurial is released under. And then I advise you read [3]. And why do you keep making these unsubstantiated claims?

> The bottom line is that a program written in C will always be orders of magnitude faster than a program written in Python. This is not news.

If we're comparing exactly the same algorithms implemented in both Python and C, C would usually be faster. But we are not discussing the implementation of simple algorithms. We are talking about complex software, with different architectures.

[3] https://code.facebook.com/posts/218678814984400/scaling-merc...

Re:Mercurial: Onward and upward by digisign on Friday May 01, 2015 @01:16AM (#9469619)
And why parts of it are written in C.
Re:Mercurial: Onward and upward by s73v3r on Thursday April 30, 2015 @08:46PM (#9468653)
"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."

No, it doesn't.