gpt4 book ai didi

mercurial - 使用 mercurial 克隆或拉取标签后如何获取标签变更集?

转载 作者:行者123 更新时间:2023-12-04 12:00:45 24 4
gpt4 key购买 nike

作为明确的指南aptly points out (搜索“标签和克隆”):

When you run hg clone -r foo to clone a repository as of tag foo, the new clone will not contain any revision newer than the one the tag refers to, including the revision where the tag was created. The result is that you'll get exactly the right subset of the project's history in the new repository, but not the tag you might have expected.



这意味着 hg tags在您的新克隆中不显示 foo标签。如果您在 foo 之前进行了克隆,也会发生同样的情况。添加了标签,然后执行 hg pull -r foo .

(题外话:标签是我在 hg 中唯一不太了解的东西。我知道将它放入变更集中有优势(例如 merge ),但将元数据与源代码混合总是感觉很奇怪。)

很明显,我要求一种自动化的方式,而不是将标签变更集作为单独的手动步骤。

我知道我可以在 incoming 中检查这种情况钩子(Hook)(因此它适用于克隆和拉取),或包装 clonepull .

但是有更好/更简单的方法吗?

UPDATE hg bug tracker 已经有 this issue .

最佳答案

你想要一个巨大的黑客 bash和嵌入式 Perl 脚本?嗯,这里是...

#!/bin/bash
if [[ "$1" == "" || "$2" == "" || "$3" == "" ]]; then
echo 'hgclonetag <src> <tgt> <tag>'
exit 1;
fi

REV=`hg log -R $1 --rev $3: --limit=2 | perl -F: -lane 'if (/:([\dA-Fa-f]+)$/) {print $F[2] if defined($flag);$flag=1;}'`
hg clone --rev $REV $1 $2

这会调用 hg log命令提取第一个与标签相关的修订后的修订号,然后克隆到此修订。

目前这不适用于远程仓库: -R不幸的是,switch 仅适用于本地存储库。

关于mercurial - 使用 mercurial 克隆或拉取标签后如何获取标签变更集?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3770889/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com