【问题标题】:How do you quickly find/delete all empty changelists in Perforce?你如何在 Perforce 中快速找到/删除所有空的变更列表?
【发布时间】:2009-10-16 08:37:39
【问题描述】:

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

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

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

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

谢谢,

托马斯

【问题讨论】:

    标签: perforce administration changelist


    【解决方案1】:

    啊!

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

    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

    呃。

    托马斯

    【讨论】:

    • 我无法在我的 Windows PC 上使用建议的答案,所以我编写了一个小的 PERL 脚本来做同样的事情。 :-)
    【解决方案2】:

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

    • p4 changes -s submitted - 所有更改列表
    • p4 changes -s submitted //... - 带有关联文件的所有更改列表

    例如,在 Windows PowerShell 中,运行

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

    【讨论】:

      【解决方案3】:

      由于我在 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;
      

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

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

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

      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.
      

      干杯,

      托马斯

      【讨论】:

        【解决方案4】:

        这是一个仅 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。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2013-05-16
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多