Python & P4V: Automating changelist description
Pregunta
I have a variable, fulltext
, which contains the full text of what I want the description of a new changelist in P4V to be. There are already files in the default changelist.
I want to use python to populate the description of a new changelist (based on default) with the contents of fulltext
.
How can this be done. I've tried this:
os.sytem("p4 change -i")
print fulltext
But that doesn't create any new change list at all. I don't know how to tell p4 that I'm done editing the description.
Solución
If you're trying to write Python programs that work against Perforce, you might find P4Python helpful: http://www.perforce.com/perforce/doc.current/manuals/p4script/03_python.html
Otros consejos
It is easiest if you have the changelist numbers that you know you are going to change.
#changeListIDNumber is the desired changelist to edit
import P4
p4 = P4.connect()
cl = p4.fetch_changelist(changeListIDNumber)
cl['Description'] = 'your description here'
p4.save_change(cl)
If you are using this for your default changelist, and you do not pre populate your description with anything, you will get an error as there will be no 'Description' key in your changelist dictionary.
on shell this works, you may use in any language
echo "Change:new\nClient:myclient\nUser:me\nStatus:new\nDescription:test" | p4 change -i