有谁知道如何在保留文件历史记录的同时跨suprepos移动文件
我正在使用 hg mv /Product/common/modules/sub-repo1/scripts/filename /Product/common/modules/sub-repo2/scripts/filename
Product
是 shell 级别的 repo 和 sub-repo1
和 sub-repo2
是子 repo
它抛出一个错误中止 /Product/common/modules/sub-repo2/scripts/filename not under root
..
最佳答案
可以通过将两个存储库拼接在一起来实现:
echo include my-file > filemap
hg convert --filemap sourcerepo temprepo
cd destrepo
hg pull --force temprepo
hg merge
这是命令行上的示例。首先我们创建一个原始的源代码仓库:
$ mkdir sourcerepo
$ cd sourcerepo
$ hg init
$ echo aaa > a
$ echo bbb > b
$ hg add a b
$ hg commit -m first
$ echo xxx > a
$ echo yyy > b
$ hg commit -m second
然后我们创建一个文件映射并将其转换为仅包含我们想要的文件的临时存储库:
$ cd ..
$ echo include a > filemap
$ hg convert --filemap filemap sourcerepo temprepo
initializing destination temprepo repository
scanning source...
sorting...
converting...
1 first
0 second
$ hg glog temprepo/a
@ changeset: 1:a2c44f396733
| tag: tip
| user: Laurens Holst <...>
| date: Fri Oct 21 13:02:53 2011 +0200
| summary: second
|
o changeset: 0:68090379058b
user: Laurens Holst <...>
date: Fri Oct 21 13:02:41 2011 +0200
summary: first
现在我们创建一个目标存储库:
$ mkdir destrepo
$ cd destrepo
$ echo zzz > z
$ hg add z
$ hg commit -m another
$ hg glog
o changeset: 0:890b51ba85c6
tag: tip
user: Laurens Holst <...>
date: Fri Oct 21 13:15:51 2011 +0200
summary: another
最后,我们从临时存储库中提取更改,并将其 merge :
$ hg pull --force ../temprepo
pulling from ../temprepo
searching for changes
warning: repository is unrelated
requesting all changes
adding changesets
adding manifests
adding file changes
added 2 changesets with 2 changes to 1 files (+1 heads)
(run 'hg heads' to see heads, 'hg merge' to merge)
$ hg merge
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
$ hg commit -m "merge file a from sourcerepo"
$ ls
a z
$ hg glog
@ changeset: 3:7becd66c019a
|\ tag: tip
| | parent: 0:890b51ba85c6
| | parent: 2:dc9ac503efba
| | user: Laurens Holst <...>
| | date: Fri Oct 21 13:39:51 2011 +0200
| | summary: merge file a from sourcerepo
| |
| o changeset: 2:dc9ac503efba
| | user: Laurens Holst <...>
| | date: Fri Oct 21 13:02:53 2011 +0200
| | summary: second
| |
| o changeset: 1:2a5fa6bd9021
| parent: -1:000000000000
| user: Laurens Holst <...>
| date: Fri Oct 21 13:02:41 2011 +0200
| summary: first
|
o changeset: 0:890b51ba85c6
user: Laurens Holst <...>
date: Fri Oct 21 13:15:51 2011 +0200
summary: another
现在,源存储库中的文件已 merge 到目标存储库中,同时保留所有更改历史记录!
关于mercurial - 在 mercurial 中跨子存储库移动文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7838392/