如何在mercurial中快速重新生成一棵树,如果这是原始结构:
A-B-C-D-E-F
我想将其更改为:
D-E-F
(甚至A-D-E-F
会这样做)
我在this answer中使用splicemap尝试了这个建议,但它失败并出现错误splice map revision <hash> is not being converted, ignoring'
它还打印出abort: no node!
任何帮助将不胜感激。谢谢。
我使用histedit
扩展程序执行此操作:
首先,让我们用你想要的结构创建一个测试仓库:
hg init
echo "a" > file
hg ci -m "a"
echo "b" >> file
hg ci -m "b"
echo "c" >> file
hg ci -m "c"
echo "d" >> file
hg ci -m "d"
echo "e" >> file
hg ci -m "e"
echo "f" >> file
hg ci -m "f"
然后,执行hg histedit
,并在编辑器中输入以下选项:
pick e4c09693d7a6 0 a
r 380d6d1ef006 1 b
r 33131e82bb1b 2 c
r pick 9325fb48b48e 3 d
pick 844ebb0b3844 4 e
pick bc85bc9ade8f 5 f
这将只在回购中留下三个提交。
请注意,要使其工作,您的仓库中的提交的phase必须是草稿。您还可能需要激活与mercurial一起提供的histedit扩展。