Perforce有本地比较python函数返回布尔类型,而不是比较列表?

问题描述:

被质疑,我很惊讶,我无法在P4Python模块中找到任何原生diff函数,它返回的不是diff列表。 P4()。is_identical(branch1,branch2)不会有好处吗?Perforce有本地比较python函数返回布尔类型,而不是比较列表?

有谁知道是否有一种方法可以做到这一点?如果真的没有,有没有人有任何想法,如何解析差异列表,看看分支是完全相同的?

我使用p4 diff2 //depot/temp_dev/boost/branch1/... //depot/temp_dev/boost/branch2/...

日志是==== //depot/temp_dev/boost/branch1/bbversion.h#7 (text) - //depot/temp_dev/boost/branch2/bbversion.h#7 (text) ==== identical ==== //depot/temp_dev/boost/branch1/ClientSpec.txt#1 (text) - //depot/temp_dev/boost/branch2/ClientSpec.txt#1 (text) ==== identical

我使用的蟒方法是here

使用p4 diff2 -q -Od或Python的等效的命令。

-Od限制输出到不同的文件,并-q限制输出到只有头部,所以如果这两个路径是完全一致的,你会只得到某种“没有不同的文件”的消息,应该是便于检查对于。

+0

谢谢萨姆,这个按预期工作。 – ZDunker

山姆在我之前,但我找到了一种方法,以编程方式在Python中克服这一点。只是为了兴趣,如果有的话:

def is_identical(branch1, branch2): 
    command = ['p4', 'diff2', branch1, branch2] 
    diff_list = _call(command).rstrip().split('\n') 
    return False if False in map(lambda diff: ('identical' in diff), diff_list) else True 

与山姆的答案相比,这一点在机器时间里输了。