p4 -G
marshal
以未腌制的 ed 形式输出其数据。
但是您是对的-p4 -G diff -duw3
也不会取消marshal
,所以我想那里有问题。
p4 -G opened
虽然解组很好。然而,任何一种diff
失败。
这是一篇相关的知识库文章: http: //kb.perforce.com/ToolsScripts/PerforceUtilities/UsingP4G
#!/usr/bin/env python
import marshal
import subprocess
# proc = subprocess.Popen(["p4","-G","diff","-duw3","configure.ac","Makefile.am"],stdout=subprocess.PIPE)
proc = subprocess.Popen(["p4","-G","diff"],stdout=subprocess.PIPE)
# proc = subprocess.Popen(["p4","-G","opened"],stdout=subprocess.PIPE)
pipe = proc.stdout
output = []
try:
while 1:
record = marshal.load(pipe)
output.append(record)
except EOFError:
pass
pipe.close()
proc.wait()
# print list of dictionary records
c = 0
for dict in output:
c = c + 1
print "\n--%d--" % c
for key in dict.keys():
print "%s: %s" % ( key, dict[key] )