【问题标题】:Perforce to Git: Invalid option: -rPerforce 到 Git:无效选项:-r
【发布时间】:2018-08-22 02:42:08
【问题描述】:

我正在尝试将项目从 Perforce 迁移到 Git。我使用git-p4 作为我的主要工具来为我完成繁重的工作,它默认带有 Windows 上的 Git:

C:\Program Files\Git\mingw64\libexec\git-core\git-p4.

Migrating Perforce to Git in Windows 之后,我已经到了执行克隆命令的步骤:git p4 clone <PerforceRepo>(其中 p4 是文件 git-p4.py 的别名)

我不断收到错误:

无效选项:-r。

C:\P4-To-Git>git p4 clone //depot/C:\build\mainline@all .
Importing from //depot/C:/build/mainline@all into .
Reinitialized existing Git repository in C:/P4-To-Git/.git/
Perforce client error:
        p4 -h for usage.
        Invalid option: -r.
Traceback (most recent call last):
  File "C:\Program Files\Git\mingw64\libexec\git-core\git-p4", line 3840, in <module>
    main()
  File "C:\Program Files\Git\mingw64\libexec\git-core\git-p4", line 3834, in main
    if not cmd.run(args):
  File "C:\Program Files\Git\mingw64\libexec\git-core\git-p4", line 3706, in run
    if not P4Sync.run(self, depotPaths):
  File "C:\Program Files\Git\mingw64\libexec\git-core\git-p4", line 3546, in run
    changes = p4ChangesForPaths(self.depotPaths, self.changeRange, self.changes_block_size)
  File "C:\Program Files\Git\mingw64\libexec\git-core\git-p4", line 852, in p4ChangesForPaths
    changeEnd = p4_last_change()
  File "C:\Program Files\Git\mingw64\libexec\git-core\git-p4", line 317, in p4_last_change
    return int(results[0]['change'])
KeyError: 'change'

我查看了 p4-git python 文件,没有使用-r 的地方。有什么帮助吗?

【问题讨论】:

  • 您的 P4 路径似乎不正确://depot/C:\build\mainline@all。如果 git-p4 支持,请使用仓库路径(如 //depot/foo/bar/mainline/...)或本地路径(C:\build\mainline\...)。另外,您确定“@all”吗?那是标签吗?
  • @sferencik 我的 p4 路径似乎是有效的,因为其他(您的)路径示例不起作用 + 我示例的第一行显示路径正确。我不确定你的意思是什么?你能输入整个命令吗? @all 告诉 git-p4 也导入所有历史记录
  • //depot/foo/bar/mainline/... 只是一个例子。自然,您的项目不在“foo/bar”下。您需要找到项目的实际仓库路径。你完全使用 Perforce 吗?或者您团队中可以帮助您找出正确的仓库路径的人?我强烈怀疑//depot/C:\build\mainline 是否正确。
  • @sferencik 抱歉,我现在很困惑,您的第一条评论建议使用 "foo/bar" 仓库路径,然后您的第二条 cmets 说它看起来不像“foo/bar”。你能帮我找到我的仓库路径吗?显示一个仓库路径示例?
  • @SandraK 连接到您的 Perforce 服务器并尝试运行一些命令,例如 p4 depotsp4 files //depot/...p4 dirs //depot/*。这可能会让您大致了解仓库的外观,并建议您要导入的路径。如果您在尝试运行这些命令时遇到连接错误,那么这项工作注定要失败,因为您没有可以通过此机器上设置的 P4PORT 值访问的 Perforce 服务器(这是 git-p4 将尝试的使用)。

标签: git version-control migration perforce git-p4


【解决方案1】:

尝试将git-p4.retries 设置为 0?

if retries > 0:
    # Provide a way to not pass this option by setting git-p4.retries to 0
    real_cmd += ["-r", str(retries)]

或者升级您的p4 可执行文件,使其支持-r 全局标志——这个选项是在2012.2 版本中添加的:

Minor new functionality in 2012.2

    #384638 *** ** *
        The net.maxwait configurable can be used to specify a hard limit
        (in seconds) on the maximum time that a connection will wait for
        any single network send or receive to complete. The 'p4 sync'
        command now supports a '-r' global flag to specify that the sync
        command should be retried if a network error occurs.

【讨论】:

  • 感谢您的回答,我该如何设置git-p4.retries?我尝试打开文件并对其进行硬编码,但没有成功
  • 不肯定(我是一个完整的 git 新手,只是在这里搜索文档)但我认为你想要 git configgit-scm.com/docs/git-config 或者如果这不起作用,只需获取一个新的 p4 可执行文件,它是免费下载的 (ftp.perforce.com),您所要做的就是用新的替换旧的。
  • 你弄清楚如何设置 git-p4.retries 了吗?
猜你喜欢
  • 2015-04-14
  • 1970-01-01
  • 1970-01-01
  • 2017-01-17
  • 2013-05-01
  • 2013-05-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多