Perforce Tip: how to apply my default change to the release branch

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,

  • `lsdiff’ is from the package `patchutils’.
  • `nosl’ will strip the 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. I put it in my .bashrc

function nosl(){
  if [ -z "$1" ]; then
    echo "Usage: echo /hello/world|nosl num"
    echo "strip num leading slashes"
    perl -pe "$n=$1;while($n>0){ $_=~ s/[^/]*/+//;$n--; }"

BTW, you could save all the trouble of Perforce by switching to Git.



Fill in your details below or click an icon to log in: 徽标

You are commenting using your account. Log Out /  更改 )

Google+ photo

You are commenting using your Google+ account. Log Out /  更改 )

Twitter picture

You are commenting using your Twitter account. Log Out /  更改 )

Facebook photo

You are commenting using your Facebook account. Log Out /  更改 )


Connecting to %s