News for hackers. Stuff that matters.
Re:Why I Switched to Git From Mercurial by steveklabnik on Monday May 17, 2010 @11:35AM (#1354571)
> I don't know how you could expect a delete not to be a delete unless you were familiar with something like git already.

Because it's version control; isn't the whole point that I can change things and return to a previous state?

I don't know anything about hg other than it being distributed, but if it destroys things, well, it's not a VCS as far as I'm concerned. That's crazy!

Re:Why I Switched to Git From Mercurial by dschobel on Monday May 17, 2010 @11:42AM (#1354584)
I'm not aware of any VCS which meets your standard of not allowing destructive commands (I'm sure you realize you can destroy history/data in git as well, right? It may take a --force, and it'll yell at you, but it's definitely doable)
Re:Why I Switched to Git From Mercurial by Shorel on Monday May 17, 2010 @12:44PM (#1354760)
Subversion, the most used VCS in the world, has no totally destructive commands per se.

Once you commit something, it stays in the repository in the commited version forever.

In SVN if you really want to delete a file, you have to stop the service, dump the repository to a text file, edit the dumped file to delete the data (or alternative, do not export the latest revision), restore the repository from the file, and restart the service. SVN has no native way to do that, you have to use some external utility to totally delete something.

Now, it can be argued that this is good or bad design, or that centralized VCSs are bad/distributed are good. But you are making a broad statement about VCSs and ignoring the existence of SVN, and this is misleading to anyone who reads this thread.

Re:Why I Switched to Git From Mercurial by kd5bjo on Monday May 17, 2010 @12:15PM (#1354669)
It's a lot harder than that, actually. You have to do --force, clear the reflog, and then run the garbage collector. Your data isn't actually removed from disk until the last step.
Re:Why I Switched to Git From Mercurial by dschobel on Monday May 17, 2010 @12:20PM (#1354685)
Yep, and beauty of the system is that anyone who is a sophisticated enough user to do that, would never do it accidentally.

Although, I imagine quite a few users --force a command and, unaware of the afore mentioned facilities, write up a nasty blog post about switching to hg from git because git lost their data :)

Re:Why I Switched to Git From Mercurial by MichaelSalib on Monday May 17, 2010 @01:34PM (#1354915)
Sophisticated users make stupid mistakes all the time. They misread output, get confused about the context in which they're operating, etc. Human beings are not machines. You cannot assume that just because a user is sophisticated, they will not make mistakes that lead to data loss. Even the best drivers still have accidents.
Re:Why I Switched to Git From Mercurial by steveklabnik on Monday May 17, 2010 @11:54AM (#1354613)
If I git rm something, and then git reset, my file is back. Are we talking about something different, or am I remembering git wrong? I don't actually git rm very often.

And it makes sense that there's a permanent delete feature, but I'd expect it to be outside of the normal workflow.

Re:Why I Switched to Git From Mercurial by sid0 on Monday May 17, 2010 @12:01PM (#1354631)
Yes, hg has a non-destructive rm too. And yes, what he's talking about is outside the normal workflow. Way, way outside.
Re:Why I Switched to Git From Mercurial by steveklabnik on Monday May 17, 2010 @12:02PM (#1354641)
Okay. Good. I thought it had to be that way.

So why do you speculate he's using the wrong delete?

Re:Why I Switched to Git From Mercurial by dschobel on Monday May 17, 2010 @12:14PM (#1354667)
Yeah, it's not clear what he did, all he references is a twitter posting saying he lost data: http://twitter.com/garybernhardt/status/9368728335 , not how.

I think it's fair to surmise that he must have been messing with commands he didn't fully understand.

The bottom-line is that in either git or hg you have to step past the screaming sirens and big red warning signs to truly lose data.

Re:Why I Switched to Git From Mercurial by sid0 on Monday May 17, 2010 @12:05PM (#1354646)
Because he lost data? hg rm wouldn't ever lose data. He probably used an hg strip (which is an advanced command and must specifically be enabled in .hgrc through the mq extension) but didn't realize what he was doing...
Re:Why I Switched to Git From Mercurial by garybernhardt on Monday May 17, 2010 @12:19PM (#1354684)
The command that lost data was hg qdel. Strip won't lose data; it dumps bundles (although they're a pain in the ass to restore from). Like I said, I used Mercurial for three years. And not "I play with it sometimes at night" kind of used, but rather "it was my main version controls system all day, every day" kind of used. I was using MQ for most of that time.

The fact that so many people consider "hg strip" an advanced command is part of the problem. Modifying history should not be considered advanced. Being able to recover from ANY command, including destructive ones, should not be considered optional.

Re:Why I Switched to Git From Mercurial by sid0 on Monday May 17, 2010 @12:54PM (#1354783)
> The command that lost data was hg qdel

Yes, so that deletes a patch. Anything in patches is basically in flux, and I wouldn't call losing a patch "data loss". If you call hg qdel "data loss", you'd call any sort of modification to a patch "data loss", since patches aren't versioned. If you want versioning with patches, use pbranches.

> Modifying history should not be considered advanced.

Maybe, but the only way I modify history in practice is through rebasing. I've never ever felt the need to modify history any other way. What use case do you have for modifying history in potentially destructive ways?

Re:Why I Switched to Git From Mercurial by garybernhardt on Monday May 17, 2010 @01:59PM (#1354999)
Git gives me everything I needed MQ for, but with the complete safety of the reflog. There is no such thing as a change I can't undo. The fact that patch management is "special" in Mercurial is the problem!

With respect to history modification:

First, I rebase a couple dozen times per day. I'm on a team that doesn't use merges unless we have a reason to (this makes it easier to bisect and think about history). I also create, destroy, and rebase many of my own branches every day.

Second, I amend commits a lot. I'll often spike some little piece of code I don't understand, then start amending the commit as I rewrite it with TDD, until the commit no longer contains any traces of the original spiked version. For more complex spikes and TDD rewrites, I'll do it over many commits, rebasing the spike over the rewritten version until the spike commit is empty and gets skipped by the rebase. Doing that in Mercurial would be... arduous. I can easily do multiple history rewrites per minute while doing this.

Third, I amend commit messages a lot, usually with "git rebase -i". Maybe I forgot the ticket number, or maybe the meaning of the commit changed (see the next point).

Fourth, I sometimes do drastic commit rearranging. This is harder to explain, but it usually involves splitting commits (in the simple case) or moving sets of related changes from one commit to another (in the complex case). These are sometimes at the file level, sometimes at the hunk level, and sometimes within a hunk. This is rarer than the others; I probably do it once or twice per week.

Fifth, I "git reset <ref>" a lot. It took me longer to start doing this, but it's useful in a lot of situations. For example, "oops, I accidentally created a merge bubble."

Re:Why I Switched to Git From Mercurial by utx00 on Monday May 17, 2010 @08:19PM (#1356021)
the patches directory that mq uses can be put under hg control.

i don't know about git reset, but everything you mentioned before can be done with mercurial (mq, histedit, ...)

Re:Why I Switched to Git From Mercurial by garybernhardt on Monday May 17, 2010 @09:30PM (#1356123)
Yep – and I did it all, using those tools, for a couple of years. :) Now, when I go back to Mercurial (which I know better than Git, mind you), I get frustrated. Those tools are much more blunt than their Git equivalents.
Re:Why I Switched to Git From Mercurial by utx00 on Saturday May 22, 2010 @06:02AM (#1370092)
so i tried it for a couple of days, and the speed was the thing that impressed me the most actually. the rest is not that dissimilar, but i didn't dislike it as much as i thought i would :) - our workflow assumes mq already so a git add is a qnew, or qref, a git diff --cache is a qdiff, a git diff is an hg diff ... so on. most commits i make are usually a qfinish, which is comparable to a git commit (no -a).

how do you manage patch queues in git? we need them because we are constantly backporting to different versions of our app. branches will mean n merges for n versions. stacked git? or is there a git native way to manage the same?

what about something like tortoisehg? gitk is pretty crude in comparison.

i assume one can glue a diff/merge tool like meld. is the experience similar when resolving conflicts?

thanks for any feedback.

Re:Why I Switched to Git From Mercurial by garybernhardt on Tuesday May 18, 2010 @12:25AM (#1356479)
Also, MQ's "qdel" command is the one that led to the data loss mentioned in the original blog post. So it doesn't really answer my concerns. :)