P4V secrets - calling P4V from the command line

Jan 14, 2010

Hi, me again.

You might have seen my last post on the C++ API and downloaded the Notepad++ plug-in from here: NppPerforcePlugin. If you installed the plug-in and/or looked at the code, you ought to have noticed that there are set of menu options invoking P4V directly (if you happen to have P4V.exe in your path).

A few of these commands have been in the public domain for a while, such as how to invoke Timelapse View™, but you might be interested in what else is available.

The full syntax to call P4V from the command line and immediately invoke a particular component is

p4v.exe -p <port> -c <client> -u <user>
  [-C <charset>] [-P <password>] [-cmd "<command> <file>"]

Port, client and user are mandatory (in that order), everything else is optional. If a command is given, quotes have to be placed around the command and the file name so that both are passed as a single parameter.

Here is the full list of all supported commands (these commands are undocumented and unsupported and subject to change in future versions without notice):

Command Description
history File history of the specified file
open Open P4V with the specified file
submit Submit the specified file
properties Properties of the specified file
diffdialog Open a dialog to specify two file revisions to compare
prevdiff Compare the local file against the have revision
annotate Timelapse View of the specified file
tree Revision graph of the specified file

For example:

p4v.exe -p 1666 -c myws -u sven -cmd "properties //depot/myproject/myfile.scala"

This will work with P4V 2009.1 and P4V 2009.2. Enjoy :-)

Happy hacking

Sven Erik

Posted In: 
sknop's picture
About the author

Sven Erik Knop is a technical marketing manager at Perforce Software.

See all posts by