无法在 Windows 上使用 git-p4 导入

发布于 2024-10-21 13:47:05 字数 1412 浏览 2 评论 0原文

我一直在尝试使用 git-p4 python 脚本将 p4 仓库路径导入到 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 的初始化问题......

I've been trying to import a p4 depot path to git using git-p4 python script.
After configuring my environment (git 1.7.1, python 2.7, Windwos XP, p4 env variables) I tried to run
the git-p4 script, geetting the following 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

Does anybody know what's going on here? If I try to run the git command that line #332 states (git rev-parse origin) from the command line shell, the command is correctly executed.

Thanks.

Update: Seems that the script is unable to launch any process whose exec file is not in the execution path.
I think it's an initialization issue with python on windows...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

∞觅青森が 2024-10-28 13:47:06

回应 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 个更改)

希望有帮助!

In response to Restuta's comment:

  1. I've created a batch file to call "git.cmd" exec file on a custom path. Contents of my batch file:
    @"C:\Program Files\Git\cmd\git.cmd" %*

  2. I've modified the git-p4.py file to call that batch file instead of just "git".
    Eg. (line 2237) Original line: init_cmd = [ "git", "init" ]
    Replace with: init_cmd = [ "PATH_TO_BATCH_FILE\git.bat", "init" ]
    E.g:
    init_cmd = [ "f:\gitp4\git.bat", "init" ]

  3. Do the same for all the git calls on the file (subprocess.Popen calls) (I've a total of 6 changes)

Hope it helps!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文