【问题标题】:unable to import with git-p4 on windows无法在 Windows 上使用 git-p4 导入
【发布时间】:2011-03-14 13:22:02
【问题描述】:

我一直在尝试使用 git-p4 python 脚本将 p4 depot 路径导入到 git。 配置我的环境(git 1.7.1、python 2.7、Windwos XP、p4 env 变量)后,我尝试运行 git-p4 脚本,得到以下输出:

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

有人知道这里发生了什么吗?如果我尝试从命令行 shell 运行第 332 行声明的 git 命令(git rev-parse origin),则该命令会正确执行。

谢谢。

更新:似乎脚本无法启动其 exec 文件不在执行路径中的任何进程。 我认为这是 Windows 上 python 的初始化问题...

【问题讨论】:

  • 似乎 subprocess.Popen(["git"]...) 的使用忽略了PATH变量。我有一个解决方法,即调用一个调用 git exec 文件的全路径批处理文件
  • 你能澄清一下你到底做了什么吗,我无法让它工作:(

标签: python git perforce git-p4


【解决方案1】:

回应 Restuta 的评论:

  1. 我创建了一个批处理文件以在自定义路径上调用“git.cmd”执行文件。我的批处理文件的内容:
    @"C:\Program Files\Git\cmd\git.cmd" %*

  2. 我已修改 git-p4.py 文件以调用该批处理文件,而不仅仅是“git”。
    例如。 (第 2237 行)原行:init_cmd = [ "git", "init" ]
    替换为:init_cmd = [ "PATH_TO_BATCH_FILE\git.bat", "init" ]
    例如:
    init_cmd = [ "f:\gitp4\git.bat", "init" ]

  3. 对文件上的所有 git 调用(subprocess.Popen 调用)执行相同操作(我一共做了 6 处更改)

希望对您有所帮助!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-03-08
    • 2011-02-08
    • 2016-11-22
    • 1970-01-01
    • 1970-01-01
    • 2016-03-23
    • 2013-09-19
    • 1970-01-01
    相关资源
    最近更新 更多