salesforce / p4-fusion

A fast Perforce to Git conversion tool written in C++ using Perforce Helix Core C++ API and Libgit2
BSD 3-Clause "New" or "Revised" License
78 stars 15 forks source link

complex --path value, --branch, and BranchSet::stripBasePath incompatibilities #68

Open dchsueh opened 11 months ago

dchsueh commented 11 months ago

Hello,

I have a streams-based repository with branches of the format:

//vehicles/rav4/...
//vehicles/rav4-prime/...
//vehicles/rav4-hybrid/...
//vehicles/corolla/...
//vehicles/corolla-cross/...
//vehicles/corolla-hybrid/...

With the "prime", "hybrid", and "cross" variants child streams of the appropriately-named mainline stream.

I'd like to p4-fusion --branch rav4 --branch rav4-prime --branch rav4-hybrid --path //vehicles/rav*/... to convert these three streams. The client is written to also select only these three.

The internal call to p4 changes -l -s submitted //vehicles/rav*/... will get only the CLs that are associated with the three streams implied by the depot path. This simplifies and shortens the list of CLs requested from the server.

The result of p4-fusion called this way is actually to request the right CLs but they end up skipping because they are determined to be "Not under the depot path" in BranchSet::ParseAffectedFiles due to the prefix strip not matching.

If I use --path //vehicles/... I end up with a lot of zero file CLs (corresponding to the non-rav4 streams) and an eventual segfault whose cause I haven't determined yet.

I can kludge the p4-fusion run to do what I want by manually assigning m_basePath but this is very ugly.

EndlessDex commented 7 months ago

I found the fix/workaround for this issue I think! You have to use the note about the "sub-branches" from the readme.

Use something like this

    --path //vehicles/... \
    --src ~/git/rav4/.git \
    --branch rav4:master \
    --branch rav4-prime:prime \
    --branch rav4-hybrid:hybrid \

This will treat all streams as "sub-branches" and seems to work out correctly. It will analyze all changelists under vehicles BUT only commit the ones relating to the selected branches.

I still occasionally get a segfault, but when i run the script again it will pickup where it left off and complete successfully.