Search code examples
perforcep4python

How to get the changelist number of perforce?


I managed to create an empty changelist in my perforce client workspace following the steps below :

>>> from P4 import P4,P4Exception
>>> p4 = P4()
>>> p4.connect()
P4 [ciastro@ciastromac perforce:1666] connected
>>> change = p4.fetch_change()
>>> change
{'Status': 'new', 'Client': 'ciastromac', 'User': 'ciastro', 'Change': 'new', 'Description': '<enter description here>\n'}
>>> change[ "Description" ] = "Autosubmitted 3rd changelist"
>>> p4.input = change
>>> p4.run_submit( "-i" )

this does add a changelist but I do not get the changelist number to add files to the changelist. I need the changelist number to submit to depot as well.


Solution

  • You don't need to define a new changelist spec at all in order to submit the default changelist. Just do:

    p4.run_submit("-d", "Autosubmitted 3rd changelist")
    

    If you don't provide a changelist number, p4 submit will automatically take the files from the default changelist, put them into a new numbered changelist, and submit it. (If you supply the -d flag with a description, it will use the description instead of prompting you to edit the changelist spec.) The output of p4 submit will tell you what number the changelist ended up with.