给定一个父流,我可以使用下面的命令找到它的直接子流:
p4 streams -F "Parent=<parent_stream_path>"
但是,有没有一种方法可以递归列出给定父流的所有子流?
发布于 2016-07-09 13:22:23
为什么不用首选语言编写一个脚本来实现这一点呢?
从父级开始。初始化一个以父元素为唯一元素的队列。使用p4 streams
获取子流列表。将它们存储在队列中,并将第一个节点(父节点)附加到不同的列表中。将每个子节点作为父节点重复此过程。基本上,是一个以父节点为根节点的Breadth First Search。
发布于 2017-05-18 15:52:26
我已经编写了一个小的perl函数来获取孩子列表。如下所示:
sub getChildrenList {
my $child = shift;
$child =~ s/^\s+|\s+$//g;
my $get_children_cmd="p4 streams -F \"Parent=<parent_stream_path>\"";
my @children= `$get_children_cmd`;
if (@children != 0){
foreach my $child_name (@children){
getChildrenList($child_name);
}
}
push(@children_list,$child);
}
https://stackoverflow.com/questions/38212218
复制