105 points · by japaget · 13y ago · 124 comments
That said, once I got my head around the full ramifications of Git's lightweight branching, I still think it was the better choice over named branches and bookmarks. When learning Mercurial, SVN-minded me naturally gravitated towards branches for everything because of the name, and learning the distinction of when to use bookmarks and when to use branches wasn't exactly clear until I finally understood how Git's branches worked - and at that point the thought of enshrining branch names in the history forevermore suddenly turned from an obvious "why not?" to a "why?". Git's interface can always get better, but Mercurial will always have branches that live forever in history and are named "Branches".
Still, in Bizarro-2013 where Git never existed or never got the boost from Github, I think Mercurial would have been just as serviceable, and I think that it's a great second option to present if you want to migrate to a DVCS but your teammates can't get their head around Git. Kudos to them on another release.
There are also hg tools that help leverage named branches, e.g. revsets. Just today I wanted to figure out exactly on what commit did we merge the gui branch of Octave into default. I ran the following:
hg log -r "children(parents(branch(default) and merge()) and branch(gui))"
This told me that the merge happened a year ago, and told me exactly what commit did it. This would not be possible if the history did not record the branch name.
I like hg's way: bookmarks for lightweight changes, named branches for long-lived lines of development. Both have their place, and both are useful.
Edit: I didn't want to start a flamewar. I'm just wondering why Git seems more popular because I think both tools are very good.
Compare the Mercurial guidance on publishing repositories[1], which comes in at about 15 screens on my system, with the equivalents for say Git[2] or Bzr[3] that fit in a couple of screens, and you can see how striking the difference is.
[1] http://mercurial.selenic.com/wiki/PublishingRepositories [2] http://git-scm.com/book/en/Git-on-the-Server-Setting-Up-the-... [3] http://doc.bazaar.canonical.com/bzr-0.11/server.htm
[Edit: Rephrase to avoid sounding unintentionally trollish. I'm trying to answer the question, not start a flame war.]
Note that on the Mercurial wiki page you linked, it does mention ssh setup, although perhaps not as prominently as you'd like.
Also, hg /does/ come with a simple, self-contained server: hg serve. It doesn't support authentication, because there's a bunch of http servers that can do that for you better and with less bugs than we'd inevitably have.
Except that if you're running Windows rather than Linux, they don't. I have literally just tested it to make sure I'm not imagining things.
The difference is that with Git you probably also have Git Bash installed on Windows, which while somewhat clunky does at least provide a fairly standardised mechanism for setting up keys etc.
To my knowledge, there is no equivalent for Hg, and attempting to use hg with an ssh:// path to the repository seems to depend on what other software you have installed (Tortoise*, for example).
If you know better, my team and I would love to learn something. This has been bugging us for years and across multiple projects, and none of us has ever found a simple, effective way of doing it.
For the record, the mention of SSH setup on the page I linked to is literally just that: a mention, with no further details at all, and as noted above the obvious change of specifying an ssh:// path to a repository instead of a local one doesn't work by default on Windows. There's also a second entry for "Shared SSH", but that goes to a separate page describing half a dozen components that mostly aren't included with hg out of the box and again seem to lack much documentation in some cases.
[Edit: Yes, there is also hg serve, but as you point out it lacks even basic security checks, and even the main Mercurial web site doesn't recommend relying on hg serve for more than temporary purposes.]
[Edit 2: Rephrase to clarify shared SSH details.]
1. It does come with a simple self-contained server.
2. Why would you run anything off a network drive? Has no one learned from Visual Source Safe and the lessons of the definitely not glorious history of NFS file locking?
3. Literally all you have to read is: http://hgbook.red-bean.com/read/a-tour-of-mercurial-the-basi...
4. Git rebase. Ugh.
Now stop complaining, because I'm stuck with winzip and windiff as a VCS for the current thing I'm working on (an old and obsolete NT4 C++ behemoth that won't go away).
Yes. I use it daily, and so does my team, some of whom have also used it in other places as part of other teams. None of us knows a simple, effective, reliable way to set up a centralised server without going via one of the web server routes.
Literally all you have to read is:
No, it isn't. If you're going to be patronising, please at least have the courtesy to read your own links before posting. There is exactly one place in that document that refers to using direct SSH access, and as I've noted elsewhere in this thread, it doesn't work out of the box if you're using a Windows client rather than say Linux, a fact I have just personally confirmed before posting here.
I take it you have never tried darcs; it's the ultimate user experience nightmare.
I don't understand what you are getting at. If you have ssh access to the machine, then you can push or pull from a repo in that machine. It is that simple.
In that page, it details ALL the possible ways you can publish your repos. And goes into much detail regarding the hgweb set up. Setting user permissions etc. That is why it is big. The other two pages does not goes into much details. The git page only describes the ssh method.
Unfortunately, as I've been discussing with others elsewhere in this thread, it's not really that simple at all in some cases. I'm typing this on a Windows machine that has Hg installed, and I routinely SSH from this machine into various Linux servers that also have Hg installed, yet for reasons we've yet to determine, trying to access any sort of ssh:// repo using the hg command line client fails.
I am not aware of any data loss bugs in that area, or those are related to buggy network filesystems (in which case other VCS would also be affected). The usual issue around shared on disk repo is with permissions (and since a long time mercurial tries to be smart when creating new directory/files in order to propagate the perms regardless of umask).
Cloning a repo hosted on a Linux-based NAS/server to another location on the same NAS/server from a Windows machine tends to set up the clone using hard links rather than a true copy by default.
That in itself is not a problem, but unfortunately the Windows hg client doesn't seem to detect this situation reliably (or at least didn't last time I checked, which is a few months ago now). That means if you then commit changes, you can be unintentionally affecting the common linked files rather than separating them on demand first. The same was true for TortoiseHg the last time I checked, this again being a few months ago.
This is a particularly wicked bug because it means even if you've cloned a repo elsewhere on your network drive with the intent of keeping an independent backup of everything, both versions will be corrupted, and the first you're likely to notice is if you run an hg verify and find the index data for your original repo (which as far you know is untouched) suddenly has errors in it.
Incidentally, if you are using this sort of scenario for whatever reason, there is an option you can set at cloning time to force a full copy to be made.
I've also heard of problems with file locking being unreliable if you're using NFS to access the server, but the only cases I've seen were set up a different way so I can't offer anything more than a general warning in that case.
Otherwise setting up Apache + mercurial on windows is not very hard. If you need help please drop me a line.
Mercurial is fine, but its hard to ignore inertia. Similar to FreeBSD/Linux.
I use both Hg and Git at work, and to be honest for my basic workflow there are very few noticeable differences in day-to-day work.
My only concern would be that people are finding my mostly-bare github profile instead, since that rules the hivemind.
Like others have said though, I don't understand what a use case for this would be. The page for that Hg plugin seems to indicate that it is just meant to ease the transition to version control, for users who don't yet 'get it'.
I will say that file timestamps invoke horrible, horrible memories of an employer that used Visual Source[un-]Safe -- a VCS that relied on accurate client system time for history integrity. I.e. the repo was easily corrupted if a client wasn't on synchronized time. Also, race conditions. AFAICT, it met none of the conditions casually denoted by the words "Version Control System".
One company I worked for chose Hg instead of Git precisely because it had better Windows support.
One year and one acquisition later, every developer was on either Linux or OSX and everyone was asking why did we go for Hg if Windows was not a concern...
Linus works with git because Linux kernel development uses git. You have, by default, thousands of pretty savvy developers working with git.
From my daily experience with both Mercurial and Git, i would say the exact opposite. I can't think of anything that Git does better than Mercurial. I can certainly think of things it does in a needlessly more complicated way - the handling of remote tracking branches and the use of the index are obvious ones. Git's fixation on branches over commits is a persistent deep source of pain for users around me. And you can pry revsets from my cold, dead hands.
Now, there was a time when Mercurial didn't have bookmarks. During that time, if you wanted a good lightweight branching model, Git was your only option (er, well maybe bzr or Darcs were, who knows). I was never that excited about lightweight branching; the weight of heavyweight branches does not seem substantial. Today, Mercurial has bookmarks that work pretty much like Git branches, so this advantage has evaporated.
[1]: http://thread.gmane.org/gmane.comp.version-control.git/18977...
This post brings up one of the major issues with DVCS, if you have a large single repo, it just doesn't play well with git/hg. This is even more apparently if you have a lot of binary objects.
Large projects like Android get along swimmingly on git because they have structured themselves such that git is the right tool for the job. If Android insisted on having one single git repo, despite that not being a git best practice, they would have trouble too.
Structure things right and a git based system will scale far beyond what centralized monolithic repos like perforce can handle. If your codebase is growing properly big, splitting your code is something that you'll need to do eventually anyway.
That said, with Git, my main use of stash is to put away uncommitted changes so i can pull updates from the origin. Stash, pull, pop. However, Mercurial is able to pull changes into a working copy which has uncommitted changes - it essentially just treats it as a merge. This, with Mercurial, i need to stash much less often.
It's still useful as a way of putting changes aside while you work on something else, though, so i am glad to have it. The alternative was doing things with patch queues which were a bit scary.
JFTR: git 1.8.4 has --autostash as argument to rebase.
Cannot pull with rebase: You have unstaged changes. Please commit or stash them.
From what i remember of CVS, if i update into a working copy with changes, it applies the update where it can, and leaves merge conflict markers (or runs your configured merge tool) where it can't. That is also what Mercurial does.
Last week, some colleagues of mine 'lost' some commits because some other colleagues had misused a forced push. They could probably have got them out of the reflog, if someone had told them about the reflog in time; before i could, they recovered a diff from their console history. If they'd been using Mercurial, the situation just wouldn't have arisen; they would have had a branch with two heads, and they could have resolved that straightforwardly.
The fact that is would possible to recover from this situation using a command that one never has any other need to even know about is no excuse for the fact that it is even possible.
The would have this situation in Git too. If the Git-server was setup to only allow fast-forward merges, then they wouldn't be able (little uncertain here) to force it through either. Forcing something is never a good idea, even in Hg.
> The fact that is would possible to recover from this situation using a command that one never has any other need to even know about is no excuse for the fact that it is even possible.
So... Git provides a feature, allowing you to clean up history before merging (what it is mostly used for anyway). Git even provides an option to recover from these changes... And you're upset because colleagues of you who apparently didn't know Git, fucked up?
Git has a learning curve.
Atlassian Stash comes with a plugin that exposes a "Disable Force Push" toggle. I have that on for all the repositories it hosts. Nobody complains that force push doesn't work (~10 devs) because if you're doing force push you're probably doing something wrong.
git bills itself as the stupid content tracker. It's much better to add a small amount of smarts to ensure that you and your friends don't have to reach in the trash and get the changesets you erroneously deleted.
And it's not an error that the user tells git (s)he wants to remove or squash or whatever some commits. Git gives you that flexibility, which alot of people like, and at the same time gives users an undo-history in case they mess up.
On the other hand, I've used the reflog once in the last four months. For me, the use of reflog really has been exceptional.
Do instead: `pip install http://mercurial.selenic.com/release/mercurial-2.8.tar.gz`