2011-01-10 130 views
1

任何人使用mercurial来管理Linux内核?这有点长,但我不确定是否有答案。我想举一些例子求助使用mercurial来管理linux内核,标签和hg ID

这里是我所看到的:

在linux内核,还有建筑称为脚本/ setlocalversion时使用的命令。在此脚本中,它根据存储库信息设置内核版本。目前,它了解git,mercurial和svn回购。

GIT中,它创建了这个代码的标签:

if head=`git rev-parse --verify --short HEAD 2>/dev/null`; then 

    # If we are at a tagged commit (like "v2.6.30-rc6"), we ignore it, 
    # because this version is defined in the top level Makefile. 
    if [ -z "`git describe --exact-match 2>/dev/null`" ]; then 

     # If we are past a tagged commit (like "v2.6.30-rc5-302-g72357d5"), 
     # we pretty print it. 
     if atag="`git describe 2>/dev/null`"; then 
      echo "$atag" | awk -F- '{printf("-%05d-%s", $(NF-1),$(NF))}' 
..... 

所以,这里是一个例子,我没有明白这是如何工作:

[1536][mcrowe:test]$ git tag -a -m"Creating a tag" KernelTest 
[1537][mcrowe:test]$ git rev-parse --verify --short HEAD 
d024e76 
[1537][mcrowe:test]$ git describe --exact-match 
KernelTest 
[1537][mcrowe:test]$ git describe 
KernelTest 

所以,在这个例子中,本地当内核构建时版本将被设置为“KernelTest”。

在善变的,然而,代码即可获得本地版本是这样的:

if hgid=`hg id 2>/dev/null`; then 
    tag=`printf '%s' "$hgid" | cut -d' ' -f2` 

    # Do we have an untagged version? 
    if [ -z "$tag" -o "$tag" = tip ]; then 
     id=`printf '%s' "$hgid" | sed 's/[+ ].*//'` 
     printf '%s%s' -hg "$id" 
    fi 
.... 

我的期望是我能标记的释放,并有该标签是什么这个脚本使用,如git的发生。然而,似乎“汞ID”永不打印出的标签这样的脚本预计:

[1546][mcrowe:test2]$ hg tag -m"Creating a tag" KernelTest -r tip 
[1548][mcrowe:test2]$ hg id 
3ccda5e738ae+ tip 
[1548][mcrowe:test2]$ hg tags 
tip        115:3ccda5e738ae 
KernelTest      114:be25df80ce76 

所以标签的这种行为改变了修订所以hg的ID将永远不会显示的标签是什么。

核心问题:AFAIK,这将永远不能用于Linux内核。问题是如何在内核树中实现hg tag的性能如git tag

+0

标签默认添加一个额外的提交,也许尝试localtags? `tag -l` – tonfa 2011-01-10 21:25:23

+0

希望我可以,但是这被推入持续集成服务器。不幸的是,需要全球标签。 – 2011-01-10 21:29:27

回答

3

尝试做:

hg log -r . --template '{latesttag}' 

我认为,你想要做什么。

还有{latesttagdistance}它可以让你知道你是N通过一个标签为方便的版本字符串。