Reputation: 1453
I like to configure the Mercurial Keyword Extension to support all Subversion keywords, i.e. to expand them in the exact way as Subversion does. I'm looking for this in order to use Mercurial together with my LaTeX package svn-multi which allows users to read and typeset this meta-data in their LaTeX documents. Unfortunately, the LaTeX parsing method isn't very flexible and will produce an hard syntax error if the data is not in the hardcoded format. (The package includes already some input sanity checks but they are limited.) I realize that both systems produce different revision numbers, but using the short, integer id form of Mercurial should do it.
So far I have the following configuration:
[keywordmaps]
Author = {author|user}
LastChangedBy = {author|user}
Date = {date|utcdate}
LastChangedDate = {date|utcdate}
Revision = {node|short}
Rev = {node|short}
LastChangedRevision = {node|short}
HeadURL = {root}/{file}
URL = {root}/{file}
Id = {file|basename} {node|short} {date|utcdate} {author|user}
The Author
is already fine, but I have difficulty to get the Date
and Revision
in the proper format. I'm having trouble getting information on all possible substitutions and their filters. {date|utcdate}
gives me the format 2012/03/28 19:18:19
, but I need it like 2006-07-22 21:42:37 -0700 (Sat, 22 Jul 2006)
. Also how to get the integer version of the revision number (which, I know, is not unique across repositories, but good enough in this case). Is it possible to substitute the default
pull/push target as HeadURL
?
Upvotes: 2
Views: 476
Reputation: 1
I solved the problem with these definitions of keywords in .hgrc:
LastChangedBy = {author|user}
LastChangedDate = {date|svnisodate}
LastChangedRevision = {rev}
HeadURL = {root}/{file}
Hope it helps.
Upvotes: 0
Reputation: 97282
For Revision answer is easy: hg help templating
rev Integer. The repository-local changeset revision number.
All date-related filters can be also found in this help
JFYI, log record with all date filters
Original log for reference
>hg log -r tip
changeset: 36:923cd64bcd36
tag: tip
user: Ray Bream <*@*>
date: Sun Oct 30 10:16:00 2011 +0600
summary: Синхронизация с 1.6
Filters
>hg log -r tip --template "{date|age}"
5 months ago
>hg log -r tip --template "{date|date}"
Sun Oct 30 10:16:00 2011 +0600
>hg log -r tip --template "{date|hgdate}"
1319948160 -21600
>hg log -r tip --template "{date|isodate}"
2011-10-30 10:16 +0600
>hg log -r tip --template "{date|isodatesec}"
2011-10-30 10:16:00 +0600
>hg log -r tip --template "{date|localdate}"
1319948160.0-21600
>hg log -r tip --template "{date|rfc3339date}"
2011-10-30T10:16:00+06:00
>hg log -r tip --template "{date|rfc822date}"
Sun, 30 Oct 2011 10:16:00 +0600
>hg log -r tip --template "{date|shortdate}"
2011-10-30
Nearest iteration to SVN date will be {date|isodate} ({date|rfc822date})
, but it contain time in parentheses
2011-10-30 10:16 +0600 (Sun, 30 Oct 2011 10:16:00 +0600)
Hint: AFAIK, keyword definition can use not only keywords, but also any hg commands and even system-commands
Upvotes: 3