将所有 perforce 分支导入 git 存储库时遇到问题

发布于 2024-11-08 20:21:50 字数 3390 浏览 5 评论 0原文

我正在尝试将一个项目从我公司的 Perforce 仓库导入到 git 存储库中。我已经成功地将单个分支放入单个 git 存储库中,但我想做的是拉入整个项目以及所有分支,但我无法让它正常工作。

我有我的 .p4settings 文件:

P4PORT=perforce-server.local:1666
P4USER=my.username
P4CLIENT=my.clientspec.name

Clientspec 相当简单:

//project/... //my.clientspec.name/project/...
-//project/External/... //my.clientspec.name/project/External/...

第二行是从结帐中排除外部库二进制文件。

我使用以下命令行开始 git-p4 导入:

git p4 clone --verbose --detect-branches --max-changes=100 //project/...@all

这将遍历并检查所有分支名称等,并尝试从第一次提交开始导入(这个特定项目从更改列表 771 开始)

Importing from //project/...@all into project
Initialized empty Git repository in /Users/grant/Development/git_test/project/.git/
Reading pipe: git config git-p4.useclientspec
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 -G branches
Opening pipe: p4 -G branches
p4 -G branch -o branch-1
Opening pipe: p4 -G branch -o branch-1
Reading pipe: git config --bool core.ignorecase
p4 -G branch -o branch-2
...
Opening pipe: p4 -G branch -o branch-n
p4-git branches: []
initial parents: {}

我不确定 p4 是否-git 分支和初始父级在这里应该是空的,但它们确实是空的。

最后,我们即将开始将更改列表导入 git 并发生以下情况:

Getting p4 changes for //project/...
p4 changes //project/...
Reading pipe: p4 changes //project/...
p4 -G describe 771
Opening pipe: p4 -G describe 771
Importing revision 771 (1%)branch is MAIN

    Importing new branch RCMerge/MAIN
p4 changes //RCMerge/MAIN/...@1,770
Reading pipe: p4 changes //RCMerge/MAIN/...@1,770

    Resuming with change 771
parent determined through known branches: Branch-foo
looking for initial parent for refs/remotes/p4/project/MAIN; current parent is refs/remotes/p4/project/Branch-foo
commit into refs/remotes/p4/project/MAIN
parent refs/remotes/p4/project/Branch-foo
p4 -G -x - print
Opening pipe: p4 -G -x - print
Glue/source/.empty
fatal: Invalid ref name or SHA1 expression: refs/remotes/p4/project/Branch-foo
fast-import: dumping crash report to .git/fast_import_crash_26002

这是上面引用的文件:

fast-import crash report:
    fast-import process: 26002
    parent process     : 26000
    at Thu May 19 11:51:54 2011

fatal: Invalid ref name or SHA1 expression: refs/remotes/p4/project/Branch-foo

Most Recent Commands Before Crash
---------------------------------
  checkpoint
  commit refs/remotes/p4/project/MAIN
  committer Some User <[email protected]> 1253574589 -0800
  data <<EOT
* from refs/remotes/p4/project/Branch-foo

Active Branch LRU
-----------------
    active_branches = 0 cur, 5 max

  pos  clock name
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Inactive Branches
-----------------
refs/remotes/p4/project/MAIN:
  status      : dirty
  tip commit  : 0000000000000000000000000000000000000000
  old tree    : 0000000000000000000000000000000000000000
  cur tree    : 0000000000000000000000000000000000000000
  commit clock: 0
  last pack   : 


Marks
-----

-------------------
END OF CRASH REPORT

现在,作为一个新手,我不知道这意味着什么,也不知道如何解决这个问题,或者如果有可能的话。以前有人遇到过类似的问题吗?如果是这样,你是如何解决的?

I'm trying to import a project from my company's Perforce depot into a git repository. I've been successful getting a single branch into a single git repo, but what I'd like to do is to pull in the entire project plus all branches, but I can't get it working correctly.

I have my .p4settings file:

P4PORT=perforce-server.local:1666
P4USER=my.username
P4CLIENT=my.clientspec.name

Clientspec is fairly simple:

//project/... //my.clientspec.name/project/...
-//project/External/... //my.clientspec.name/project/External/...

The second line is to exclude the external library binaries from the checkout.

I use the following command line to start git-p4 importing:

git p4 clone --verbose --detect-branches --max-changes=100 //project/...@all

This goes through and checks all the branch names, etc, and attempts to import starting at the first commit (This particular projects begins at changelist 771)

Importing from //project/...@all into project
Initialized empty Git repository in /Users/grant/Development/git_test/project/.git/
Reading pipe: git config git-p4.useclientspec
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 -G branches
Opening pipe: p4 -G branches
p4 -G branch -o branch-1
Opening pipe: p4 -G branch -o branch-1
Reading pipe: git config --bool core.ignorecase
p4 -G branch -o branch-2
...
Opening pipe: p4 -G branch -o branch-n
p4-git branches: []
initial parents: {}

I'm not sure if p4-git branches, and initial parents are supposed to be empty here, but they are.

Finally we get to the point where it's about to start importing changelists into git and the following happens:

Getting p4 changes for //project/...
p4 changes //project/...
Reading pipe: p4 changes //project/...
p4 -G describe 771
Opening pipe: p4 -G describe 771
Importing revision 771 (1%)branch is MAIN

    Importing new branch RCMerge/MAIN
p4 changes //RCMerge/MAIN/...@1,770
Reading pipe: p4 changes //RCMerge/MAIN/...@1,770

    Resuming with change 771
parent determined through known branches: Branch-foo
looking for initial parent for refs/remotes/p4/project/MAIN; current parent is refs/remotes/p4/project/Branch-foo
commit into refs/remotes/p4/project/MAIN
parent refs/remotes/p4/project/Branch-foo
p4 -G -x - print
Opening pipe: p4 -G -x - print
Glue/source/.empty
fatal: Invalid ref name or SHA1 expression: refs/remotes/p4/project/Branch-foo
fast-import: dumping crash report to .git/fast_import_crash_26002

Here's the file referenced above:

fast-import crash report:
    fast-import process: 26002
    parent process     : 26000
    at Thu May 19 11:51:54 2011

fatal: Invalid ref name or SHA1 expression: refs/remotes/p4/project/Branch-foo

Most Recent Commands Before Crash
---------------------------------
  checkpoint
  commit refs/remotes/p4/project/MAIN
  committer Some User <[email protected]> 1253574589 -0800
  data <<EOT
* from refs/remotes/p4/project/Branch-foo

Active Branch LRU
-----------------
    active_branches = 0 cur, 5 max

  pos  clock name
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Inactive Branches
-----------------
refs/remotes/p4/project/MAIN:
  status      : dirty
  tip commit  : 0000000000000000000000000000000000000000
  old tree    : 0000000000000000000000000000000000000000
  cur tree    : 0000000000000000000000000000000000000000
  commit clock: 0
  last pack   : 


Marks
-----

-------------------
END OF CRASH REPORT

Now, being a perforce novice, I have no idea what this means and have no idea how to resolve this issue, or if its even possible. Has anyone run into a similar issue before? If so, how did you resolve it?

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

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

发布评论

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

评论(1

孤檠 2024-11-15 20:21:50

我终于找到了解决这个问题的方法。事实证明,Perforce 分支映射是反向完成的,这就是这个问题的根源。

Branch-foo 是从 MAIN 中分支出来的,它应该有一个如下所示的分支映射:

//project/MAIN/... //project/Branch-foo/...

然而,创建分支的人颠倒了映射,从而导致了这样的结果:

//project/Branch-foo/... //project/MAIN/...

这个混淆的 git-p4 作为 MAIN 的第一个变更列表从 # 开始771 和 Branch-foo 的变更列表从 #7652 开始,因此它无法在 Branch-foo 中找到任何父级并崩溃。将分支规范更改为上面列出的第一个可以解决问题。

I've finally figured out the solution to this problem. It turns out that a Perforce branch mapping was done in reverse and that was the source of this problem.

Branch-foo was branched off of MAIN, which should have a branch mapping like so:

//project/MAIN/... //project/Branch-foo/...

However, the person who created the branch, reversed the mapping, thus resulting in this:

//project/Branch-foo/... //project/MAIN/...

This confused git-p4 as MAIN had the first changelists starting at #771 and Branch-foo had changelists starting at #7652, thus it couldn't find any parent in Branch-foo and crashed. Changing the branch spec to the first one listed above fixed the probblem.

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