2015-05-19 117 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)