News for hackers. Stuff that matters.
Re:Mercurial 4.0 Sprint Notes by the_duke on Tuesday October 18, 2016 @12:19PM (#12735949)
I had no idea Google and FB were dabbling with Mercurial.

I checked it out years ago, but pretty much settled on Git.

What are the advantages?

Re:Mercurial 4.0 Sprint Notes by kyrra on Tuesday October 18, 2016 @12:53PM (#12736367)
1) The .git directory doesn't play nicely with mono-repos. Since all files are just hashed files that live in the .git dir, knowing which files in there are part of a subtree is hard. On the other side, Mercurial .hg dir uses a tree structure to track files, so you can do things like NarrowHG[0].

2) As well, Git has multiple client implementation (like git, egit, jgit, etc...). Adding new features is a bit more complicated as all the implementations need to add them before they can be more widely used. Mercurial has one implementation that everyone uses. So new features are easier to add.

3) The .git structure is simple, which is great, but it's become the API for git in a way. While mercurial explicitly says you should never rely on the structure of the .hg directory. If you want to interact with the .hg dir from other software, you should either issue 'hg' command or start up a command server[1] to talk with it. So it creates a cleaner API barrier. Because of this, the Mercurial team can make changes to the .hg dir to better serve different needs (like those of a mono-repo), without breaking the world.

[0] https://bitbucket.org/Google/narrowhg

[1] https://www.mercurial-scm.org/wiki/CommandServer

Re:Mercurial 4.0 Sprint Notes by avar on Tuesday October 18, 2016 @03:30PM (#12737881)
The .git file format has also changed multiple times, packed refs, multiple pack file formats etc. There's even WIP ref backends now which store the whole thing in some embedded database format.
Re:Mercurial 4.0 Sprint Notes by alblue on Tuesday October 18, 2016 @05:46PM (#12739018)
There is no ".git" file. It's a directory with a lot of files. Some of the packing has been storage optimisations but the logical model (objects identified by hash) has remained the same throughout.

The nice thing about this is you can present the same logical model while being flexible about the way that model is persisted, unlike Mercurial which has a fixed file format upon which operations are based.

Re:Mercurial 4.0 Sprint Notes by s_kilk on Wednesday October 19, 2016 @04:09AM (#12741982)
Mercurial also has a proper plugin architecture, which means that new features can be developed in the wild as needs arise, and then either become widely used or rolled into the standard distribution.
Re:Mercurial 4.0 Sprint Notes by bedros on Tuesday October 18, 2016 @11:34PM (#12740858)
narrowhg looks like a good replacement for subrepo, thanks for the tip
Re:Mercurial 4.0 Sprint Notes by Mathiasdm on Wednesday October 19, 2016 @02:42AM (#12741607)
Keep in mind that narrowhg is extremely experimental!
Re:Mercurial 4.0 Sprint Notes by cm3 on Tuesday October 18, 2016 @12:50PM (#12736327)
The possibility of extending the Mercurial core with a well-defined API is one major reason. In fact, most interesting features are extensions, bundled with Mercurial, and after several releases and experience, the functionality usually gets integrated into Mercurial proper (most often than not still as an extension). This is, unfortunately not an C API but Python, but it's still an advantage Mercurial has for now. Git has various efforts to build reusable libraries to write tools with, but there isn't an officially sanctioned _and_ complete one that works across all platforms. Microsoft has removed their reliance on libgit2 and shells out to git in Visual Studio now. If the git project had an official libgit, which exposed all functionality, is reused by git itself, and worked across all platforms, the situation would be in favor of git because consuming a C API is more broadly supported than, say, using a Python API inside a .Net application.

tldr: Git is still faster overall, but those who want to extend a dvcs choose Mercurial for its API that exposes the data structures in a stable manner, albeit in Python, which limits use cases.

Re:Mercurial 4.0 Sprint Notes by pjmlp on Tuesday October 18, 2016 @01:15PM (#12736621)
Actually the fact that Mercurial uses Python is what made it quite usable on Windows from the get go, before Microsoft and others bothered to step up and improve the experience.

As for using Python on .NET, that is what Iron Python is for.

Re:Mercurial 4.0 Sprint Notes by cm3 on Tuesday October 18, 2016 @01:35PM (#12736830)
Of course Python as an abstraction layer made it more readily available on Windows and allowed allocation of developer resources to hgtk, including a Windows Explorer extension.

Still, despite its flaws, C is the common layer we have to expose an API that you want to be consumed everywhere. That, or a message passing interface with a client/server architecture. A client/server design may lead to zombie servers, while a tightly coupled C API might crash your application, though you can isolate the C API consumer in a supervised and automatically restarted server you talk to with messages, so that's the more flexible API to have.

The Rust rewrite of parts of Mercurial by Facebook is a no-brainer and given the possibility of GC-less C API in Rust, I wouldn't be surprised if a built-in-Rust C API for Mercurial were to follow. I don't like Rust when compared to high-level languages, but it's a viable C replacement with compile-time exclusion of certain bug classes, so I can get behind such a project. That said, the soundness bugs reported on github are worrisome, so I wouldn't trust Rust's checker to be correct or exhaustive, just yet. It's still a step up from C, that's undeniable.

Re:Mercurial 4.0 Sprint Notes by pjmlp on Tuesday October 18, 2016 @02:22PM (#12737234)
Well, on Windows we also have COM, but I get your point.

Going off topic, maybe someone will eventually do a SQLLite re-write as well and other critical projects to our modern stacks that still rely on C.

Re:Mercurial 4.0 Sprint Notes by cyphar on Tuesday October 18, 2016 @02:41PM (#12737409)
> Going off topic, maybe someone will eventually do a SQLLite re-write as well and other critical projects to our modern stacks that still rely on C.

SQLite does not need to be rewritten. It has the best and most comprehensive test suite in the history of software development -- I would go so far as to say that there are no implementation bugs in SQLite (every single branch in the code has been extensively tested and also extensively tested with dummy failures and so on). So a rewrite in a safer language would benefit nobody (and would just be a huge time sink).

Re:Mercurial 4.0 Sprint Notes by jjnoakes on Tuesday October 18, 2016 @06:26PM (#12739287)
I'm not advocating one way or the other, but I will say that I don't believe 100% code coverage guarantees that you have no issues lurking that a safer language would prevent.

Now it probably isn't worth the effort for a very well tested project like sqlite, but that doesn't validate the premise.

Re:Mercurial 4.0 Sprint Notes by cyphar on Wednesday October 19, 2016 @07:46AM (#12742921)
> but I will say that I don't believe 100% code coverage guarantees that you have no issues lurking that a safer language would prevent.

It's 100% branch coverage, with 100% fault coverage as well. If there is an "issue lurking that a safer language would prevent" I would honestly be shocked. SQLite is not a good project to mention rewriting, because it is an incredible technical acheivement in terms of how well tested it is.

Re:Mercurial 4.0 Sprint Notes by jjnoakes on Wednesday October 19, 2016 @09:32AM (#12743575)
> SQLite is not a good project to mention rewriting

Which, as I said, is not what I'm doing. I'm only disagreeing with the premise that 100% test coverage means 0% chance of an unsafe bug existing in the code base (for any code base, not just for SQLite).

Re:Mercurial 4.0 Sprint Notes by cyphar on Wednesday October 19, 2016 @10:05PM (#12749357)
Personally, I consider 100% branch coverage to mean an effectively 0% chance of an unsafe bug existing in the code base. Does Rust have 100% branch coverage in their compiler? So how can you be absolutely sure their compiler doesn't have bugs when doing borrow checking and other tomfoolery? 100% branch coverage is an _insanely_ high standard and you can't compare it to any other project unless that project also has 100% branch coverage or similar.
Re:Mercurial 4.0 Sprint Notes by denfromufa on Tuesday October 18, 2016 @01:59PM (#12737031)
Python for .NET (pythonnet) allows to bridge CPython and .NET/Mono runtimes.
Re:Mercurial 4.0 Sprint Notes by lucideer on Tuesday October 18, 2016 @12:27PM (#12736061)
The biggest technical difference is the mostly immutable history, which is a feature or a drawback depending on who you talk to.

More subjectively, most people I've chatted to about it seem to find Mercurial's interface much easier to grok / pick up as a new user than Git's (which is somewhat notorious for its quirks).

There are other differences, but these stand out to me. That said, I use Git because adoption + community (and my experience with hg-git has been less successful than some... though it's been a while since I gave it a spin)

Re:Mercurial 4.0 Sprint Notes by marcinkuzminski on Tuesday October 18, 2016 @12:46PM (#12736276)
CTO of RhodeCode here.

If you use phases (draft/secret/public) correctly it's really close to being mutable. For example all our devs forks are having non-publishing repositories since it's a private non-shared space. By keeping all commits as draft it's easy to do a rebase and then push new changed commits.

While the main repo is publishing and once pushed commits are never mutable, also we keep a workflow that only dev forks can have multiple heads while production repo cant.

IMHO it's the nicer form of mutability

Re:Mercurial 4.0 Sprint Notes by Bjartr on Tuesday October 18, 2016 @04:40PM (#12738465)
Do you have or know of writeups describing this workflow in more detail? I'm interested in learning more.
Re:Mercurial 4.0 Sprint Notes by ngoldbaum on Tuesday October 18, 2016 @04:58PM (#12738656)
This workflow is described in the documentation for the mercurial evolve extension: https://www.mercurial-scm.org/doc/evolution/
Re:Mercurial 4.0 Sprint Notes by marcinkuzminski on Wednesday October 19, 2016 @07:50AM (#12742936)
Here's a blog post on how to use Bookmarks in Mercurial workflow using code-review. We back ported from one of the guys that works for us and described our workflow:

https://rhodecode.com/blog/120/mercurial-workflow-using-book...

Re:Mercurial 4.0 Sprint Notes by jjnoakes on Tuesday October 18, 2016 @06:28PM (#12739294)
Can you elaborate on what you mean by immutable history, and how git lacks it?
Re:Mercurial 4.0 Sprint Notes by lucideer on Tuesday October 18, 2016 @08:45PM (#12740044)
In git you can edit past commits and rebase, which completely destroys historical data and traces of the rebase. This can be very useful, e.g. for keeping a frequently-committed-to branch "clean" and informative by squashing commits, for removing accidentally committed sensitive credentials, etc.

Mercurial, on the other hand, is architecturally set up in a way that considers the repo history to be a somewhat "sacred" truthful account.

You still get the same flexibility as git if/when you need the above mutability: it's not 100% immutable, it supports local rebases, and also global mutablity via "phases" - see Marcin's post on this. In an absolute worst case scenario you can also coordinate reclones of a repo of course, but generally speaking the point is that immutability is "on by default".

Re:Mercurial 4.0 Sprint Notes by jjnoakes on Wednesday October 19, 2016 @08:13AM (#12743051)
I'm sorry, I still don't see the distinction. It sounds like in both systems the default is immutability, with commands to override that if necessary.

And by the way, doesn't git rebase not mutate history? I believe it creates a parallel history (and updates the branch and head refs to point to the new history) but the old history still exists in git's storage and can be recovered (until you GC your storage).

Re:Mercurial 4.0 Sprint Notes by jordigh on Wednesday October 19, 2016 @01:37PM (#12745849)
In git, you `git rebase` any commit will always do whatever you tell it to do.

In Mercurial, `hg rebase` will abort if you're trying to make it do something to public commits. Public commits are commits that have been shared on a publishing server. The contrast with draft commits, which are commits that have not been shared or only shared on a non-publishing server.

If you really want to edit public commits, you have to manually force them back to the draft phase before you can rebase or rewrite them.

Re:Mercurial 4.0 Sprint Notes by jjnoakes on Wednesday October 19, 2016 @02:26PM (#12746328)
If you "git push" after rebasing published commits, you get an error, unless you use "--force" or you pull and merge manually before hand.

So I'm still not sure the distinction you are making between which one is "immutable" and which one isn't.

Re:Mercurial 4.0 Sprint Notes by jordigh on Wednesday October 19, 2016 @03:10PM (#12746762)
Phases catch this problem early before `git push`. You don't want to run into the problem too late. Then you'll be faced with the decision to throw out your work because you accidentally rewrote something that should not have been rewritten. Or you'll have to decide at the last minute that you really did mean to make problems for everyone else.

Btw, with Mercurial Evolve, there's no need to force-push, as Evolve will propagate meta-history to other users that indicates what commits replace which ones.

Re:Mercurial 4.0 Sprint Notes by jjnoakes on Wednesday October 19, 2016 @03:22PM (#12746874)
Ok so it has nothing to do with immutability, it's just one warns earlier than the other.

Thanks for clarifying.

Re:Mercurial 4.0 Sprint Notes by jordigh on Wednesday October 19, 2016 @03:27PM (#12746922)
It is about immutability. No Mercurial command (histedit, rebase, uncommit, amend) will allow you to change an immutable (public) commit unless you first force it back into the draft phase.

You can say that because you can always force public commits into drafts that they're not really immutable, but that's a bit of a perversion of what Mercurial's phase system is intended to do.

Re:Mercurial 4.0 Sprint Notes by jjnoakes on Wednesday October 19, 2016 @04:11PM (#12747274)
And no git command lets you change what public history looks like unless you --force the push.

So the check is in a different place. That doesn't seem to me to imply that Mercurial's history is "immutable" and git's is "mutable", especially since those words have precise meanings, and even WITH the --force, git doesn't change anything in the history, it just writes out a new history and updates the branch ref to point to the new history.

The only thing mutated (in both systems) is the ref to the branch head, right? So aside from warnings and errors being in different places (both before publish time), what is the difference between the two that leads you to argue that one is immutable and one isn't?

Re:Mercurial 4.0 Sprint Notes by marcinkuzminski on Wednesday October 19, 2016 @04:15PM (#12747313)
I think what Mercurial brings here is that even if you have a repo and you do a force-push you keep all the heads. Thus it's almost like a history of changes.

I think if you do a code-review and you get the final state of the repo to check, you can nicely tell how it was evolved/squashed/re-ordered.

I find that workflow much more useful than just rewriting history like in git (i know about reflog)

Re:Mercurial 4.0 Sprint Notes by RandomOpinion on Tuesday October 18, 2016 @08:01PM (#12739820)
To add my 2 cents, immutable history is more of an annoyance than anything. If someone checks in something by mistake that absolutely must be removed (e.g. something that contains a password), it is a considerable undertaking to actually remove that commit from the repository.
Re:Mercurial 4.0 Sprint Notes by agentgt on Wednesday October 19, 2016 @09:02AM (#12743343)
It is not hard once you know how to do it is just not readily documented (ie histedit and force push).

BTW if you checked in a password... you really should now go change that password :)

Re:Mercurial 4.0 Sprint Notes by RandomOpinion on Saturday October 22, 2016 @02:47PM (#12769994)
I know better than to check in passwords, thank you very much. Regrettably, some of my colleagues do not.
Re:Mercurial 4.0 Sprint Notes by pjmlp on Tuesday October 18, 2016 @01:12PM (#12736581)
A sane distributed source control system implemented in Python.

I am still disappointed that Git won.

Re:Mercurial 4.0 Sprint Notes by shoover on Tuesday October 18, 2016 @02:40PM (#12737399)
Agreed. And yet it is encouraging to see the continued investment and upstream engagement by Facebook and Mozilla. (I knew Facebook and Mozilla were heavily invested; I'm not sure what Google's involvement is since code.google.com was abandoned.)

Things could get more competitive in terms of global mindshare if more Facebook engineers (some of whom the OP mentioned have forgotten how to use git) start speaking out in favor of Mercurial.

Re:Mercurial 4.0 Sprint Notes by ngoldbaum on Tuesday October 18, 2016 @02:48PM (#12737457)
Google is working on adding mercurial as a frontend for their repository management system (Piper) and development environment (CitC).
Re:Mercurial 4.0 Sprint Notes by rjbwork on Tuesday October 18, 2016 @05:55PM (#12739080)
Depends on your definition of won, I guess...fourth job in a row using Hg. I've never used git professionally, just for OSS stuff.
Re:Mercurial 4.0 Sprint Notes by geodel on Tuesday October 18, 2016 @03:26PM (#12737831)
Also C won, Unix won, Android won. Seems technical subpar options are better business options.
Re:Mercurial 4.0 Sprint Notes by pjmlp on Tuesday October 18, 2016 @03:27PM (#12737844)
You forgot JavaScript and PHP.
Re:Mercurial 4.0 Sprint Notes by fra on Tuesday October 18, 2016 @12:24PM (#12736016)
Re:Mercurial 4.0 Sprint Notes by jcranmer on Tuesday October 18, 2016 @12:31PM (#12736098)
The big advantage to call out is that they found Mercurial much easier to add extensions to and more receptive to their issues with large monorepos. (For an idea of the scale, Facebook's repository I have heard is ~10× the size of mozilla-central, which is probably the largest public Mercurial repository.)
Re:Mercurial 4.0 Sprint Notes by gcp on Tuesday October 18, 2016 @12:32PM (#12736107)
Much faster on Windows for large repos.

Better extension system. Some like hg evolve are science fiction compared to typical git workflows. Sounds like hg absorb is similar.

Re:Mercurial 4.0 Sprint Notes by awinder on Tuesday October 18, 2016 @12:29PM (#12736074)
If you have a ton of files inside of one gigantic repo, the work facebook is doing on mercurial might help you out.

If you live in a saner world though, you'll probably benefit more from git's superior cli & tooling

Re:Mercurial 4.0 Sprint Notes by gcp on Tuesday October 18, 2016 @12:34PM (#12736130)
I think you mostly call it a "saner world" because git tooling and performance doesn't work with unified repos, so people avoid it.

But it can be fixed, too, which is what Facebook and Google are doing.

Re:Mercurial 4.0 Sprint Notes by bjt on Tuesday October 18, 2016 @06:59PM (#12739494)
It's weird to hear git's cli called superior. I have much more often heard the opposite.
Re:Mercurial 4.0 Sprint Notes by arunc on Wednesday October 19, 2016 @04:24PM (#12747378)
Mercurial CLI is safe by all means! I have never lost a commit in hg. Git CLI is an abomination and is a nightmare to deal with. As a colleague of mine said once, "It is easy to develop programs than to use version control them using git".