Skip to main content
 首页 » 编程设计

python之如何在不同步的情况下通过 p4python 读取 depot 的文件夹结构

2025年05月04日30lexus

我想读取 P4 depot 上指定文件夹路径内的文件夹和文件结构而不同步它。可能吗?

请您参考如下方法:

要获取指定仓库路径的子文件夹,应该使用此代码

p4.run("dirs", path+'*') 

结果将是一个单项字典列表

[{'dir': '//Depot/path/dirname1'}, {'dir': '//Depot/path/dirname2'}] 

为了获取指定仓库路径中包含的所有文件,应该使用:

p4.run("files", path+'*') 

结果将是一个字典列表,每个文件一个:

[{'rev': '1', 'time': '1465999632', 'action': 'add', 'type': 'text', 'depotFile': '//Depot/path/dirname1/filename.txt', 'change': '999999'}] 

另请注意,指定的路径必须以斜杠结尾/

感谢@SilentMonk @BryanPendleton 给我提示