如何在 Perforce 中快速查找/删除所有空变更列表?

发布于 2024-08-08 04:01:17 字数 230 浏览 8 评论 0原文

我想知道尝试删除已提交的更改列表有什么意义,因为已提交的更改列表不应该为空。

但后来我正在使用教程库,并在整个分支上使用 obliterate 命令,我可以看到在某些情况下您可能会得到空的已提交变更列表(需要使用 -f 标志删除)。

但是,我不知道如何使用命令行找到它们,因为我不知道如何查找没有关联文件的更改列表。

有没有简单的方法可以做到这一点?

谢谢,

托马斯

I was wondering what could be the point in trying to delete committed changelists, because a committed changelist is not supposed to be empty.

But then I am playing with the tutorial depot, and using the obliterate command on a whole branch, I can see there are situation where you can end up with empty committed changelists (that need deletion with the -f flag).

However, I don't know how to find them with the command line, as I don't know how to look for changelists with no files associated with.

Is there an easy way to do that ?

Thanks,

Thomas

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

不…忘初心 2024-08-15 04:01:17

啊!

在问这个问题之前我应该​​浏览更多文档...

http://public.perforce.com/wiki/Perforce_Command_Line_Recipes

描述:删除所有空的已提交变更列表。
shell命令:p4更改-s提交|切-d“”-f 2 | xargs -n1 p4 更改 -d -f
Powershell:p4 更改 -s 已提交 | %{p4 更改 -d -f $_.split()[1]}
px: px -F %change% 更改 -s 已提交 | px -X- 更改 -d -f
贡献者:Sam Stafford、Philip Kania、Shawn Hladky

Duh。

托马斯

Ah !

I should have browse more documentation before asking this...

http://public.perforce.com/wiki/Perforce_Command_Line_Recipes

Description: Delete all empty submitted changelists.
Shell command: p4 changes -s submitted | cut -d " " -f 2 | xargs -n1 p4 change -d -f
Powershell: p4 changes -s submitted | %{p4 change -d -f $_.split()[1]}
px: px -F %change% changes -s submitted | px -X- change -d -f
Contributors: Sam Stafford, Philip Kania, Shawn Hladky

Duh.

Thomas

甜是你 2024-08-15 04:01:17

要简单地查找所有空的已提交变更列表而不删除它们,您可以比较这两个命令的输出:

  • p4changes -s Submitted - allchangelists
  • p4changes-s已提交 //... - 具有关联文件的所有更改列表

例如,在 Windows PowerShell 中,运行

diff -ReferenceObject (p4 changes -s submitted) -DifferenceObject (p4 changes -s submitted //...)

To simply find all empty submitted changelists without deleting them, you can compare the output of these two commands:

  • p4 changes -s submitted - all changelists
  • p4 changes -s submitted //... - all changelists with associated files

In Windows PowerShell, for example, run

diff -ReferenceObject (p4 changes -s submitted) -DifferenceObject (p4 changes -s submitted //...)
情深已缘浅 2024-08-15 04:01:17

由于我在 Windows 上,我创建了一个小脚本,在 PERL 中执行完全相同的操作,而不是 Shell、powershell 或 px :) :

#*******************************************************************************
# Module:  delete_empty_changelist.pl
# Purpose: A script to delete empty changelist
# 

@list = `p4 changes -s submitted`;

foreach $chg (@list)
{
 $chgnbr = (split /\s+/, $chg)[1];
 print `p4 change -d -f $chgnbr`;
 }     
exit 0;

请注意,事实上,在所有情况下,它都不是一个非常聪明的脚本:它尝试删除绝对是每个提交的变更列表,并且强制阻止这样做,因为如果文件与其关联,您将收到错误。

我想脚本的结果应该发送到日志并进行解析,以便仅突出显示相关行。

运行该脚本将产生类似于以下内容的输出:

Change 857 has 1 files associated with it and can't be deleted.
Change 856 has 1 fixes associated with it and can't be deleted.
Change 855 has 1 fixes associated with it and can't be deleted.
Change 854 deleted.
Change 853 has 1 fixes associated with it and can't be deleted.
Change 852 has 8 files associated with it and can't be deleted.
Change 851 has 1 files associated with it and can't be deleted.
Change 850 has 2 files associated with it and can't be deleted.
Change 849 has 2 files associated with it and can't be deleted.
Change 846 deleted.
Change 845 has 2 files associated with it and can't be deleted.

Cheers,

Thomas

As I am on Windows, I have created a little script doing the exact same thing in PERL, rather than Shell, powershell or px :) :

#*******************************************************************************
# Module:  delete_empty_changelist.pl
# Purpose: A script to delete empty changelist
# 

@list = `p4 changes -s submitted`;

foreach $chg (@list)
{
 $chgnbr = (split /\s+/, $chg)[1];
 print `p4 change -d -f $chgnbr`;
 }     
exit 0;

Note that in fact, in all cases, it's not a very clever script: It tries to delete absolutely every submitted changelist, and is prevented by perforce to do so, because if files are associated with it, you will get an error.

I suppose the result of the script should be sent to a log, and parse, so that only the relevant lines are highlighted.

Running the script will produce an output similar to:

Change 857 has 1 files associated with it and can't be deleted.
Change 856 has 1 fixes associated with it and can't be deleted.
Change 855 has 1 fixes associated with it and can't be deleted.
Change 854 deleted.
Change 853 has 1 fixes associated with it and can't be deleted.
Change 852 has 8 files associated with it and can't be deleted.
Change 851 has 1 files associated with it and can't be deleted.
Change 850 has 2 files associated with it and can't be deleted.
Change 849 has 2 files associated with it and can't be deleted.
Change 846 deleted.
Change 845 has 2 files associated with it and can't be deleted.

Cheers,

Thomas

决绝 2024-08-15 04:01:17

这是仅 DOS CMD 版本。只需替换%p4streamsUser%即可。

    for /f "tokens=* delims=" %%i in ('p4 changes -u %p4streamsUser% -s pending') do (
        for /f "tokens=1-7*" %%a in ("%%i") do (
            echo Deleting CL %%b %%h %%f
            p4 change -d -f %%b
        )
    )

我使用的是 Windows 7 机器。这将适用于其他几个版本的 Windows/DOS。

Here is a DOS CMD only version. Just replace %p4streamsUser%.

    for /f "tokens=* delims=" %%i in ('p4 changes -u %p4streamsUser% -s pending') do (
        for /f "tokens=1-7*" %%a in ("%%i") do (
            echo Deleting CL %%b %%h %%f
            p4 change -d -f %%b
        )
    )

I'm on a Windows 7 machine. This will work on several other versions of windows/DOS.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文