January 14, 2010

P4V secrets - calling P4V from the command line

Flexible Workflows

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):

historyFile history of the specified file
openOpen P4V with the specified file
submitSubmit the specified file
propertiesProperties of the specified file
diffdialogOpen a dialog to specify two file revisions to compare
prevdiffCompare the local file against the have revision
annotateTimelapse View of the specified file
treeRevision 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