thunderbird
thunderbird

Reputation: 121

p4python modify changelist description

The snippet of this p4python code gets the perforce description and removes the square brackets mentioned in the description. I am planning to make this script called during the change-commit trigger to replace the CL description before even submitting the change. Not sure what's wrong, but the trigger doesnt take my new change description.. Has anyone tried doing this using the p4python? Any hints highly appreciated

describe = p4.run('describe', changeList)
print describe

description = describe[0].get('desc')
print description

description = description.replace('[', '')
description = description.replace(']', '')
print description

First describe prints

[{'status': 'pending', 'changeType': 'public', 'rev': ['21'], 'client': 'workspace1', 'user': 'username', 'time': '1432010818', 'action': ['edit'], 'type': ['text'], 'depotFile': ['//depot/repo/Vagrantfile'], 'change': '12345', 'desc': '[ABC-789] testfile commit'}]

First description prints

[ABC-789] testfile commit

Second description removes the square brackets

ABC-789 testfile commit

Upvotes: 2

Views: 2134

Answers (2)

Scott Jenkins
Scott Jenkins

Reputation: 21

Since you mean during change-submit/content trigger, here's what I do:

details = p4.fetch_change(changelistNumber)
description = details['Description']

# Make changes to description

details[descriptionKey] = description
p4.save_change(details)

Upvotes: 1

Bryan Pendleton
Bryan Pendleton

Reputation: 16339

Is 'change-commit trigger' a typo? The change-commit trigger is called after the change is completely submitted, and can't make any modifications to it.

If you want to alter the changelist during the submit process, you need to use a change-submit or change-content trigger.

Upvotes: 1

Related Questions