News for hackers. Stuff that matters.
Re:Mercurial RFC of a new extension to directly operate on G... by jcranmer on Tuesday October 29, 2019 @07:22PM (#21393151)
> the notion of having an index and staging area would be fundamentally different (or absent)

Mercurial indeed lacks a staging area

> the notion of committing locally and pushing remotely would be fundamentally different

If you enable phases, it does. By default, all local commits are "draft" commits, which can have history edited. But when you push to (or pull from) a public repository, it becomes a "public" commit, and Mercurial will refuse to edit those commits. There's also a "secret" phase, which Mercurial will refuse to push to a public repository. You can also configure whether or not remote repositories are public or not.

The other fun feature is changeset evolution: when you rebase a changeset, Mercurial will keep the original changeset around with a link between the old and new versions of it. If you push the rebase remotely to a repository that previously had the original, Mercurial will tell people that changesets based on the original also need to be rebased when they pull it, and the history information will let them use the regular rebase flow to do it. Too bad BitBucket is dropping hg repos...

Re:Mercurial RFC of a new extension to directly operate on G... by doubleunplussed on Tuesday October 29, 2019 @09:59PM (#21393972)
> Mercurial indeed lacks a staging area

I'm sure someone will dispute that it is the same as the staging area, but mercurial does have the ability to only include some things in commits, and I use it daily. I admit I have no idea how it works on the command line, but in tortoisehg I can select individual files and hunks thereof to add to a commit (screenshot: https://imgur.com/ErPEjSN).

It's my impression that loads of people use this feature and somehow don't notice it exists, and will openly agree that mercurial lacks a staging area. My opinion is that defaulting to including changes from all files previously committed is such a sensible default that it makes the feature so seamless that people forget it exists even whilst using it.

Kinda like how people from the US think you can't turn left on red in Australia (equivalent of right on red in the US). You can, but the existence of slip lanes everywhere its allowed mean you don't actually face the red light when doing so. This hides it so effectively that I've seen several people complaining that they can't turn on red, not noticing that they do it every day.

Re:Mercurial RFC of a new extension to directly operate on G... by jcranmer on Tuesday October 29, 2019 @10:13PM (#21394059)
Mecurial lets you choose which files you want to commit on the command line, either by simply specifying all the relevant globs, or by using -I (include) and -X (exclude) flags to compose a more complex pattern matching. You can also use interactive commit mode to open up a TUI to select which files you want to load. Alternatively, you can also add stuff to the top commit with `hg commit --amend`. git has basically all of these features.

What Mercurial doesn't have is a separate repository concept of an incomplete commit that has awkward, and often inconsistent, interactions with several common repository commands. Git has this, and this is the staging area.

The UI feature you use has nothing to do with the staging area, and is in fact closer to the `hg commit -i` interactive commit mode.

Re:Mercurial RFC of a new extension to directly operate on G... by cannam on Wednesday October 30, 2019 @06:24AM (#21396131)
This makes for one difference which sometimes bites people even if they use the two tools in the same way: if you change a file "while committing it", e.g. changing it in one window while writing the commit message in another, Mercurial will commit the changed version, while Git of course commits the file as it was when you staged it, or when you ran commit -a.

I find this quite handy in Mercurial, as I sometimes realise while writing the commit message that e.g. I forgot to remove a line of temporary debug output, and I can still go and do it before I save the commit message. But that's very bad form that reflects badly on me. The way Git does it feels more correct.

Re:Mercurial RFC of a new extension to directly operate on G... by DaiPlusPlus on Tuesday October 29, 2019 @11:19PM (#21394396)
What about committing partial changes to files (like git’s hunks)?
Re:Mercurial RFC of a new extension to directly operate on G... by doubleunplussed on Wednesday October 30, 2019 @09:16AM (#21397323)
Yes, hg's interactive commit allows this (and if you look at my screenshot, you can see tortoisehg presents checkboxes next to hunks in the diff, this is the way I use it)
Re:Mercurial RFC of a new extension to directly operate on G... by rkangel on Wednesday October 30, 2019 @07:16AM (#21396421)
I seem to remember using the hg record extension.
Re:Mercurial RFC of a new extension to directly operate on G... by pseudalopex on Wednesday October 30, 2019 @12:15AM (#21394651)
"hg commit -i" does that.
Re:Mercurial RFC of a new extension to directly operate on G... by iggldiggl on Wednesday October 30, 2019 @04:55AM (#21395711)
Thinking back about my Git usage, I've indeed only ever used it as a sort of poor man's "hg commit --interactive", so I haven't missed it a bit when using Mercurial. Indeed I find Mercurial's model (there's only the repository with the real changesets and the working directory, but not this sort of weird inbetween thing called the staging area) much easier to reason about...
Re:Mercurial RFC of a new extension to directly operate on G... by pjc50 on Wednesday October 30, 2019 @07:30AM (#21396490)
> Mercurial does have the ability to only include some things in commits

So do p4 and svn, through "changelists". The difference is that only in git is the staging area "persistent" from one command to another, and hidden from you when you run the default "what are the differences between my working directory and the head" command.

Re:Mercurial RFC of a new extension to directly operate on G... by rkangel on Wednesday October 30, 2019 @07:22AM (#21396456)
Mercurial does have a staging area, it is just turned off by default (and this is a good thing).

Mercurial has a very good extension system, and ships several useful extension in the default installation. The 'record' extension adds the 'commit individual hunks' functionality of the git staging area, and needs a one line "record=" in your config file to enable it. See: https://www.mercurial-scm.org/wiki/RecordExtension

By having some of these functionalities in extensions, the core interface is kept simpler and easier to learn, but the more powerful features are still there for those who want them.

Re:Mercurial RFC of a new extension to directly operate on G... by throw0101a on Wednesday October 30, 2019 @08:48AM (#21397085)
> Mercurial indeed lacks a staging area

Perhaps this:

* https://www.mercurial-scm.org/wiki/GitConcepts#Git.27s_stagi...