Check what will be committed before actually committing

mercurial, version-control

Solution

When you do commit your message editor will contain a list of files that will be committed in the ignored section. If you commit with `hg -m "message"` this won't work as the editor step is skipped:

HG: Enter commit message.  Lines beginning with 'HG:' are removed.
HG: Leave message empty to abort commit.
HG: --
HG: user: User <user@user.land>
HG: branch 'default'
HG: changed myfile.yxy

You can use `hg commit` and `hg rollback` to undo the last commit if it contained a file that you did not want to commit. The rollback works as long as you did not `hg push` to another repository.

Status works with the same patterns as commit. You can use `hg status some/path/*` and then `hg commit some/path/*` only replacing the command to use.

Problem

I'm in the process of learning Mercurial, and even though I installed TortoiseHG, I find myself turning more and more to the command line. So often I would like to check what the result of a given `hg` command would be before I actually run it. Is there any equivalent to the `-whatif` switch known from PowerShell I can use, or how would you go about checking what would be committed using a given `hg commit` statement?

Original source