4

情况

试图将 1 个“主”和 2 个分支从 perforce 迁移到 git。在使用规范映射分支后,我尝试了一个典型的迁移,导致代码目录重复问题。

问题

运行“git p4”(克隆或同步)时,主分支代码的副本包含在分支中,并且分支代码位于主分支旁边的目录中。我希望只看到 git 暂存区域中的分支代码。

设置

#Perforce Repo Structure
//depot/main/branches/MAINT_01
//depot/main/branches/MAINT_02
//depot/main/branches/mobile

# perforce branch maps
# note: mobile and MAINT_02 are branched (in perforce) from MAINT_01
MAINT_02 -> //depot/main/branches/MAINT_01/... //depot/main/branches/MAINT_02/...
mobile  -> //depot/main/branches/MAINT_01/... //depot/main/branches/mobile/...

# Perforce info
Server version: P4D/LINUX26X86_64/2009.2/241896 (2010/04/10)
Client Spec: (need to exclude many branches here)
//depot/main/branches/... //buildmaster-scm01/...
-//depot/main/branches/BranchA/... //buildmaster-scm01/BranchA/...
-//depot/main/branches/BranchB/... //buildmaster-scm01/BranchB/...
-//depot/main/branches/tempBranch/... //buildmaster-scm01/tempBranch/...
-//depot/main/branches/Bar/... //buildmaster-scm01/Bar/...
-//depot/main/branches/Foo/... //buildmaster-scm01/Foo/...
-//depot/main/branches/Cheese/... //buildmaster-scm01/Cheese/...

# Git Info (Linux Box)
 /git/buildmaster/git2 302  % git --version
 git version 1.7.12.rc2

迁移尝试

这是怎么回事...

agvscm01.inq.com /git/buildmaster/git 225  % git init
Initialized empty Git repository in /git/buildmaster/git/.git/
agvscm01.inq.com /git/buildmaster/git 226  % git p4 sync --detect-branches --use-client-spec //depot/main/branches@all
Importing revision 20482 (88%)
    Importing new branch branches/MAINT_01

    Resuming with change 20482
Importing revision 21137 (96%)
    Importing new branch branches/mobile

    Resuming with change 21137
Importing revision 21396 (100%)
Updated branches: MAINT_01 MAINT_02 mobile
agvscm01.inq.com /git/buildmaster/git 227  % git checkout -b master p4/branches/MAINT_01
Checking out files: 100% (14923/14923), done.
Already on 'master'
agvscm01.inq.com /git/buildmaster/git 228  % git checkout -b rel_2 p4/branches/MAINT_02
Checking out files: 100% (15142/15142), done.
Switched to a new branch 'rel_2'
agvscm01.inq.com /git/buildmaster/git 229  % git checkout -b mobile p4/branches/mobile
Checking out files: 100% (29960/29960), done.
Switched to a new branch 'mobile'
agvscm01.inq.com /git/buildmaster/git 233  % git checkout master
Switched to branch 'master'
  agvscm01.inq.com /git/buildmaster/git2 303  % git branch -a
* master
  mobile
  rel_2
  remotes/p4/branches/MAINT_01
  remotes/p4/branches/MAINT_02
  remotes/p4/branches/mobile

结果

agvscm01.inq.com /git/buildmaster/git2 304  % git checkout mobile
Checking out files: 100% (15073/15073), done.
Switched to branch 'mobile'
agvscm01.inq.com /git/buildmaster/git2 305  % ls
MAINT_01  mobile
agvscm01.inq.com /git/buildmaster/git2 306  %

请注意,MAINT_01 和 mobile 目录具有所有正确的历史记录,但在此级别只能看到 mobile 的内容。

期望

移动分支分支不应包含 MAINT_01 目录。mobile 是 MAINT_01 的一个分支。这可能是非常简单的事情,但我没有看到它。此外,检出 master 只包含 MAINT_01 作为 root。MAINT_01 的内容应该是分支的根。

agvscm01.inq.com /git/buildmaster/git2_bak 307  % git checkout master
Switched to branch 'master'
agvscm01.inq.com /git/buildmaster/git2_bak 308  % ls
MAINT_01
agvscm01.inq.com /git/buildmaster/git2_bak 309  %

感谢这里的任何帮助。


4

1 回答 1

2

从 1.7.11 开始,在 git-p4 模块中存在一个已确认的 git 错误,当同时使用--use-client-spec--detect-branches选项时,该错误将 perforce 代码映射到 git repo。当我向 git 开发团队报告问题时,来自电子邮件回复的片段......

谢谢你的详细报告。这是 1.7.12-rc2 中的一个错误。本系列在 origin/master 之上修复了它。

问题的症结在于,当启用 --use-client-spec 和 --branch-detection 时,文件被映射到 git 中的错误位置。

皮特威科夫(5):

  • git p4 测试:将 client_view() 函数移动到库
  • git p4 测试:添加损坏的 --use-client-spec --detect-branches 测试
  • git p4:在初始化中设置 self.branchPrefixes
  • git p4:在 stripRepoPath 中进行通配符解码
  • git p4:使用 --use-client-spec 进行分支检测
 git-p4.py                     | 75 +++++++++++++++++++++++++++--------------

 t/lib-git-p4.sh               | 18 ++++++++++

 t/t9801-git-p4-branch.sh      | 77 +++++++++++++++++++++++++++++++++++++++++++

 t/t9809-git-p4-client-view.sh | 17 ----------

 4 files changed, 146 insertions(+), 41 deletions(-)

目前他们发布了 1.7.12rc2。等待修复版本

于 2012-08-13T17:03:01.447 回答