Perforce MediaWiki extension

Tags implemented by this extension
The Perforce MediaWiki extension implements the following tags:

p4change
The p4change tag produces a P4Web link to a Perforce changelist. The usage is as follows:

1234 1234

The first form produces a simple link containing only the change number:
 * 1234

The second form produces a full line containing additional information fetched from Perforce:
 * 1234

p4changes
The p4changes tag produces a list of Perforce changelists. The usage is as follows:   

The following example uses all of the parameters (  ): 

Note that this is equivalent to running the command:  

p4print
The p4print tag places the contents of a depot file directly into the page. The usage is as follows:



The file contents will be rendered as raw text inside a  tag, with any HTML escaped.

p4variants
The p4variants tag produces a list of branches from a specified path that have changes in them which have not yet been integrated back. This is a time-consuming query, so this tag uses AJAX to load the output on demand rather than automatically including it in the page. The usage is as follows:



The supplied path may be a single file or a directory (path ending in * or ...). Branches of the user-supplied path are identified by examining integration records with p4 integrated and looking for correspondences between the supplied path and the individual paired files. Unintegrated changelists are found by running p4 interchanges between identified branches and the supplied path, and the results are filtered by running p4 integrate -n to verify that at least one file in each candidate changelist has a pending integrate action.

Here is an example of the above usage (click [find variants] to run the query):



p4changes
Same as the p4changes tag, with attributes specified in the following order:

p4chgcats
Changelists grouped into categories according to description keywords. Usage:

The "prefix" parameter is a markup string that should be prepended to each changelist result. (For example, specify a * here to create a bullet list, or a # for a numbered list.)

The "format" parameter behaves the same as in the #p4job: function.

The "keyword" parameters will be case-insensitively matched against the change descriptions to determine which changelists should go under each category.

The "category" parameters specify the header that should go above each list of changelists. Multiple keywords can map to one category, and vice versa, but each category is listed only once (in the order first given).

Example usage:

p4diff2
Displays differences between two files or paths. Usage:

The path arguments are required, should be in depot syntax, and may include revision specifiers. The flags argument may contain the -d or -q flags as implemented by the standard p4 diff2 command; the output of the parser function will be the output of the p4 diff2 command enclosed in a wiki-style preformatted text block.

The flags argument may also include the -A flag (implemented by this extension), which will reduce the output to a sum of added + changed lines.

p4info
Displays server info (same as "p4 info|grep Server"). Usage:

p4job
Displays information about a single job. To generate a P4Web link to a job:

To extract a particular field from a job:

The "format" parameter is a whitespace-separated list of any of the following keywords:
 * Nchars: (limits output to N characters)
 * Nwords: (limits output to N space-separated words)
 * Nlines: (limits output to N newline-separated lines)
 * Nsents: (limits output to N punctuation-separated sentences)
 * Nparas: (limits output to N blank-line-separated paragraphs)
 * line: (normalizes all whitespace to spaces, eliminating linebreaks)
 * text: (wraps multi-line output in a  block)
 * raw: (wraps multi-line output in a  block and disables all wiki markup)
 * template:TEMPLATE: (wraps output in user-defined template TEMPLATE)

p4jobs
Displays a table of job data.

The "job-expr" parameter is a standard Perforce job search expression.

The "fields" parameter is a whitespace-separated list of job fields. The table is sorted by the fields in the order given; to sort a particular field in reverse order, put a ! before the field name.

The "maxjobs" parameter limits the number of jobs produced (default 20, max 100).

The "format" parameter formats each field, using the same logic as used by the #p4job: function. A formatting option can be applied to only a certain column by appending #FieldName to the end of it.

The "table-attr", "tr-attr", and "td-attr" are HTML attributes that will be added to the table, each table row, and each table cell.

There can be any number of matched "query"/"action" arguments. Each "query" is either a job search expression or one of the keywords ODD, EVEN, or ALL (which match odd rows, even rows, or all rows of the table). The "action" is applied to each row of the table matching the query, and can be one of: where tr-attr is a HTML attribute (or list of attributes) to be applied to the matching table rows, and format is a formatting string following the same logic as the basic "format" parameter (except it is only applied to matching rows). The actions will be applied in the order specified, so later actions can augment or override earlier ones. (Note: simple job queries consisting of one search term and no wildcards will be handled by in-memory searching of the already-fetched data; more complex strings will generate new queries against the Perforce server.)
 * attrib:tr-attr
 * format:format

Example usage:

p4graph
Generates GraphViz DOT markup graphing the history of a file. If the GraphViz extension is installed, the graph will be rendered on the page. Usage:

The optional "constraint" parameter specifies which elements the graph should try to keep aligned: "file" or "change" (default is neither).

p4print
Same as the p4print tag, but provides additional options for translating the output. The syntax is:

The "mode" can be any one of "raw", "text", or "wiki":


 * raw: All HTML is escaped and the result is displayed in a  block.  This is exactly equivalent to using the tag.  raw is the default mode if none is specified.


 * text: The file contents are treated as if they were wiki text, but a space is placed at the beginning of each line to put the file into a  block.  Any wiki markup or allowed HTML in the file will be rendered as in a normal page (within a   block), and URLs will be rendered as links.  This option should be suitable for most plain text files.  (Note that some HTML tags may break up the block, in which case raw is a better choice.)


 * wiki: The file contents are treated as if they were wiki text. This is probably only useful for files that contain no formatting at all, files that are specifically wiki-formatted, or very minimal HTML pages.

p4variants
Same as the p4variants tag:

The Special:Perforce page
The Special:Perforce page can be used to put some of the parser function queries in a dedicated dynamically generated page. This is primarily useful in cases where the query results are arbitrarily large and you don't want to embed them directly into the page, but you want to provide easy access to them.

The link syntax is:

Special:Perforce/query/arg1@@arg2@@...

with query being a Perforce parser function name minus the leading "#p4". For example: Special:Perforce/changes/50@@//public/jam/src/...@@long

This syntax doesn't work too well for some of the functions with tricky argument lists; the main one it's useful for is.

The default Special:Perforce page contains some generic information about your Perforce server and a small collection of Perforce-related links.