如何检测更改列表是否删除了经典 Perforce 仓库中的分支

How to detect if a changelist deletes a branch in a classic Perforce depot

我有一个经典的 Perforce depot。给出的是一个目录列表,其中每个目录代表一个分支。有什么方法可以检测给定的更改列表是否删除了分支中的 所有 文件(因此删除了整个分支)?

例如:

//depot/branch1
//depot/branch2

我试过:p4 sync -n //depot/branch1/...@<CHANGELIST> 同步整个分支。 -n 是模拟或预览同步。但是返回的输出对我没有帮助。还有其他方法可以检测到吗?

C:\Perforce\test>p4 help files

    files -- List files in the depot

    p4 files [ -a ] [ -A ] [ -e ] [-i] [ -m max ] file[revRange] ...

        ...

        The -e flag displays files with an action of anything other than
        deleted, purged or archived.  Typically this revision is always
        available to sync or integrate from.

C:\Perforce\test>p4 files dir/...
//stream/main/dir/bar#2 - delete change 119 (text)
//stream/main/dir/foo#2 - delete change 119 (text)

C:\Perforce\test>p4 files -e dir/...
dir/... - no such file(s).

也一样:

p4 files -e //depot/branch1/...

如果显示 no such file(s) 则该目录中的所有内容都已删除。

如果要检查某个提交的变更列表的状态,只需将变更列表添加为修订说明符即可:

C:\Perforce\test>p4 files -e dir/...@119
dir/...@119 - no such file(s).

C:\Perforce\test>p4 files -e dir/...@118
//stream/main/dir/bar#1 - add change 106 (text)
//stream/main/dir/foo#1 - add change 106 (text)

在这个例子中,我们可以看出更改 @119 具体是删除目录的那个,因为在那个更改列表文件不存在,但在前一个文件中它们存在。


这在流库中的工作方式相同:

C:\Perforce\test>p4 switch foo

C:\Perforce\test>p4 files ...
//stream/foo/dir/bar#2 - delete change 131 (text)
//stream/foo/dir/foo#2 - delete change 131 (text)

C:\Perforce\test>p4 files -e ...
... - no such file(s).