"svn status" for Perforce

Status command is very important part of  any VCS (Version Control System) local interface. It allows you to check your workspace state and ensure correct commit will be created.

Perforce is a commercial VCS that is similar to CVS (revisions per file) and SVN (global revisions of whole tree). It's support for status command is very clumsy. Let's check how we can emulate status with this tool using small script:

echo === extra files not tracked by Perforce ===
find . '!' -type d '!' -executable | p4 -x - have 2>&1 | grep 'not on client' | \
 sed '/\/moc_/d;/\.so/d;/\.o /d;/Makefile /d;/\.a /d'

echo === Current changelist ===
p4 changelist -o

As you can see we implemented "ignore" mechanism in above script (by sed filtering). "Extra files not tracked by Perforce" reflects "?"-status from CVS/SVN. "Current changelist" reflects "A,D,U"-statuses from CVS/SVN.

By using such script you can ensure your commit contains all files from your workspace, thus will be buildable on other developers' machines.

This entry was posted in en and tagged , , . Bookmark the permalink.

One Response to "svn status" for Perforce

  1. Hi Daruisz,

    nice script but a bit complicated. You can in fact use a simple

    find . -type f -not -executable | p4 -x – add

    Perforce will sort out the files that have not been added yet, and automatically add them to your changelist.

    Leaves the question: how to filter out the files you do not want to submit:
    these you can exclude by mapping them out in the client workspace mapping. Have a look at the documentation on 'p4 client' for details.

    Cheers

    Sven Erik

Comments are closed.