Mercurial 日志模板
Mercurial Log Templates
我在 .hgrc
文件
中创建了一个日志别名
nlog = glog --style=${HOME}/.hg-ext/templates.lg
现在在 templates.lg
我使用 label
函数对输出进行着色
changeset = "{label('red',rev)} {label('c.author', author|person)} {desc|firstline|strip} {label('green', date|age)} {label('yellow', branches)}{label('yellow',bookmarks)}{label('yellow', tags)}\n\n"
changeset_verbose = "{label('red',rev)}:{node|short} {label('c.author',author|person)} {desc|firstline|strip} {label('green',date|age)} {label('yellow', branches)}{label('yellow',bookmarks)}{label('yellow', tags)}\n\n"
start_branches = " "
branch = "{label('yellow', branch)}"
start_bookmarks = " "
bookmark = "{label('yellow', bookmark)}, "
last_bookmark = "{label('yellow', bookmark}"
start_tags = " "
tag = "{label('yellow', tag)}, "
last_tag = "{label('yellow', tag)}"
当我 运行 hg nlog
它在某些存储库上工作正常,但在其他存储库上失败并跟踪
C:\Users\esharapov\Repos\Composer.Hg>hg -v --traceback nlog
Traceback (most recent call last):
File "mercurial\dispatch.pyo", line 191, in _runcatch
File "mercurial\dispatch.pyo", line 924, in _dispatch
File "mercurial\dispatch.pyo", line 681, in runcommand
File "mercurial\extensions.pyo", line 195, in closure
File "hgext\color.pyo", line 518, in colorcmd
File "mercurial\extensions.pyo", line 195, in closure
File "hgext\pager.pyo", line 143, in pagecmd
File "mercurial\dispatch.pyo", line 1055, in _runcommand
File "mercurial\dispatch.pyo", line 1015, in checkargs
File "mercurial\dispatch.pyo", line 921, in <lambda>
File "mercurial\util.pyo", line 991, in check
File "mercurial\dispatch.pyo", line 537, in __call__
File "mercurial\util.pyo", line 991, in check
File "mercurial\extensions.pyo", line 195, in closure
File "mercurial\util.pyo", line 991, in check
File "hgext\mq.pyo", line 3516, in mqcommand
File "mercurial\util.pyo", line 991, in check
File "hgext\graphlog.pyo", line 64, in glog
File "mercurial\commands.pyo", line 5076, in log
File "mercurial\cmdutil.pyo", line 2219, in graphlog
File "mercurial\cmdutil.pyo", line 2196, in displaygraph
File "mercurial\cmdutil.pyo", line 1184, in show
File "mercurial\cmdutil.pyo", line 1489, in _show
File "mercurial\templatefilters.pyo", line 340, in stringify
File "mercurial\util.pyo", line 802, in increasingchunks
File "mercurial\templater.pyo", line 783, in _flatten
File "mercurial\templater.pyo", line 262, in runtemplate
File "hgext\color.pyo", line 501, in templatelabel
File "mercurial\templatefilters.pyo", line 340, in stringify
File "mercurial\templatekw.pyo", line 115, in _showlist
File "mercurial\templatekw.pyo", line 106, in one
File "mercurial\templater.pyo", line 938, in __call__
File "mercurial\templater.pyo", line 845, in process
File "mercurial\templater.pyo", line 835, in _load
File "mercurial\templater.pyo", line 181, in compiletemplate
File "mercurial\templater.pyo", line 173, in _parsetemplate
File "mercurial\parser.pyo", line 78, in parse
File "mercurial\parser.pyo", line 70, in _parse
File "mercurial\parser.pyo", line 50, in _parseoperand
File "mercurial\parser.pyo", line 41, in _match
ParseError: ('unexpected token: end', 26)
hg: parse error at 26: unexpected token: end
可能是什么原因?
我不能告诉你你的错误,但我执行了一些额外的测试,条件和结果之间存在严格的相关性
准备
- 已创建
$TortoiseHg\templates\map-cmdline.colorglog
内容与您的 templates.lg
相同(我懒得在每次测试中都写下您的长命令)
在我的 3.7.1 中找到了命令行,相当于你的nlog
(因为hg: unknown command 'glog'
):它是
hg log -G --style=colorglog
log -G 和没有路径的样式,因为默认地图位置中的样式文件具有 good name
- 启用颜色扩展
测试
无标签(强制性除外 tip
)或书签的回购
>hg paths
default = https://bitbucket.org/albert_brand/hgexportfiles
>hg tags
tip 10:ee40a7b06166
>hg book
no bookmarks set
hg 日志 - 正常
带有标签和书签的回购
>hg paths
default = http://bitbucket.org/durin42/hg-git/
>hg book
master 987:be0d1413a06f
next 490:ac644c0e16d4
>hg tags
tip 987:be0d1413a06f
0.8.5 985:53d514c9c7e6
0.8.4 976:22a12bf143a3
0.8.3 946:d7ad67f850b2
0.8.2 926:e183fdc198f0
0.8.1 902:e6489cf3fe8c
0.8.0 857:cf3dafce0611
0.7.0 827:fc63d0e2653d
...
hg 日志 - 失败 ("hg: parse error at 26: unexpected token: end")
有标签但没有书签的回购
>hg paths
default = http://bitbucket.org/durin42/hgsubversion/
>hg book
no bookmarks set
>hg tags
tip 1378:e1619c051788
1.8.5 1370:bd979667611d
1.8.4 1365:89997a5fc181
1.8.3 1347:759cafce6bec
1.8.2 1344:38be7a6b6def
1.8.1 1324:dde1ade36a49
...
hg 日志 - 正常
在 hg-git gepo
中使用单个标记|书签修订的附加测试
>hg log -r 985 --style=colorglog
985 Siddharth Agarwal init: mark Mercurial 3.7 as supported and prepare for 0.8.5 6 weeks ago 0.8.5
标记修订 - OK
>hg log -r 490 --style=colorglog
hg: parse error at 26: unexpected token: end
已添加书签的修订 - 失败
添加
好的,我明白了。像往常一样,明显的错别字在明显的地方。而不是
last_bookmark = "{label('yellow', bookmark}"
一定是
last_bookmark = "{label('yellow', bookmark)}"
原因很明显:label()
,而不是 label(
并且已添加书签的修订将不再产生错误
我在 .hgrc
文件
nlog = glog --style=${HOME}/.hg-ext/templates.lg
现在在 templates.lg
我使用 label
函数对输出进行着色
changeset = "{label('red',rev)} {label('c.author', author|person)} {desc|firstline|strip} {label('green', date|age)} {label('yellow', branches)}{label('yellow',bookmarks)}{label('yellow', tags)}\n\n"
changeset_verbose = "{label('red',rev)}:{node|short} {label('c.author',author|person)} {desc|firstline|strip} {label('green',date|age)} {label('yellow', branches)}{label('yellow',bookmarks)}{label('yellow', tags)}\n\n"
start_branches = " "
branch = "{label('yellow', branch)}"
start_bookmarks = " "
bookmark = "{label('yellow', bookmark)}, "
last_bookmark = "{label('yellow', bookmark}"
start_tags = " "
tag = "{label('yellow', tag)}, "
last_tag = "{label('yellow', tag)}"
当我 运行 hg nlog
它在某些存储库上工作正常,但在其他存储库上失败并跟踪
C:\Users\esharapov\Repos\Composer.Hg>hg -v --traceback nlog
Traceback (most recent call last):
File "mercurial\dispatch.pyo", line 191, in _runcatch
File "mercurial\dispatch.pyo", line 924, in _dispatch
File "mercurial\dispatch.pyo", line 681, in runcommand
File "mercurial\extensions.pyo", line 195, in closure
File "hgext\color.pyo", line 518, in colorcmd
File "mercurial\extensions.pyo", line 195, in closure
File "hgext\pager.pyo", line 143, in pagecmd
File "mercurial\dispatch.pyo", line 1055, in _runcommand
File "mercurial\dispatch.pyo", line 1015, in checkargs
File "mercurial\dispatch.pyo", line 921, in <lambda>
File "mercurial\util.pyo", line 991, in check
File "mercurial\dispatch.pyo", line 537, in __call__
File "mercurial\util.pyo", line 991, in check
File "mercurial\extensions.pyo", line 195, in closure
File "mercurial\util.pyo", line 991, in check
File "hgext\mq.pyo", line 3516, in mqcommand
File "mercurial\util.pyo", line 991, in check
File "hgext\graphlog.pyo", line 64, in glog
File "mercurial\commands.pyo", line 5076, in log
File "mercurial\cmdutil.pyo", line 2219, in graphlog
File "mercurial\cmdutil.pyo", line 2196, in displaygraph
File "mercurial\cmdutil.pyo", line 1184, in show
File "mercurial\cmdutil.pyo", line 1489, in _show
File "mercurial\templatefilters.pyo", line 340, in stringify
File "mercurial\util.pyo", line 802, in increasingchunks
File "mercurial\templater.pyo", line 783, in _flatten
File "mercurial\templater.pyo", line 262, in runtemplate
File "hgext\color.pyo", line 501, in templatelabel
File "mercurial\templatefilters.pyo", line 340, in stringify
File "mercurial\templatekw.pyo", line 115, in _showlist
File "mercurial\templatekw.pyo", line 106, in one
File "mercurial\templater.pyo", line 938, in __call__
File "mercurial\templater.pyo", line 845, in process
File "mercurial\templater.pyo", line 835, in _load
File "mercurial\templater.pyo", line 181, in compiletemplate
File "mercurial\templater.pyo", line 173, in _parsetemplate
File "mercurial\parser.pyo", line 78, in parse
File "mercurial\parser.pyo", line 70, in _parse
File "mercurial\parser.pyo", line 50, in _parseoperand
File "mercurial\parser.pyo", line 41, in _match
ParseError: ('unexpected token: end', 26)
hg: parse error at 26: unexpected token: end
可能是什么原因?
我不能告诉你你的错误,但我执行了一些额外的测试,条件和结果之间存在严格的相关性
准备
- 已创建
$TortoiseHg\templates\map-cmdline.colorglog
内容与您的templates.lg
相同(我懒得在每次测试中都写下您的长命令) 在我的 3.7.1 中找到了命令行,相当于你的
nlog
(因为hg: unknown command 'glog'
):它是hg log -G --style=colorglog
log -G 和没有路径的样式,因为默认地图位置中的样式文件具有 good name
- 启用颜色扩展
测试
无标签(强制性除外 tip
)或书签的回购
>hg paths
default = https://bitbucket.org/albert_brand/hgexportfiles
>hg tags
tip 10:ee40a7b06166
>hg book
no bookmarks set
hg 日志 - 正常
带有标签和书签的回购
>hg paths
default = http://bitbucket.org/durin42/hg-git/
>hg book
master 987:be0d1413a06f
next 490:ac644c0e16d4
>hg tags
tip 987:be0d1413a06f
0.8.5 985:53d514c9c7e6
0.8.4 976:22a12bf143a3
0.8.3 946:d7ad67f850b2
0.8.2 926:e183fdc198f0
0.8.1 902:e6489cf3fe8c
0.8.0 857:cf3dafce0611
0.7.0 827:fc63d0e2653d
...
hg 日志 - 失败 ("hg: parse error at 26: unexpected token: end")
有标签但没有书签的回购
>hg paths
default = http://bitbucket.org/durin42/hgsubversion/
>hg book
no bookmarks set
>hg tags
tip 1378:e1619c051788
1.8.5 1370:bd979667611d
1.8.4 1365:89997a5fc181
1.8.3 1347:759cafce6bec
1.8.2 1344:38be7a6b6def
1.8.1 1324:dde1ade36a49
...
hg 日志 - 正常
在 hg-git gepo
中使用单个标记|书签修订的附加测试>hg log -r 985 --style=colorglog
985 Siddharth Agarwal init: mark Mercurial 3.7 as supported and prepare for 0.8.5 6 weeks ago 0.8.5
标记修订 - OK
>hg log -r 490 --style=colorglog
hg: parse error at 26: unexpected token: end
已添加书签的修订 - 失败
添加
好的,我明白了。像往常一样,明显的错别字在明显的地方。而不是
last_bookmark = "{label('yellow', bookmark}"
一定是
last_bookmark = "{label('yellow', bookmark)}"
原因很明显:label()
,而不是 label(
并且已添加书签的修订将不再产生错误