git-p4 sync not working - mysterious stack trace
I'm trying to use git-p4 to clone perforce depot. I keep running into a problem in the git-p4 script, where git-p4 tries to access a dict key that is not defined and throws a trace.
[~/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'
I went into the script and printed out the file dict right at that point and got s开发者_开发问答ome more details, which I'll revise for clarity & anonymity. The faulty dict looked like this:
{'action': 'move/delete', 'path': '//depot/prod/foo/bar', 'rev': '3', 'type': 'xtext'}
My p4 client looks like this:
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/...
As you can see, the faulty dict is a file that does not exist in my client view. I believe this is the source of the problem. However, I am clearly running the command with --use-client-spec. I've also tried git config git-p4.useclientspec true
The verbose output makes it look like it's pulling my view out of
Opening pipe: p4 -u mkramer -c mkramer -G client -o.
If I run p4 -u mkramer -c mkramer client -o
I see the correct view.
If I run p4 -u mkramer -c mkramer files //depot/prod/...#head
I see files that aren't in my view.
Versions of my software:
[~/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
We just ran into this ourselves. P4 appears to have added some new commands last year that git-p4 doesn't fully support; particularly "move/delete" and "move/add".
In order to work around the issue, we changed the line:
if file["action"] in ("delete", "purge"):
to:
if file["action"] in ("delete", "purge", "move/delete"):
So far this is working for us, but I won't assert that this is necessarily a robust fix.
This is a bug that was fixed in recent versions of git-p4 using essentially the patch provided by rbergman. See http://git.kernel.org/?p=git/git.git;a=commit;h=562d53fa69933b3ade2691b99cbe67722313f43c for more details; this patch probably appeared in one of the later 1.6.x releases and is definitely in the 1.7.x releases of git.
精彩评论