Mercurial: multiline commit message on the command line?

前端 未结 7 915
走了就别回头了
走了就别回头了 2021-02-06 20:20

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

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

does not work. The log

相关标签:
7条回答
  • 2021-02-06 20:56

    Mercurial: multiline commit message on the command line?

    Hit enter.

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

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

    $ 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 fire up "hg view" you can 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
    
    0 讨论(0)
  • 2021-02-06 20:56

    I know, there is already a solution for linux users, but I needed another solution for windows command line, so I was looking for it...

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

    hg commit -l filename.txt
    

    I hope, it's useful for someone out there ,)

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

    -l --logfile FILE read commit message from file

    0 讨论(0)
  • 2021-02-06 21:08

    In bash (since version 2.0):

    hg commit -m $'foo\nbar'
    

    (I.e. put a dollar sign before an opening single quote to make it parse escape sequences (like \n) within the string — note that it doesn't work with double quotes.)

    0 讨论(0)
  • 2021-02-06 21:12

    If you're doing it interactively (vs. from a script), just do hg commit without the -m flag. I'm not sure what the behavior is on Linux or Mac, but on Windows it pops up Notepad with a file that you fill out and save for a multiline message.

    0 讨论(0)
  • 2021-02-06 21:12

    Here's another way that is more close to what you tried at first:

    hg commit -m "$(echo -e 'foo\nbar')"
    
    0 讨论(0)
  • 2021-02-06 21:19

    For Windows with PowerShell:

     hg commit --message "foo`nbar"
    
    0 讨论(0)
提交回复
热议问题