Git P4:迁移完整历史记录 - 包括集成历史记录



几年前,我的一个 Perforce 仓库中的一个子文件夹(例如 //FirstDepot/LargeSubfolder/... )变得太大而无法维护,所以我将其"迁移"到自己的仓库中(例如 //NewDepotFromLargeSubfolder/... )。Perforce 不支持从一个库到另一个库的集成,所以我基本上签出了文件,将它们添加到新库并从子文件夹中删除了它们。

现在,我将要将整个Perforce服务器迁移到许多git存储库。git p4过程运行良好,我已经成功地将其他不相关的 Perforce 库迁移到 git(包括它们使用 @all 的完整文件历史记录 - 但是,这些库从未以描述的方式在 Perforce 中"迁移"......

问题是我不想丢失//FirstDepot/LargeSubfolder/...下面的文件历史记录。那里有几千个变更列表(加上//NewDepotFromLargeSubfolder/...的几千个),其中许多都包含非常有价值的信息。

我尝试从第一个位置迁移文件历史记录,然后将第二个位置的历史记录"堆叠"在其上:

host:~ user$ mkdir SomeTempFolder
host:~ user$ cd SomeTempFolder
host:SomeTempFolder user$ export P4PORT=perforce:1666
host:SomeTempFolder user$ git p4 clone //FirstDepot/LargeSubfolder@all gitRepoFolder
Importing from //FirstDepot/LargeSubfolder@all into gitRepoFolder
Initialized empty Git repository in /Users/user/SomeTempFolder/gitRepoFolder/.git/
Import destination: refs/remotes/p4/master
Importing revision 26776 (99%)
Ignoring apple filetype file //FirstDepot/LargeSubfolder/SomePath/SomeIconFile.icns
Importing revision 26778 (100%)

因此,除了有关Mac OS X图标文件被忽略的消息外,第一位有效。但是,第二部分失败了:

host:SomeTempFolder user$ git p4 clone //NewDepotFromLargeSubfolder@all gitRepoFolder
Importing from //NewDepotFromLargeSubfolder@all into gitRepoFolder
Reinitialized existing Git repository in /Users/user/SomeTempFolder/gitRepoFolder/.git/
Import destination: refs/remotes/p4/master
Importing revision 26777 (0%)
Ignoring apple filetype file //NewDepotFromLargeSubfolder/SomePath/SomeIconFile.icns
Importing revision 27142 (33%)
Ignoring apple filetype file //NewDepotFromLargeSubfolder/AnotherPath/Some AppleScript file.scpt
Ignoring apple filetype file //NewDepotFromLargeSubfolder/AnotherPath/Another AppleScript file.scpt
Importing revision 27620 (100%)
fast-import failed: warning: Not updating refs/remotes/p4/master (new tip <some long git ID> does not contain <another long git ID>)
git-fast-import statistics:
<loads of git statistic>

使用 --verbose 运行 git p4 似乎表明 Perforce 修订版的实际导入成功完成,但随后出现了我不明白的问题:

Importing revision 27620 (100%)commit into refs/remotes/p4/master
Opening pipe: ['p4', '-G', '-x', '-', 'print']
Path/of/the/file/in/the/last/Changelist
Reading pipe: ['git', 'config', '--bool', 'git-p4.importLabels']
Traceback (most recent call last):
  File "/usr/libexec/git-core/git-p4", line 3287, in <module>
    main()
  File "/usr/libexec/git-core/git-p4", line 3281, in main
    if not cmd.run(args):
  File "/usr/libexec/git-core/git-p4", line 3155, in run
    if not P4Sync.run(self, depotPaths):
  File "/usr/libexec/git-core/git-p4", line 3030, in run
    die("fast-import failed: %s" % self.gitError.read())
  File "/usr/libexec/git-core/git-p4", line 106, in die
    raise Exception(msg)
Exception: fast-import failed: warning: ... (as above) ...

第二部分的迁移在完成到新的 git 存储库时工作正常。

阅读"git-p4 克隆"失败后"新提示......不包含...",我在没有空格的工作文件夹中重试了迁移;相同的结果。顺便说一句,我正在使用Mac OS X,但是Perforce服务器在Debian 7.5虚拟机上运行。

我的问题:
+有没有人有一些建议如何找出这里的问题?
+ 通常是否可以"堆叠"修订历史记录块?
+ 任何人都可以想到另一种方法(除了有两个 git 存储库)?

我根本不是 git 专家,但到目前为止,我几乎可以向它扔东西,git 在弄清楚我想做什么方面做得很好;而且Reinitialized existing Git repository消息似乎表明我并没有完全关闭。

第二部分的迁移在完成到新的 git 存储库时工作正常

这可能是这里可接受的解决方法的基础:必须分离 Git 存储库,并从"如何合并两个 git 存储库?"中选择一种技术来获得最终存储库。

git filter-branch方法在"组合多个 git 存储库"中详细介绍。

(您还有一种基于合并的更简单方法,也在此处描述:OP ssc 选择了"在不破坏文件历史记录的情况下合并两个 Git 存储库")

最新更新