P4.fetch_change() creates a change spec with Change equal to 'new'. I need to create a change spec with an actual number (that won't collide with any other changes). IOW, I need to be able to reserve a changelist number.
How can this be done with P4Python?
Context: My script takes in an already-existing changelist number. I need to be able to test that the script works correctly.
P4.save_change() generates a changelist number -- that is, it creates a numbered, pending changelist. Try something like:
changespec = P4.fetch_change()
changespec[ "Description" ] = "placeholder"
P4.save_change( changespec )
Note that p4.fetch_change()
gives you the dict of the current default changelist!
You might already have files in there! So to really create an empty one you can just pass a dict with 'Change': 'new' and a 'Description'.
I couldn't find a way to make save_change
return the actual changelist integer. So one can split the result and have the nr that way:
from P4 import P4
def create_empty_changelist(desc='some description'):
p4 = P4()
p4.connect()
result = p4.save_change({'Change': 'new', 'Description': desc})[0]
return int(result.split()[1])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With