git-p4 同期が機能しない - 謎のスタック トレース
質問
git-p4 を使用して Perforce デポのクローンを作成しようとしています。git-p4 スクリプトで、定義されていない dict キーに 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/...
ご覧のとおり、問題のある dict はクライアント ビューに存在しないファイルです。これが問題の根源だと思います。ただし、明らかに --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"):
これまでのところ、これは私たちのために機能していますが、これは必ずしも堅牢な修正であると主張しません。
他のヒント
これは、基本的に rbergman によって提供されたパッチを使用して git-p4 の最近のバージョンで修正されたバグです。見る http://git.kernel.org/?p=git/git.git;a=commit;h=562d53fa69933b3ade2691b99cbe67722313f43c 詳細については;このパッチはおそらく、その後の 1.6.x リリースのいずれかに含まれており、git の 1.7.x リリースには確実に含まれています。