make `view diff on commit` a feature that is easy to use
anatoly techtonik
techtonik at gmail.com
Wed Nov 5 14:43:34 UTC 2014
On Wed, Nov 5, 2014 at 4:35 PM, Olle <olle.lundberg at gmail.com> wrote:
> On Tue, Nov 4, 2014 at 9:50 PM, anatoly techtonik <techtonik at gmail.com>
> wrote:
>>
>> I always do `hg diff` before `hg ci` (sometimes also `hg sum/st`),
>> which is very clumsy, so I went to see if something is already
>> available.
>>
>> vim-only
>>
>> https://stackoverflow.com/questions/8009333/vim-show-diff-on-commit-in-mercurial
>> http://mercurial.selenic.com/wiki/DiffsInCommitMessageInVIM
>>
>> bash-only
>> http://mercurial.selenic.com/wiki/hgeditor
>>
>>
>> I've tried to bring my own solution with temporary file, but the
>> diff with prepended HG: loses syntax highlighting. So, to make
>> this feature more useful, maybe these two things are possible
>> to implement:
>>
>> 1. remove all lines after HG: block, i.e.
>> -HG: Enter commit message. Lines beginning with 'HG:' are removed.
>> -HG: Leave message empty to abort commit.
>> +HG: Enter commit message. Lines beginning with 'HG:' and any text
>> +HG: after are removed. Leave message empty to abort commit.
>>
>> 2. hg commit -v to show diff
>> hg commit -vv to show diff + diffstat
>> (grabbed the idea from SO comment above)
>
>
> I actually started to implement this a while ago, but never got to
> incorporate the changes suggested by mpm:
> http://selenic.com/pipermail/mercurial-devel/2013-December/055311.html
I see suggestion to implement hgeditor protocol. Is that all?
http://selenic.com/pipermail/mercurial-devel/2013-December/055313.html
I can't completely read `hgeditor` source. This stuff in particular:
grep '^HG: changed' "$1" | cut -b 13- | while read changed;
but it seems that protocol requires two separate files to be created:
$HGTMP/diff (if there is one)
$HGTMP/msg
and then feeding both to the same editor. `notepad.exe` won't understand
that. The solution could be to add environment variables with these paths
that could be pasted into `[ui]/editor = ` string. But, again, this won't help
with default Windows program.
I'd still prefer a single channel behavior like in Git, where everything below
HG: block is stripped. This way you will need the same EDITOR setting
for both.
http://mercurial.selenic.com/wiki/editor
More information about the Mercurial
mailing list