2012-03-28 83 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} 

希望它有助於。