p4python: get diff2 form depot

拜拜、爱过 提交于 2020-01-04 03:15:32

问题


I want to retrieve output of the next command (where p4 is standard perforce client):

p4 diff2 //depot/...#1 //depot/...#2

In terminal it is producing something like this:

==== //depot/bin/build.sh#1 (xtext) - //depot/bin/build.sh#2 (xtext) ==== content
1a2
> #added something 2
9c10
< fi---
> fi
==== //depot/bin/README#1 - <none> ===
==== //depot/bin/status_ok#1 - <none> ===

Let's assume that I have next script in python:

from P4 import P4
p4 = P4()
p4.port = "1818"
p4.host = "localhost"
p4.user = "psih"
p4.client = "build_verificator_ws2"
p4.connect()
changes = p4.run_diff2("//depot/...#1", "//depot/...#2")
print changes
p4.disconnect()

After execution python script I will receive something like that:

[{'status': 'content', 'depotFile2': '//depot/bin/build.sh', 'rev': '1', 'rev2': '2', 'type': 'xtext', 'depotFile': '//depot/bin/build.sh', 'type2': 'xtext'}, {'status': 'left only', 'type': 'text', 'rev': '1', 'depotFile': '//depot/bin/README'}, {'status': 'left only', 'type': 'text', 'rev': '1', 'depotFile': '//depot/bin/status_ok'}]

List of files in depot with revisions but no diffs.

Any suggestions?


回答1:


The answer is in using a non-tagged response:

changes = p4.run_diff2("//depot/...#1", "//depot/...#2", tagged=False)


来源:https://stackoverflow.com/questions/14663858/p4python-get-diff2-form-depot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!