views:

113

answers:

0

I have the task of migrating my team & source from git to Perforce, and I'm looking for ideas on how to move the git history into p4.

I would be happy moving master branch only. However, even that is proving problematic.

I'm using the wonderful git-p4 tool. I create an destination area in my p4 workspace, and use git p4 clone //depot/StuffFromGit to start tracking it in git-p4. I graft all my git repository's changes into the git-p4 clone. I can then git p4 submit and be done, all the changes are pushed to p4.

It works great when the git history looks like this, nice and linear:

A---B---C---D

The problem comes with multiple people working on the project. Even though they are working on master, that still creates branches that split and merge. Still, git-p4 bravely handles this:

A---B---C---E
     \--D--/

git p4 traverses OK, committing ABCDE in order (or ABDCE, either person's history first).

The problem comes when, for example, C and D both change the same file, and E is a real-honest-to-goodness merge. git p4 rebase fails here; it'll rewind the commits, but during playback it'll apply C first, then attempt D and find a conflict. It'll then stop, asking me to merge. Well, E contains the merge but it's asking me to hand-merge! 'git p4 submit' will fail in a similar way, only now it's p4 rejecting the pre-merge change.

Using index info to reconstruct a base tree...
Falling back to patching base and 3-way merge...
Auto-merging main.cpp
CONFLICT (content): Merge conflict in main.cpp
Failed to merge in the changes.
Patch failed at 0005 Changing main

So now I'm stuck. Is there a way to sanitize the git history or to get git-p4 to understand it? It's frustrating as the merges are there.

Thoughts I've had:

  • Use git filter-branch to remove all mention of conflicting files. I'd get the history comments across, though missing many file changes. With about 3000 commits in the history, I would wind up removing all of the key (busy) files' history. At the end of the filtered-files import, I'd add the missing files back by doing a final commit of the HEAD.
  • Dump the history, do a single p4 commit of the HEAD (simple but sad).
  • Not move to p4: I've worked that idea for as long as possible.

None of which are really great. Any ideas on how to git 'gt p4 rebase' or 'git p4 submit' to work?