One of the duties of a branch curator (usually a senior developer or project manager) is periodically refreshing her branch with changes from an upstream branch. For example, if she is curating a development branch, she will need to periodically pick up changes from the MAIN or INTEGRATION branch.
When I've had this responsibility, I constantly looked for ways to remind myself to run the integrations frequently. I really wanted to see a list of pending integrations in a tool that I used every day. I've tried using widgets in wikis and intranets, scripts that sent pending integrations weekly via email, and a few other methods.
In order to create a Branch Curator's Dashboard, let's start by making a Pending Integrations tab (applet). This tab will show me, for each branch spec that I own, all pending integrations, using the forward and reverse view mapping. (I always use branch specs to manage integration activities.)
The source code and a README file with more complete installation instructions are available in the Public Depot. Here's a brief description of how the tab works.
1. Implement the tab
The tab (applet) is implemented in a file called interchanges.html, which we check in as //depot/jsapi/interchanges.html. More on this file later; the name came from my hope that the undoc interchanges command would be available in P4JsApi.
2. Register the tab
We create a centralsettings.js file that defines our tab as a P4V applet. We check in this file as //depot/jsapi/centralsettings.js. The relevant part of the file is:
3. Enable the tab for a group
We add a protections table entry specifying that the centralsettings.js file should be used for the group BranchCurators.G:
Of course, we could use any user or group here, and define different settings files for different users or groups. See the P4JsApi guide for more details.
4. Start using it
We have our users enable applets in P4V, as described in the P4JsApi guide. After restarting P4V, the View menu has a new entry called Pending Integrations. Here's a screen shot of the tab in action in P4V.
The interchanges.html implementation file uses the P4JsApi to execute a series of Perforce commands. It gathers a list of branches owned by the current user, then runs a preview integration (p4 integ -n) for each branch. The data is put into an HTML table for display to the user. The snippet below shows the most interesting bits of the file.
The README file has a list of possible future enhancements. Probably the most useful enhancement is the ability to let a user choose which branch specs to view in the tab, rather than using the branch specs they own. Feel free to customize interchanges.html if you want to use different criteria for selecting branch specs of interest.
The P4JsApi opens up all sorts of interesting possibilities for making custom dashboards and views in P4V. Hopefully, applets like this one will provide the building blocks for a richer P4V experience. There are other examples in the Public Depot as well.
A version of this article first appeared in p4 blog.
Randy DeFauw is a consultant with Perforce Software. Prior to joining Perforce, he was a certified Perforce consulting partner and trainer. He has extensive experience with Perforce configuration, administration, and integrations.