Jump to content


p4python modify changelist description

p4python perforce

  • Please log in to reply
2 replies to this topic

#1 thunderbird

thunderbird

    Member

  • Members
  • PipPip
  • 16 posts

Posted 19 May 2015 - 05:54 AM

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

#2 thunderbird

thunderbird

    Member

  • Members
  • PipPip
  • 16 posts

Posted 19 May 2015 - 06:05 PM

I think using the p4 change command might help in this case, but the trigger process throws up "Access for user 'PERFORCE$' has not been enabled by 'p4 protect'." error.. The administrator user already has the super privilges set, not sure where the system is getting PERFORCE$ user from.

Any pointers?

change_cl_description = "p4 change -f -o %s | sed -e \"s|\[||g\" -e \"s|\]||g\"|p4 change -i" % (changeList)
os.system(change_cl_description)


Access for user 'PERFORCE$' has not been enabled by 'p4 protect'.


#3 thunderbird

thunderbird

    Member

  • Members
  • PipPip
  • 16 posts

Posted 19 May 2015 - 07:14 PM

Thanks, got it working by using p4.format_change and p4.save_change methods from the P4 classes..





Also tagged with one or more of these keywords: p4python, perforce

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users