Mercurial,如何标记旧版本的文件

时间:2011-12-24 00:37:46

标签: mercurial tagging

我忘记使用发布标记标记我的文件的旧版本。旧版本是r13,最新版本是r65。我将最新的存储库克隆到一个新目录,做了一个“hg update -r13”来获取我想要标记的旧代码,然后执行了tag命令,但收到了消息:

中止:不在分支头(使用-f强制)

在这种情况下使用-f选项是否安全?

1 个答案:

答案 0 :(得分:19)

我猜你仍然可以在回购中进行标记,而无需更新自己的特定版本。

  

hg tag -r 13 tagname

请参阅Mercurial wiki上的详细信息。

我试过测试一下:

temp $ hg init .
temp $ touch a.txt
temp $ hg add a.txt 
temp $ hg commit -m "added a"
temp $ hg status
temp $ echo "sdwwdd" >> a.txt 
temp $ hg commit -m "modified a"
temp $ echo "\neddwedd" >> a.txt 
temp $ hg commit -m "modified a again"
temp $ hg log
changeset:   2:ef40a402fdab
tag:         tip
user:        "xxxx"
date:        Fri Dec 23 16:51:48 2011 -0800
summary:     modified a again

changeset:   1:d630dc3e2e3a
user:        "xxxx"
date:        Fri Dec 23 16:51:31 2011 -0800
summary:     modified a

changeset:   0:7c9917f24515
user:        "xxxx"
date:        Fri Dec 23 16:51:04 2011 -0800
summary:     added a

输出:

temp $ hg tag -r 1 a.txt a_1
temp $ hg tags
tip                                3:e3157256098f
a_1                                1:d630dc3e2e3a
a.txt                              1:d630dc3e2e3a
temp $ hg tag -r 1 all_1
temp $ hg tags
tip                                4:a643971911d8
all_1                              1:d630dc3e2e3a
a_1                                1:d630dc3e2e3a
a.txt                              1:d630dc3e2e3a
相关问题