hg log templates, tags displayed only when needed

Simon King simon at simonking.org.uk
Mon Oct 26 15:00:55 UTC 2015


On Mon, Oct 26, 2015 at 2:36 PM, Uwe Brauer <oub at mat.ucm.es> wrote:
>
>    > On Mon, Oct 26, 2015 at 11:37 AM, Uwe Brauer <oub at mat.ucm.es> wrote:
>
>    > I'm not sure if it can be done directly on the command line, but you
>    > can do it by creating a "style" file. Unfortunately I don't think
>    > there's any official documentation for style files, but the following
>    > might be useful:
>
>    > Here's an example which *might* do what you're looking for:
>
>    > #---------
>
>    > $ cat >mystyle
>    > changeset = "changeset: {rev}:{node|short}\n{tags}user:
>    > {author}\nDate: {date|rfc822date}\nsummary: {desc}\n{nofiles}\n"
>    > tag = "tag: {tag}\n"
>    > $ hg log --style ./mystyle -l 2
>    > changeset: 26827:a9ed5a8fc5e0
>    > tag: tip
>    > user: Yuya Nishihara <yuya at tcha.org>
>    > Date: Sat, 24 Oct 2015 06:59:26 +0100
>    > summary: help: mention alias and revsetalias in description of HGPLAINEXCEPT
>
>
> Great!! This is almost the output I need for my Emacs question. Thanks
> very much.
>
> One question remains:
> The output  of hg log --style ./mystyle -l 2
> is now
>
> ,----
> |
> | changeset: 30:28f611cb807a
> | tag: tip
> | user:Uwe Brauer <oub at mat.ucm.es>
> | Date: Mon, 26 Oct 2015 15:28:36 +0200
> | summary: Ditto
> |
> | * testhg2.tex (section{Nación} {} {}): New long change:
> `----
>
> Where the line containg the * comes from the ChangeLog file.
>
> In that file this line is indented like
>
>         * testhg2.tex (section{Nación} {} {}): New long change:
>
> How can I achieve that output? That is how can I tell description to
> indent a certain about of tabs/or whitespace?
>

There was another link that I should have included earlier:

https://selenic.com/hg/help/templating

(also available if you run "hg help templating")

There appear to be a few options for indenting:

tabindent
Any text. Returns the text, with every non-empty line except the first
starting with a tab character.

fill(text[, width[, initialident[, hangindent]]])
Fill many paragraphs with optional indentation.

indent(text, indentchars[, firstline])
Indents all non-empty lines with the characters given in the
indentchars string. An optional third parameter will override the
indent for the first line only if present.

Hope that helps,

Simon



More information about the Mercurial mailing list