Skip to content

Instantly share code, notes, and snippets.

@positron
Last active July 7, 2022 02:42
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save positron/8674615 to your computer and use it in GitHub Desktop.
Save positron/8674615 to your computer and use it in GitHub Desktop.
Create an empty perforce changelist in p4python and save the changelist number
from P4 import P4
client = P4()
# set client.port, client.client, etc here
change = client.fetch_change()
change['Files'] = [] # this contains all the files in default otherwise
ret = client.save_change(change) # ['Change 1234 created.']
new_cl = ret.split()[1]
# now you can do stuff like
client.run_add('-c', new_cl, 'path/to/file.txt')
# or
client.run_integrate(['-c' + new_cl, '//path/from/...', '//path/to/...'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment