Tat*_*ate 5 python git perforce git-p4
我一直在尝试使用git-p4 python脚本将p4 depot路径导入git.在配置我的环境(git 1.7.1,python 2.7,Windwos XP,p4 env变量)后,我尝试运行git-p4脚本,设置以下ouptut:
F:\gitp4>c:\Python27\python.exe git-p4.py clone --destination=master //depot/quake/main/...@all
Reading pipe: git config git-p4.syncFromOrigin
Importing from //depot/quake/main/...@all into master
Initialized empty Git repository in F:/gitp4/master/.git/
Traceback (most recent call last):
File "git-p4.py", line 1926, in <module>
main()
File "git-p4.py", line 1921, in main
if not cmd.run(args):
File "git-p4.py", line 1798, in run
if not P4Sync.run(self, depotPaths):
File "git-p4.py", line 1501, in run
self.hasOrigin = originP4BranchesExist()
File "git-p4.py", line 439, in originP4BranchesExist
return gitBranchExists("origin") or gitBranchExists("origin/p4") or gitBranchExists("origin/p4/master")
File "git-p4.py", line 332, in gitBranchExists
stderr=subprocess.PIPE, stdout=subprocess.PIPE);
File "c:\Python27\lib\subprocess.py", line 672, in __init__
errread, errwrite)
File "c:\Python27\lib\subprocess.py", line 882, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified
Run Code Online (Sandbox Code Playgroud)
有谁知道这里发生了什么?如果我尝试从命令行shell运行#332行(git rev-parse origin)的git命令,则命令正确执行.
谢谢.
更新:似乎脚本无法启动其exec文件不在执行路径中的任何进程.我认为这是Windows上的python的初始化问题...
回复 Restuta 的评论:
我创建了一个批处理文件来调用自定义路径上的“git.cmd”执行文件。我的批处理文件的内容:
@“C:\ Program Files \ Git \ cmd \ git.cmd”%*
我修改了 git-p4.py 文件以调用该批处理文件,而不仅仅是“git”。
例如。(第 2237 行) 原行: init_cmd = [ "git", "init" ]
替换为: init_cmd = [ "PATH_TO_BATCH_FILE\git.bat", "init" ]
例如:
init_cmd = [ "f:\gitp4\git.bat “, “在里面” ]
对文件上的所有 git 调用(subprocess.Popen 调用)执行相同的操作(我总共进行了 6 处更改)
希望能帮助到你!