Perforce Tip: how to apply my default change to the release branch
Reasons I need this hack
- Our current project uses mix platforms (WIN64/Linux64), so the file path contains backward slash
\. - My p4 CLI program is from Windows installer because Cygwin version has the slash issue.
- Windows version of p4 has no such issue under Cygwin if we only feed it relative path.
How to?
Create the patch,
p4 diff -du -db main-branch/... > ~/mywork.patch
Go to the work directory of release branch.
cd dir-release-branch/
p4 edit the files I want to patch under release branch.
Please note,
-
lsdiffis from the packagepatchutils. -
noslwill strip the backward/forward slashes. It's written by me.
cat ~/mywork.patch|lsdiff|nosl 5|p4 -x - edit
Patch the files and DONE!
patch -p5 < ~/mywork.patch
Here is the source code of nosl placed in my .bashrc,
nosl ()
{
if [ -z "$1" ]; then
echo "Usage: echo /hello/world|nosl num";
echo "strip num leading slashes";
else
perl -pe "\$n=$1;while(\$n>0){ \$_=~ s/[^\\\\\\/]*[\\\\\\/]+//;\$n--; }";
fi
}
BTW, you could avoid all the trouble of Perforce by switching to Git.
UPDATE: git-p4 is better solution.