Wednesday, July 1, 2009

Perforce ChangeList Diff

I use Perforce as source code version control system. I don't use any visual client.

Perforce allows you to view differences between the version you are working on and the latest version in the repository. To view the difference for one file, we use following command

p4 diff -du //depot/prod/branch/pkg1/test.java

To view the difference for multiple files opened for edit under pkg we use following command:

p4 diff -du //depot/prod/branch/pkg1/...

Many times we create a change list that contain multiple files spanning multiple packages. There is no way to view difference for all files in a change list. I wrote a simple shell script that will show the diff of all the files in a change list. Just copy the script below in a shell script, assign it execute permission and you are good to go.

#!/bin/sh
echo "Generating diff for ChangeList: $1"
p4 opened -c $1 | cut -d "#" -f 1 | xargs p4 diff -du

Let's say you saved the script in p4_cl_diff.sh then the command to use the script would be:

p4_cl_diff.sh

Let me know if you find it useful.

-Naren

1 comment:

  1. Correction:

    p4_cl_diff.sh

    should be


    p4_cl_diff.sh changelist#

    ReplyDelete