News for hackers. Stuff that matters.
Re:Prefer mercurial to git by masklinn on Sunday February 16, 2014 @10:48AM (#7247939)
> Where Mercurial falls short to me is that if you create a branch in your main repository like that, then it never goes away as far as I can tell.

`bookmarks` will do that. Or you can use unnamed heads and track them manually[0] (that's essentially what bookmarks — and git branches — do). "Detached heads" are not a thing in mercurial, heads don't have to be named.

[0] obviously there's nothing to track if you're just going on a short tangent, just commit your stuff, and go back to the original to merge if it was a good idea or forget if it was not. And yes you can create a bookmark "after the fact" e.g. do half a dozen commits, realise that it's going to take longer than you thought and create a bookmark for the current experiment on the tip.

Re:Prefer mercurial to git by dhimes on Sunday February 16, 2014 @11:05AM (#7247991)
This is it exactly. A lot of people miss this with hg. hg bookmarks are the equivalency to git branches. hg branches are "permanent." So you have, say, 'dev,' 'test' and 'stable' branches. Then you do hot-fixes and feature development on bookmarks, and merge them back into the branches.

It's a beautiful thing, really <tears up a bit..../>

Re:Prefer mercurial to git by exDM69 on Sunday February 16, 2014 @03:40PM (#7249181)
> hg bookmarks are the equivalency to git branches.

In my opinion, this is not all good although it clearly solves a problem. Having two somewhat non-orthogonal features for branching undoes a part of the easier learning curve argument. You end up having to educate people whether to use bookmarks or branches and in what situations.

If branches are permanent, who are allowed to create branches? Everyone or just maintainers/core developers? What if a would-be contributor creates a branch that isn't wanted as a permanent branch or has a bad name? Need to rename a branch or do some tricks to comply with the upstream conventions? It ends up being a similar social/political issue to git rebase vs. git merge.

The easier learning curve argument was more relevant when people were coming to hg from svn/cvs backgrounds. These days more and more people are coming from a git background.

Re:Prefer mercurial to git by alwillis on Monday February 17, 2014 @01:11AM (#7250853)
>Having two somewhat non-orthogonal features for branching undoes a part of the easier learning curve argument. You end up having to educate people whether to use bookmarks or branches and in what situations.

Like most things, it depends. But mostly no, it doesn't impact the learning curve issue, especially if your team uses the git branching model, you never even have to address Mercurials named branches.

I'd also say all the other advantages of Mercurial far out-weigh something a conceptually simple as "use bookmarks for git-like, non-permanent branches; use named branches for permanent branches." Done.

Re:Prefer mercurial to git by alwillis on Monday February 17, 2014 @01:18AM (#7250869)
This article is a little dated, but it conveys the flexibility of Mercurial branching.[1]

I don't know why git users get so hung up on named branches—you never have to use them if they don't make sense for your project.

[1] http://stevelosh.com/blog/2009/08/a-guide-to-branching-in-me...

Re:Prefer mercurial to git by dhimes on Sunday February 16, 2014 @04:51PM (#7249494)
Indeed, without a dictator controlling the 'central repo' you do have the issue of contributors borking your branches.

As far as learning curve, the branch/bookmark confusion doesn't seem to be all that big in practice IMO.

Re:Prefer mercurial to git by ufmace on Sunday February 16, 2014 @11:38AM (#7248139)
I hadn't heard of that, and it does sound like a nice feature, but it still seems a little hacky compared to Git branches. At best, it would be as good as them, but then why not stick with the original?

Oddly enough, I find myself liking the simplicity of Git here. You can do pretty complex stuff with it, but having only one type of branch seems to help some. That, and the local-only stashsets, which seem to be intentionally kept as simple as possible. In Mercurial, you have named branches, unnamed branches, cloned repos, bookmarks, maybe some other stuff that I don't know about, and I'm not really sure how they all interact and what's used for what.

Re:Prefer mercurial to git by twic on Sunday February 16, 2014 @12:04PM (#7248264)
hg's equivalent of stash is shelve:

http://mercurial.selenic.com/wiki/ShelveExtension

It does pretty much exactly the same thing.

Re:Prefer mercurial to git by masklinn on Sunday February 16, 2014 @11:45AM (#7248174)
> I hadn't heard of that, and it does sound like a nice feature, but it still seems a little hacky compared to Git branches.

It's exactly the same thing git branches do. If it seems hacky, it's also hacky in git.

> At best, it would be as good as them, but then why not stick with the original?

Stick with what original? The originals in mercurial are branches (where the branch name is part of the commit metadata and thus of the repository's history forever, save for history rewriting) and "anonymous heads".

Then users clamoured for transient (movable, renamable, deletable) git-style branches, so bookmarks were added as an option.

> cloned repos

Erm… you can also clone repositories in git.

> I'm not really sure how they all interact

At the end of the day, it's all commit DAG.

Re:Prefer mercurial to git by ufmace on Sunday February 16, 2014 @07:32PM (#7249996)
> It's exactly the same thing git branches do. If it seems hacky, it's also hacky in git.

I more meant that it seems hacky to add a feature that's mostly-sorta like Git branches to Mercurial now.

> Stick with what original? The originals in mercurial are branches (where the branch name is part of the commit metadata and thus of the repository's history forever, save for history rewriting) and "anonymous heads".

I meant original as in Git vs Mercurial. Like if you want Git-like branches, then why not just stick with Git?

> Erm… you can also clone repositories in git.

Yeah, you could, but I've never seen anybody recommend cloning a Git repo on the same computer for the purpose of separating out work from the main branch. At least for a while, this seemed to be widely recommended way of separating code out in Mercurial.

Where things get kinda weird - in Git, if you want to commit code somewhere that doesn't go into main just yet, there are only 2 options - branches and stash, and stash is explicitly meant to be a very short-term, local thing, since you can't really share them easily and they aren't really part of the commit hierarchy. That makes things simpler, as you never have to wonder what the right feature to use is for keeping separate work somewhere and sharing it with other people. You can create complex structures with branches, but at least there's only one 'type' of thing to keep track of.

I'm not as familiar with Mercurial, but for ways to keep temporary work somewhere, it seems we have named branches, anonymous branches, bookmarks, cloned repos on the same system, and apparently shelve too. According to this guy[1], the workflows for sharing bookmarks around don't seem to be fleshed out all that well either. So how do I know which one to use for what tasks?

[1] http://www.kevinberridge.com/2012/05/hg-bookmarks-made-me-sa...