Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Mercurial bookmarks are equivalent to git branches, but Mercurial branches have no equivalent in git. In Mercurial, branches give you a way to track the branches a commit is a part of which is good for long-running branches (I think of things like master, maybe a long running refactor or major feature branch) while bookmarks are great for the more normal workflow of small, focused, feature branching. Neither of those are designed to cover a gap in the core design, they are a _feature_ of the core design that git doesn't even have.


>branches give you a way to track the branches a commit is a part of which is good for long-running branches

I think you have a slight misunderstanding on the differences between git and mercurial, as git absolutely allows you to do this. Mercurial tends to track this information in a way where it actually limits telling you what branches a commit is contained in. Git will tell you straight up which branches lead back to a commit (i.e., being contained in them). Mercurial tends to only give you immediate, direct ancestors, any kind of complicated history and Mercurial can't be bothered to actually to dive in and tell you what branches a commit is really apart of.

That seems to be strangely counter-intuitive for "long running branches."

Git doesn't need an equivalent of Mercurial branches and bookmarks, because git branches do everything both of those mercurial features do and more, in a far more lightweight and efficient manner contained in a clean, singular feature.


> Git doesn't need an equivalent of Mercurial branches and bookmarks, because git branches do everything both of those mercurial features do and more, in a far more lightweight and efficient manner contained in a clean, singular feature.

Not quite everything. Since Mercurial branch names are baked into the commit, if you wanted to know which branch a commit was originally part of, you can find out.

Git does not support this. If two branches have parent commits in common, it technically belongs to both branches.

There is a valid conversation to be had on if this feature is actually necessary or makes sense in the context of a DVCS, but git branches are not a full substitute for Mercurial branches.


> If two branches have parent commits in common, it technically belongs to both branches.

It belongs to both branches as well in Mercurial, it just hides that information from you. An astoundingly bad idea, no? I'm not sure how mercurial hiding information from you is a "feature" in any sense of the word.


Hiding or encapsulating information is arguably part of the very nature of an abstraction; the CLIs provided by git and Mercurial could be considered an abstraction of the implementation details of the respective technologies.

As such, I fully expect each tool to hide some amount of information so that I don't have to think about the details.


There's no easy quick way to represent the actual state of the commit. It's far easier in git because it's the only way to do it. Furthermore, then information being "encapsulated" can actually become stale or misleading in Mercurial.


Mercurial records in every commit, that branch it was made. It is part of it's identity. That is what the parent is talking about. Git does not do this. Because git does not have this concept of named branches.

In other words, Mercurial has feature branches, while git has developer branches. This gives much more possible workflows in case of Mercurial.

>Mercurial tends to only give you immediate, direct ancestors, any kind of complicated history and Mercurial can't be bothered to actually to dive in and tell you what branches a commit is really apart of...

http://stackoverflow.com/questions/7166011/mercurial-find-al...

Is that what you are talking about?

Mercurial contains vastly more querying capabilities in the form of revsets. No such thing exists for Git.

If you go head to head with git vs mercurial, git will loose pathetically.


>Git does not do this. Because git does not have this concept of named branches.

It doesn't pre-bake the information in the commit, because it's entirely useless information to bake into a commit; and even in the case of Mercurial can paint the wrong picture about the nature of a commit given branches that it's on.

>This gives much more possible workflows in case of Mercurial.

That is the exact opposite of what it gives you. I'm not even sure how you possibly arrived at that conclusion.

>Mercurial contains vastly more querying capabilities in the form of revsets.

Git doesn't need a query language, because you can literally do everything revsets will give you with git log and then maybe some very elementary bash script knowledge. You are literally arguing that Mercurial having its own arbitrary DSL is somehow better than git being able to seamlessly use popular tooling with conventional command line syntax; which seems to be at odds with the whole "mercurial is easier to use." I take extreme issue with your claim that Mercurial has "vastly" more querying capabilities and then you not even give one measly example.


>because it's entirely useless information to bake into a commit;

I have found it very useful in untangling a complex history. You might not see the value in it becuase git does not care to maintain a truthful history, but promotes building a "clean" history. It makes sense to do that if you are maintaing somethign like linux kernal. But for smaller projects, maintaining a truthful history is much more valuable.

So I would say that it is extremely valuable information in the context of Mercurial.

And there are other version control systems that follow similar model. Take a look at the '3.3 Branches' heading in another fantastic version control system called 'Fossil' here [1].

>That is the exact opposite of what it gives you. I'm not even sure how you possibly arrived at that conclusion.

Well, Mercurial supports git's branching model and a lot of others. I am not sure how that is not clear.

>Git doesn't need a query language...

Of course. It is not meant to be used by mere mortals..

>because you can literally do everything revsets will give you with git log ...

Are you seriously saying that using command line flags is more powerful and easier than using a query language that lets you use arbitrarily expressions to query a data set?

> I take extreme issue with your claim that Mercurial has "vastly" more querying capabilities and then you not even give one measly example.

Checkout the link I mentioned in my earlier comment.

This is the manual page for revsets [2]. Please take a look.

[1] http://www.fossil-scm.org/fossil/doc/trunk:2012-01-01/www/fo...

[2] https://www.mercurial-scm.org/repo/hg/help/revsets


>But for smaller projects, maintaining a truthful history is much more valuable.

Elaborate.

>Mercurial supports git's branching model and a lot of others.

Except, it doesn't completely.

>Are you seriously saying that using command line flags is more powerful and easier than using a query language that lets you use arbitrarily expressions to query a data set?

Yes, because command line flags are ubiquitous in nearly every single tool, versus an arbitrary DSL that has no convention behind it, or can be easily parsed by other tools in the same ecosystem.

> Please take a look.

You seem to be under the impression that I have not or do not use Mercurial. You would be mistaken. Both of those pages do not lend support to your claim that the ability to "query" (with or without a DSL) the history graph is somehow superior in Mercurial. They merely document the feature, but do not draw any meaningful comparisons highlighting what it can do that git log or even git rev-list (which git log uses) can't.


> Elaborate

For example, to answer questions like "What feature was this commit part of, originally". "How and where did the merges happened?". To answer these questions months after the merges happened, even after you did't think that you would need to answer these questions, something like the workflows mercurial is essential.

>Except, it doesn't completely.

Elaborate?

>Yes, because command line flags are ubiquitous in nearly every single tool

Ok. But that does not mean that it is powerful enough and can be a replacement for or better than a proper query laguage..

> arbitrary DSL that has no convention behind it

What convention? I am not getting you.

>can be easily parsed by other tools in the same ecosystem.

Parse what exactly?

>Both of those pages do not lend support to your claim that the ability to "query" (with or without a DSL) the history graph is somehow superior in Mercurial. They merely document the feature, but do not draw any meaningful comparisons highlighting what it can do that git log or even git rev-list (which git log uses) can't.

Oh it does support it plenty. Take a look at the vocabulary supported by revsets in form of intuitive and easy to remember predicates. I don't think you are really impartial if you are not convinced by it.


>to answer questions like "What feature was this commit part of, originally"

Neither system will answer that. If you're relying on branches to tell you what feature sets changes belong to, you should be adding that to your commits.

>"How and where did the merges happened?"

Git will do this faster and in a more correct manner. In a complicated history graph, Mercurial will actually hide information from you if you try to query it and sometimes even mislead you. I'm starting to think you haven't used either system extensively.

>Parse what exactly?

Arguments and output.

>Oh it does support it plenty.

It does not. If you can't give an example, you can just admit that you don't know what you're talking about.


>Neither system will answer that....

I am not sure what you are talking about. Every change set in Mercurial contain the branch in which it was made. Even after a merge, there is a clear distinction about the commits made in a certain branch.

I think you might be thinking of rebased change sets. In that case, you would be right.

>Git will do this faster and in a more correct manner..

Please show an example. I would also like to see an instance where Mercurial hiding information from you and giving misleading answers to your queries.

>Arguments and output.

But it is supposed to be used by people. So it should be first human friendly. And there is nothing stopping you from parsing output of mercurial commands. And what is the use case of parsing arguments? Why did you think so? Mercurial has even a template feature letting you format the output in any way you want. I am not sure, it seems to me that you are not making a whole lot of sense..

>If you can't give an example, you can just admit that you don't know what you're talking about.

There are some examples at the bottom of the revset page I linked. Knock yourself out. And do share some examples of your claims, because your last commits contained enough stuff to doubt your experience..(stuff about conventions and DSLs, what was that again?)


> I would also like to see an instance where Mercurial hiding information from you and giving misleading answers to your queries.

A branch with two heads. Two branches that have the same name. Which commit came from where? What happens if that branch was merged into the other? Or what happens if only one got merged into a "mainline" branch, while the other one was reverted else where. It's useless information at best, and misleading at worse.

>But it is supposed to be used by people. So it should be first human friendly.

You're going to claim a DSL that you have to research is somehow easier to use than simple command line arguments that have decades of convention behind them? Odd.

Git allows you to format output as well. Not sure why you felt the need to bring that up. Again, unless you've extensively used both systems I'm not sure why you feel the need to argue because it's making you look foolish.

>There are some examples at the bottom of the revset page I linked.

And absolutely none of them help your argument.


> It's useless information at best, and misleading at worse.

It seems useless to you because you see it from a git viewpoint. It is clear when you say that "Two branches that have the same name". It is not "two branches", but one branch with two heads. In Mercurial, a Branch is a set of commits. That view is incompatible with the thing that git call "branches".

If you think about it, Mercurial's implementation of a Branch is closer to the idea of a "Branch". As I told earlier, Mercurial branches are "Feature" branches". I am not sure if you have gone through the fossil doc page I linked earlier. When you see it like that, it makes complete sense that a Branch can have any number of heads. Say, the second head containing a different implementation of the same feature.

(God I miss Mercurial)

>Which commit came from where? What happens if that branch was merged into the other? Or what happens if only one got merged into a "mainline" branch, while the other one was reverted else where. It's useless information at best, and misleading at worse.

These questions are the result of trying to make sense of Mercurial branches in a GIt way..

>what happens if only one got merged into a "mainline" branch, while the other one was reverted else where.

Again, this question is a result of you seeing mercurial branches in a git way. Because git define a branch as the set of commits starting from a "head", the idea of merging only one of the heads does not make sense to you.

But you can do the same with git, right. You can move back couple of commits from a head and create a new head by starting committing from there. Only that in git, the previous head would be hidden. And you will have to go to the reflog to dig them up. But in Mercurial, things are much clearer and exposed (contrary to your accusation of it hiding and misleading).

So again, it feels misleading to you because it is different from git. It is very consistent in conforming to its on model.

>You're going to claim a DSL that you have to research is somehow easier to use than simple command line arguments that have decades of convention behind them? Odd.

I am not at all getting you here. "command line arguments that have decades of convention"? What exactly does that mean? And what is the thing about "a DSL that you have to research"?. You don't have to look up command line arguments of git? And you call git's command line arguments simple?

>Again, unless you've extensively used both systems I'm not sure why you feel the need to argue because it's making you look foolish.

I didn't claim that git does not allow you to format the output, but just that Mercurial allows you to do that so that your argument about easily parseable output is moot.


Could you maybe specify better how this is implemented in hg so that I can understand why it would be better than:

    git branch --contains <commit>


When you make the commit, hg records in the commit which branch you were on when you made it. It becomes a permanent part of the commit. Regardless of whether you later merge or even delete that branch, the association between that branch and that commit is still there.

I personally don't understand the use case, and prefer git's way of handling things, but I don't rule out that other people find it useful.


One use case is given branch X, tell me what the branch looked like N commits in the past. Git cannot tell you this because all parent commits are equal. DVCS workflows tend towards lots of short-lived branches where it is less useful (which is why hg has bookmarks).

It can also just simplify certain things. I can tell by checking if a commit is reachable from e.g. the v1.2 bugfix branch but not from master that the commit was post the 1.2.0 release to fix a bug.

With hg branches you can just see that the commit was made the the v1.2 bugfix branch. This is very minor, but my experience with hg is that there are dozens of these minor niceties that are why a lot of hg users are still around despite git having clearly won the popularity contest.


>One use case is given branch X, tell me what the branch looked like N commits in the past.

What am I not understanding here? You definitely can go N commits in the past on each branch, and even any commit. And if you rewrite history you can even use the reflog to really tell what the branch was like (as long as it hasn't been cleaned out).


    ┌─────┐◀──────── master
    │Merge│◀──────── bugfix
    └▲───▲┘
     │   │
     │   │
     │  ┌─┐
     │  │B│
     │  └▲┘
    ┌─┐  │
    │A│  │
    └▲┘  │
     └───┤
         │
    ┌────────┐
    │Ancestor│
    └────────┘
Which branch was commit `B` made on? What did the `bugfix` branch look like one commit ago?


Nice use of Unicode! Do you have a tool to help you construct a diagram like this?


If you were in master when you merged bugfix in ("git merge bugfix"), then you can

  git cat-file -p master
and see which commit, A or B, is listed as the first parent. This belongs to the master.


> Which branch was commit `B` made on

You can do some basic heuristics to figure it out, but I'm not sure what the point of knowing this is.

>What did the `bugfix` branch look like one commit ago?

`git checkout bugfix; git log bugfix^1`


In the case of merges, how would you tell which parent to look at? Branches might have been deleted, moved, or merged.

> And if you rewrite history you can even use the reflog to really tell what the branch was like (as long as it hasn't been cleaned out).

The reflog is not moved across remotes, is it? If I make a fresh clone of a repository, that doesn't tell me what the branch was like a year ago.


You're right, it's not moved across remotes. I'm just confused to why the information would ever be needed. It seems to not have any real use case. You can recreate a branch any where at any point in the history, why would you care what commit a branch originally came from? It seems like a solution in search of a problem. Or maybe even a solution to a problem that shouldn't need solving in the first place!

>If I make a fresh clone of a repository, that doesn't tell me what the branch was like a year ago.

This isn't true with Mercurial either. A lot can happen in a year, and it might even make the information misleading (having similar named branches, history deletion, etc). It's useless at best and misleading at worst.


"This commit has a bad commit message. Why did I commit it? Oh, it's on the branch add-search-functionality."

I find that having a branch name that was the sole branch name when the code was made gives context to the commit; why it was made and what its purpose was. Being reachable from a branch pointer doesn't give that same context. Yes, commit messages should handle this. But I find they don't.

> It's useless at best and misleading at worst.

This has not been my experience. I haven't found a great need for "what's the whole state a year ago"; more so "what was the context around this commit", which I think a mercurial-style branch name answers.


I'm sorry, in what practice are you in where your commit messages are somehow so lackluster that a branch name (not even a PR!) can give you more information about why something is being done?

And to make sure no one responds with some silly "just because you don't have a use for it, doesn't mean don't have their uses for it": I get what you're trying to say. I'm really just not buying it as an actual use case. If your commit message isn't sufficient enough to explain the purpose of the commit (ticket numbers, explanation, etc), it doesn't get approved. If you're relying on a <20 character branch name to give you sufficient context about a commit a year later, I simply have no words.

>which I think a mercurial-style branch name answers.

I find that extremely suspect.


> If your commit message isn't sufficient enough to explain the purpose of the commit (ticket numbers, explanation, etc), it doesn't get approved.

I'm glad this is the case where you work and develop. I have never worked at a company where this is the case. I'm also not perfect about commit messages in my personal code. The codebase I'm currently working on has recent commits with description "review", "add addressDto" and "post rebase fix".

> >which I think a mercurial-style branch name answers.

> I find that extremely suspect.

Ok. If I see "add addressDto" as a part of the branch "google-geocoding", that tells me the context. If I see it as part of "refactor-to-use-hibernate", that also tells me something useful.


>The codebase I'm currently working on has recent commits with description "review", "add addressDto" and "post rebase fix".

I guess what I don't get, is that if you have people doing commit messages like that, how can you possibly expect them to appropriately name a branch which most likely stores far less characters.


Far too often the commit message says "what" while the branch name says "why."

Just recently I had to triage a recently discovered bug whose symptoms disappeared about 4 years ago to determine if the bug was fixed or just masked. This was code that I was completely unfamiliar with because the other engineers that might have looked at it were otherwise indisposed working on things that were known for sure to be issues.

The "what" told me the specific change that masked the bug and the "why" informed me of the feature that this supported. That allowed me to generate a new test-case that showed up in the current version. Without both pieces of information I would likely have had to spend a couple of hours inspecting code changes to do the same.


If you can't trust your developers to write acceptable commit messages, why are you trusting them to write code?


Because you're less in the nitty-gritty when naming a branch, so you're more likely to name it with something referencing the large feature you're working on.


I work with two codebases with over 200k commits and over 10k branches each. Sometimes the branch names are useless. Sometimes the commit messages are poor. Often knowing one helps provide more context for the other.

Believe it or not, there were times in the last 20 years when there was insufficient review of commit messages!


It's sometimes very useful, but not that often. It's not great for short lived feature branches. It's for long-term branches. If you don't need those (and most often you do not): great, your life is (relatively) simple; don't over-complicate it. You don't buy the use-case, because the situation is not that common or desirable. But once you get in a situation where you really do need multiple long-term branches developed in parallel, you might be happy to have a tool that helps untangle the web of merges somewhat.


>It's for long-term branches.

Please elaborate how this helps you in long-term branches, instead of just assuming long-term branches aren't something most people deal with on a daily basis.

>you might be happy to have a tool that helps untangle the web of merges somewhat.

This has no relation to long-term branches, this happens with any kind of normal history, and even shared history between repositories (which is a far messier thing to untangle). Yet this feature is unneeded, because the information can be correctly found within git in an accurate and not misleading fashion.


> branches give you a way to track the branches a commit is a part of which is good for long-running branches (I think of things like master, maybe a long running refactor or major feature branch)

If you always merge "from the right direction", you can follow the first parent line in git and reconstruct which parent is in the master branch (or in the "heavier" branch in general) and which isn't.

In more complicated situations, Mercurial named branches (commit forever carries the branch name) can be helpful. But you can get pretty far with git, too.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: