git p4:迁移完整历史记录 - 包括集成历史记录

3
几年前,我在 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 clone` fails "new tip ... does not contain ..."后,我在一个没有空格的工作文件夹中重试了迁移; 结果相同。顺便说一下,我正在Mac OS X上工作,但Perforce服务器正在Debian 7.5虚拟机上运行。
我的问题: + 有人能给出一些建议,如何找出这里的问题? + 是否通常可以“堆叠”修订历史记录? + 除了有两个git存储库之外,是否有其他方法?
我根本不是git专家,但到目前为止,我几乎可以将东西扔给它,而git会出色地找出我想要做的事情;此外,“重新初始化现有Git存储库”消息似乎表明我并不完全错误。

也许您可以查看Perforce服务器的日志,以了解在工具失败的点上正在运行哪个命令。如果您有一个足够新的Perforce服务器,并且使用“server=4”跟踪设置运行Perforce服务器,则发送到客户端软件的所有错误消息也会记录在服务器的日志中,这应该有助于您定位工具接收到的确切错误消息。 - Bryan Pendleton
服务器版本为 P4D/LINUX26X86_64/2013.1/678655 (2013/07/29)。尝试使用 -v server=4 启动 p4d(虽然文档说 3 是最高的),并重新运行迁移尝试:没有任何错误消息,只有通常的输出。 - ssc
服务器的输出不会发送到您的屏幕,而是将写入服务器文件系统中的日志文件中。该日志文件的名称由服务器的P4LOG设置给出。如果您的服务器没有P4LOG定义,则可能不会写入日志,因此您应该配置一个日志,然后重新运行测试并查看该日志。 - Bryan Pendleton
谢谢,我知道了;当我说“只是通常的输出”时,我的意思是在/var/log/perforce/log中以Perforce server info:开头的消息。我应该更清楚地表达出来。我不确定我在这里看到的是一个Perforce服务器问题;毕竟,服务器只得到了一长串有关changelist描述的查询... - ssc
1个回答

1

谢谢!这个链接解决了我的问题。祝你获得更多奖励 :-) - ssc
@ssc太好了!我已在答案中包含了你选择的解决方案的链接,以提高可见性。 - VonC

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接