Mercurial: multiline commit message on command line?

How can I specify a multi-line commit message for mercurial on the command line?

hg commit -m "* add foo\n* fix bar" 

does not work. The log displays:

 changeset: 13:f2c6526e5911 tag: tip date: Fri Jan 23 23:22:36 2009 +0100 files: foobar.cpp description: * add foo\n*fix bar 
+50
command-line mercurial
Jan 24 '09 at 12:40
source share
5 answers

Mercurial: multiline commit message on command line?

Press Enter.

 $ hg commit -m "Did some work > Now I'm done" 

One of the things is that in hg log only the first line is displayed:

 $ hg log changeset: 0:d2dc019450a2 tag: tip user: Aaron Maenpaa <zacherates@gmail.com> date: Sat Jan 24 07:46:23 2009 -0500 summary: Did some work 

... but if you run "hg view", you will see that the whole message is there.

Edited to add:

... but hg -v log shows the whole message:

 $ hg -v log changeset: 0:d2dc019450a2 tag: tip user: Aaron Maenpaa <zacherates@gmail.com> date: Sat Jan 24 07:46:23 2009 -0500 files: work description: Did some work Now I'm done 
+71
Jan 24 '09 at 12:45
source share

From Windows cmd, run this command for multi-line commit.

 hg commit -l con 

This allows you to enter a message about committing multiple lines directly from the command line. To end your message, press Enter , and on a separate line, delete Ctrl + Z and Enter again.

Why? The -l option to hg commit says to read the commit message from the file, and con indicates that the file is actually a console.

+16
Apr 26 '13 at 7:20
source share

If you do this interactively (compared to the script), just hg commit without the -m flag. I'm not sure what this behavior is on Linux or Mac, but on Windows it displays a notepad with a file that you fill out and save for a multi-line message.

+9
Jan 24 '09 at 16:06
source share

I know that there is already a solution for Linux users, but I need another solution for the Windows command line, so I searched for it ...

And I found one: https://www.mercurial-scm.org/pipermail/mercurial/2011-November/040855.html

 hg commit -l filename.txt 

Hope this is helpful to someone out there,)

[EDIT] oO - it has already been added to the help

-l -logfile FILE read commit message from file

+4
Oct 17 '12 at 12:40
source share

Here's another way that is closer to what you tried at the beginning:

 hg commit -m "$(echo -e 'foo\nbar')" 
+2
Feb 17 '09 at 18:43
source share



All Articles