我正在尝试使用 git-p4 克隆 perforce depot。我一直在 git-p4 脚本中遇到问题,其中 git-p4 尝试访问未定义的字典键并抛出跟踪。

[~/p4/prod@ernie02] (master) $ 
git p4 sync --verbose --use-client-spec //depot/prod/
Reading pipe: git config git-p4.user
Reading pipe: git config git-p4.password
Reading pipe: git config git-p4.port
Reading pipe: git config git-p4.host
Reading pipe: git config git-p4.client
p4 -u mkramer -c mkramer -G client -o
Opening pipe: p4 -u mkramer -c mkramer -G client -o
None
Doing initial import of //depot/prod/ from revision #head into refs/remotes/p4/master
p4 -u mkramer -c mkramer -G files //depot/prod/...#head
Opening pipe: p4 -u mkramer -c mkramer -G files //depot/prod/...#head
commit into refs/remotes/p4/master
p4 -u mkramer -c mkramer -G -x - print
Opening pipe: p4 -u mkramer -c mkramer -G -x - print
p4 -u mkramer -c mkramer -G users
Opening pipe: p4 -u mkramer -c mkramer -G users
Traceback (most recent call last):
  File "/home/mkramer/git/bin/git-p4", line 1922, in <module>
    main()
  File "/home/mkramer/git/bin/git-p4", line 1917, in main
    if not cmd.run(args):
  File "/home/mkramer/git/bin/git-p4", line 1651, in run
    self.importHeadRevision(revision)
  File "/home/mkramer/git/bin/git-p4", line 1461, in importHeadRevision
    self.commit(details, self.extractFilesFromCommit(details), self.branch, self.depotPaths)
  File "/home/mkramer/git/bin/git-p4", line 1063, in commit
    data = file['data']
KeyError: 'data'

我进入脚本并打印出文件字典,并获得了更多详细信息,为了清晰和匿名,我将对其进行修改。有问题的字典看起来像这样:

{'action': 'move/delete', 'path': '//depot/prod/foo/bar', 'rev': '3', 'type': 'xtext'}

我的 p4 客户端如下所示:

Client: mkramer
Update: 2010/04/27 14:46:10
Access: 2010/04/27 14:51:29

Owner:  mkramer
Description:
        Created by mkramer.
Root:   z:\p4
AltRoots:
        z:\p4
        /home/mkramer/p4
Options:        noallwrite noclobber nocompress unlocked nomodtime normdir
SubmitOptions:  submitunchanged
LineEnd:        share
View:

        //depot/prod/... //mkramer/prod/...
        -//depot/.../foo/... //mkramer/.../foo/...

如您所见,错误的字典是我的客户端视图中不存在的文件。我相信这就是问题的根源。但是,我显然正在使用 --use-client-spec 运行命令。我也尝试过 git config git-p4.useclientspec true 冗长的输出让它看起来像是在拉我的视线

Opening pipe: p4 -u mkramer -c mkramer -G client -o.  

如果我跑 p4 -u mkramer -c mkramer client -o 我看到了正确的观点。

如果我跑 p4 -u mkramer -c mkramer files //depot/prod/...#head 我看到了不在我视图中的文件。

我的软件版本:

[~/p4/prod@ernie02] (master) $ p4 -V
Perforce - The Fast Software Configuration Management System.
Copyright 1995-2009 Perforce Software.  All rights reserved.
Rev. P4/LINUX26X86_64/2009.1/205670 (2009/06/29).
[~/p4/prod@ernie02] (master) $ git --version
git version 1.7.0.5
[~/p4/prod@ernie02] (master) $ python -V
Python 2.6.5
有帮助吗?

解决方案

我们自己遇到了这个。去年,P4似乎添加了一些新命令,Git-P4不完全支持。特别是“移动/删除”和“移动/添加”。

为了解决这个问题,我们更改了行:

if file["action"] in ("delete", "purge"):

到:

if file["action"] in ("delete", "purge", "move/delete"):

到目前为止,这对我们有用,但我不会断言这一定是一个可靠的解决方案。

其他提示

这是一个在最新版本的 git-p4 中修复的错误,主要使用 rbergman 提供的补丁。看 http://git.kernel.org/?p=git​​/git.git;a=commit;h=562d53fa69933b3ade2691b99cbe67722313f43c 更多细节;该补丁可能出现在较晚的 1.6.x 版本之一中,并且肯定出现在 git 的 1.7.x 版本中。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top