2012-03-28 69 views
2

我喜欢配置Mercurial Keyword Extension以支持所有Subversion keywords,即按照Subversion那样精确地扩展它们。我在寻找这个,以便将Mercurial与我的LaTeX包svn-multi一起使用,它允许用户在其LaTeX文档中读取和排版此元数据。不幸的是,LaTeX解析方法不是非常灵活,如果数据不是硬编码格式,将会产生一个硬语法错误。 (该软件包已经包含了一些输入健全性检查,但它们是有限的。) 我意识到两个系统都会生成不同的修订版本号,但使用Mercurial的short,integer id形式应该可以。将Mercurial关键字扩展配置为生成Subversion关键字

到目前为止,我有以下配置:

[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} 

Author已经很好,但我有困难得到DateRevision以正确的格式。我无法获得有关所有可能的替代品及其过滤器的信息。 {date|utcdate}给我的格式2012/03/28 19:18:19,但我需要它像2006-07-22 21:42:37 -0700 (Sat, 22 Jul 2006)。另外,如何获取修订版本号的整数版本(我知道,这在储存库中并不是唯一的,但在这种情况下足够好)。是否可以将default拉/推目标替换为HeadURL

回答

3

对于修订答案很简单:hg help templating

rev   Integer. The repository-local changeset revision number. 

所有日期相关的过滤器可以在此帮助

JFYI也发现,日志记录了所有日期筛选

原始日志以供参考

>hg log -r tip 
changeset: 36:923cd64bcd36 
tag:   tip 
user:  Ray Bream <*@*> 
date:  Sun Oct 30 10:16:00 2011 +0600 
summary:  Синхронизация с 1.6 

过滤器

>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 

最近迭代SVN日期将是{date|isodate} ({date|rfc822date}),但它包含在括号中的时间

2011-10-30 10:16 +0600 (Sun, 30 Oct 2011 10:16:00 +0600) 

提示:据我所知,关键字定义不仅可以使用关键字,而且任何汞的命令,甚至系统的命令

0

我关键字的这些定义在.hgrc解决了这个问题:

LastChangedBy = {author|user} 
LastChangedDate = {date|svnisodate} 
LastChangedRevision = {rev} 
HeadURL = {root}/{file} 

希望它有助于。