p4-opened

One of the primary annoyances I have had with perforce is the behaviour of ‘p4 opened’. p4 opened will list all your opened files in an unhelpful ordering, with files opened in different changelists mixed together. I ended up writing a quick ruby script in order to have more descriptive output for this command.

This script, p4-opened, will seperate opened files by changelist, printing the change description at the top. This ends up being much more useful. For example, instead of printing the following for ‘p4 opened’:

//path/to/file.2#4 - edit default change (text)
//path/to/file.3#1 - edit default change (text)
//path/to/file.4#3 - edit change 305888 (text)
//path/to/file.5#1 - edit change 307394 (text)
//path/to/file.6#60 - edit change 305888 (text)
//path/to/file.7#8 - edit change 305888 (xtext)

p4-opened will display the following output:

--------------------------------------------------------------------------------
Change 305888:

        The description for this changelist will be printed here

//path/to/file.4#3 - edit change 305888 (text)
//path/to/file.6#60 - edit change 305888 (text)
//path/to/file.7#8 - edit change 305888 (text)
--------------------------------------------------------------------------------
Change 307394:

        This is another changelist, with one file.

//path/to/file.5#1 - edit change 307394 (text)
--------------------------------------------------------------------------------
Change change:

        Default changelist.

//path/to/file.1#1 - edit default change (text)
//path/to/file.2#4 - edit default change (text)
//path/to/file.3#1 - edit default change (text)
--------------------------------------------------------------------------------

Installation is fairly easy, assuming you have ruby installed: simply place the script in some directory on your path. You can download it from my github at http://github.com/nflath/p4-opened. If you have any questions or suggestions, feel free to contact me about them.

Leave a Reply