-->

Hg (Mercurial SCM) and Notify - How to get project

2019-09-04 08:53发布

问题:

I'm using Hg(1.6.4) with Notify extension and I am trying to override the changeset template with project name on email subject. I read the "hg template help" and I not found a specific tag to get the project name.

The {webroot} and {root} tags got all path and I wanted PROJECT name only, i.e:

/home/USER/repo/PROJECT/rev

Is it possible to extract only PROJECT name? Is there any tag or template to parser and to get the project name?

回答1:

Uncomment the strip variable in hgrc file

#If you want to use a shorter repo-name, you can strip off components at the beginning.
#For example to strip off /usr/local/hg/repos from /usr/local/hg/repos/code use
strip = 3

And use a template like this to edit the email subject:

template = Subject: {webroot|strip}\n
 details:     {webroot}/rev/{node|short}
 branches:    {branches}
 changeset:   {rev}:{node|short}
 user:        {author}
 date:        {date|date}
 description: {desc}\n