2015-05-19 58 views
2

此p4python代码的片段获取perforce描述并删除说明中提及的方括号。我打算在更改提交触发器期间调用此脚本以在提交更改之前替换CL描述。不知道什么是错的,但触发器不采取我的新变化描述..有没有人尝试使用p4python这样做?任何提示的高度赞赏p4python修改更改列表说明

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

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

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

首先描述打印

[{'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'}] 

首先说明打印

[ABC-789] testfile commit 

其次说明删除的方括号

ABC-789 testfile commit 

回答

1

是“变化-COM mit触发'一个错字?在更改完全提交后,更改提交触发器被称为,并且无法对其进行任何修改。

如果您想在提交过程中更改更改列表,您需要使用更改提交或更改内容触发器。

+0

感谢修正布莱恩..你SRE的权利..我的意思更改内容 – thunderbird

+0

你应该能够改变更改提交触发器期间的更改列表描述。但仅仅在Python程序中改变'description'变量是不够的,而且它不足以将更新后的描述打印到stdout。您需要运行“更改-i”命令,并将修改规范修改为包含修订后的更改列表描述(但更改列表规范的其余部分未更改)。 –

1

既然你在平均变化提交/内容触发,这是我做的:

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

# Make changes to description 

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