Question

I'm trying to work with P4Python, and hoping to find a way to be able to check what's the type of change of each file in the changelist. I mean, I'd like to know if it's a modification, or whether this file has Marked for Add or Marked for Delete.

My code is something like

    p4.connect()
    clientSpec = p4.fetch_client()
    depotList = p4.run_opened("-c", changelistNumber)
    p4.disconnect()

So, I have the list of files in the changelist, and now I can iterate over them, and I wish to remove the ones which are Marked for delete for example.

Your help is very appreciated!

Was it helpful?

Solution

The result of p4.run_opened is an array that has a map for each opened file. This map has the following keys:

'haveRev'
'rev'
'clientFile'
'client'
'user'
'action'
'type'
'depotFile'
'change'

In order to find out the type of change, iterate over the array and ask each item for the 'action'. In one of my current changelists, the first file is opened for 'edit':

import P4
p4 = P4.P4()
p4.connect()
p4.run_opened()[0]['action']
p4.disconnect()

will return: 'edit'

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top