Mu Mind
Mu Mind

Reputation: 11214

git commit --verbose equivalent in mercurial?

In git, I can do "git commit --verbose" to show me a diff right there in the message editor. I don't see any option for it in mercurial. Is there a mercurial plugin to show me a diff in the message editor or anything similar?

Upvotes: 8

Views: 1049

Answers (4)

Mu Mind
Mu Mind

Reputation: 11214

Short answer: There is no git commit --verbose equivalent in mercurial, but it's possible to hack it in.

The edit text is hard-coded in the mercurial source, so no plugin or configuration can directly change it.

The best you can do is to hack the ui.editor setting in your hgrc to add text into the editor directly. I made a script called hg-commit-editor:

#!/bin/sh
echo 'HG: ------------------------ >8 ------------------------' >> $1
hg diff >> $1
editor $1
exit $?

and then set it as my commit editor in my hgrc:

[ui]
editor = hg-commit-editor

This appends the output of "hg diff" to the bottom of the edit text file after a special line (source) so it's not included as part of the commit message.

Upvotes: 7

yegle
yegle

Reputation: 5875

The easiest solution is to download this (use the raw link on the left hand side), put it in your $PATH, then set HGEDITOR environment variable to this script.

When doing hg commit, you'll see the diff in a separate window.

See also https://www.mercurial-scm.org/wiki/hgeditor

@Mu Mind's script should still work, and probably preferable if you want it to behave as close as git commit --verbose.

Upvotes: 1

VonC
VonC

Reputation: 1329092

Not directly but you could combine:

So: generating a file with the right information in it (list of files to be pushed) as the commit message.

Upvotes: 1

Lazy Badger
Lazy Badger

Reputation: 97365

Not exactly the same result, but nearest iteration:

before commit you can hg diff to see diff in WC, using alias extension you can create alias for command-pair "hg diff & hg commit"

Upvotes: 0

Related Questions