Perforce is a great version control system which I've been using at work since 2005 (well, strictly speaking, I started using it in 2004, but that was just casual usage). On this page, I'll list some hints on Perforce, which I tend to forget on how to do. If other folks can find this scratchpad useful too, that's a bonus :-)
View the diff of a given change id
$ p4 describe 35297
View the diff of a given change id that is shelved
$ p4 describe -S 35297
Ask perforce if a certain change has been integrated
$ p4 integrate -n -b mybranch-2.0 -s @35297,35297
See pending changelists
$ p4 changelists -s pending -u myuser
See all changes within a certain date span
This is how you check all changes in the source tree (from where you stand) between the first of January 2011 and the first of February the same year:
$ p4 changes ...@2011/01/01,2011/02/01
Checkout all files you've edited locally
Checkout all files you've edited locally but have forgotten to run p4
edit
on first:
$ p4 diff -se ... | xargs p4 edit
TAB completion
I've created BASH completion for all p4 commands, you can get the completion file here.
With it in place, you can do:
Auto completion of commands
$ p4 c[TAB][TAB]
change changelists client counter
changelist changes clients counters
Auto completion of branches
$ p4 integrate -b plugins-comm[TAB][TAB]
plugins-common-1.1 plugins-community-3.1 plugins-community-3.4
plugins-community plugins-community-3.2 plugins-community-3.5
plugins-community-3.0 plugins-community-3.3 plugins-community-3.6
The branch list is cached, in case you were wondering :-) See ~/.p4.d
.
Auto completion of users
$ p4 changes -u s[TAB][TAB]
saa shah shud soku stbe sym sai shaon sms sta support
The user list is cached, in case you were wondering :-) See ~/.p4.d
.
Auto completion of command specific options
$ p4 integrate -[TAB][TAB]
-b -d -Ds -f -i -n -r -t
-c -Di -Dt -h -I -o -s -v
Auto completion of depot paths
$ p4 print //depot/[TAB][TAB]
//depot/BETA //depot/core //depot/projects //depot/tools
//depot/branches //depot/escenic //depot/ps
//depot/BUILD //depot/main //depot/RELEASE
Coloured diff
# apt-get install colordiff
Then add the following to your .bashrc
:
export P4DIFF=colordiff
Once you've evaluated your .p4config
or .bashrc
, you'll get your
diffs in wonderful colours.