Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/mercurial/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Mercurial中,如何从变更集中提取单个文件的变更以应用于另一个分支?_Mercurial_Tortoisehg - Fatal编程技术网

在Mercurial中,如何从变更集中提取单个文件的变更以应用于另一个分支?

在Mercurial中,如何从变更集中提取单个文件的变更以应用于另一个分支?,mercurial,tortoisehg,Mercurial,Tortoisehg,我在一个分支上提交了大量文件,我需要将该变更集中单个文件的修改传输到另一个分支。我该怎么做?我主要使用龟甲,但命令行解决方案也很好 如果我转到OrtoiseHG中的变更集并选择该文件,我可以看到我想要传输的差异,但无法实际应用它们。最基本的解决方案是转储文件补丁,将其应用到当前工作修订版,并提交它,假设您位于存储库的根目录: $ hg up <revision-to-apply-the-patch-to> $ hg diff -c <revision-containing-th

我在一个分支上提交了大量文件,我需要将该变更集中单个文件的修改传输到另一个分支。我该怎么做?我主要使用龟甲,但命令行解决方案也很好


如果我转到OrtoiseHG中的变更集并选择该文件,我可以看到我想要传输的差异,但无法实际应用它们。

最基本的解决方案是转储文件补丁,将其应用到当前工作修订版,并提交它,假设您位于存储库的根目录:

$ hg up <revision-to-apply-the-patch-to>
$ hg diff -c <revision-containing-the-patch> <files-to-include> | patch -p0
$ hg ci -m "Transplanting selected changes from <revision-contain...>"
这种方法的缺点是,从修订历史的角度看,您所做的事情并不十分明显。一个好的提交消息在这里很有帮助,但是历史图没有给出移植一些更改的过程的提示。在这种情况下,合并和恢复可能是更好的解决方案:

$ hg up <revision-to-apply-the-patch-to>
$ hg merge -r <revision-containing-the-patch>
$ hg revert --no-backup <files-to-exclude>
$ hg ci -m "Merge in changes of <files-to-include>"

可能有更多的解决方案可以做到这一点-我首先想到的是这两种解决方案。

您可以使用以下方法获得该文件的修补程序:

hg log -r THEREVISIONWITHLOTSOFCHANGES -p -I path/to/justthatfile > justthatfile.patch
然后,您可以通过执行以下操作将其导入到任何分支上:

hg update anotherbranch
hg import --no-commit justthatfile.patch
hg commit