I'm using P4 python version, and tried to get the difference of two files. However, it only returns filename and version.
l=p4.run("diff2","//a/b/c.h#42","//a/b/c.h#11")
print(l)
and the output is
[{'status': 'content', 'depotFile': '//a/b/c.h', 'rev': '42', 'type': 'text', 'depotFile2': '//a/b/c.h', 'rev2': '11', 'type2': 'text'}]
How to get which line is added, removed or modified?
The tagged version of p4 diff2
doesn't include the textual diff information, and P4Python enables tagged mode by default. Do:
p4.tagged = False
to disable tagged output.
import sys
from P4 import P4
p4 = P4()
p4.connect()
p4.tagged = False
for line in p4.run("diff2", sys.argv[1], sys.argv[2]):
print(line)
C:\Perforce\test>python diff2.py foo bar
==== //stream/main/foo#2 (text) - //stream/main/bar#2 (text) ==== content
1,2c1,2
< asdfasdf
< asdfasdf
---
> asdlfkjasdf
> sdflkj