Version control 来自执行p4客户机命令的管道的oot。 ################################################################################ 我的$WorkspaceRoot=“”; my$PrintClientCommand=“p4客户端-o”; $PrintClientCommand.=$Client; $PrintClientCommand.=“|”; 打开(PRINTCLIENTCOMMAND,$PRINTCLIENTCOMMAND); 而() { #保存“编辑”命令的工作区根目录,如下所示。 如果($\=~“根:”) { $WORKSPACEOOT=$\ux; #只需在Root之后解析内容: 如果($WorkspaceRoot=~/Root:\s*(.*)/) { $WorkspaceRoot=$1; } } } 关闭printclient命令; 除非长度($WorkspaceRoot)>0,否则为模具; #打印“工作空间根目录为:”$工作空间根; ################################################################################ #对于每个文件(newchangelistnumber.txt除外), #将该文件签出到新创建的变更列表中。 #注意:此代码假定文件已添加到Performance。 #增强:修复上述约束。 ################################################################################ 打印“签出此子目录中已在Performce中的所有文件…\n”; 我的$directory='; opendir(DIR,$directory)或die$!; while(my$file=readdir(DIR)) { #我们只想要文件 下一个除非(-f“$directory/$file”); #跳过文本文件。 下一个if($file=~m/\.txt$/); #跳过Perl文件。 下一个if($file=~m/\.pl$/); 我的$CheckOutFileCommand=“”; $CheckOutFileCommand=“p4-c”; $CheckOutFileCommand.=$Client; $CHECKOUFIELCOMMAND.=“编辑”; $CheckOutFileCommand.=“-c”。$NewChangeListNumber.”; $CHECKOUFIELCOMMAND.=$WORKSPACEOOT.\\”$file; $CHECKOUFIELCOMMAND.=“|”; 打开(CHECKOUTFILECOMMAND,$CHECKOUTFILECOMMAND); 而() { 打印美元; } 关闭checkoutfile命令; } closedir(DIR);

Version control 来自执行p4客户机命令的管道的oot。 ################################################################################ 我的$WorkspaceRoot=“”; my$PrintClientCommand=“p4客户端-o”; $PrintClientCommand.=$Client; $PrintClientCommand.=“|”; 打开(PRINTCLIENTCOMMAND,$PRINTCLIENTCOMMAND); 而() { #保存“编辑”命令的工作区根目录,如下所示。 如果($\=~“根:”) { $WORKSPACEOOT=$\ux; #只需在Root之后解析内容: 如果($WorkspaceRoot=~/Root:\s*(.*)/) { $WorkspaceRoot=$1; } } } 关闭printclient命令; 除非长度($WorkspaceRoot)>0,否则为模具; #打印“工作空间根目录为:”$工作空间根; ################################################################################ #对于每个文件(newchangelistnumber.txt除外), #将该文件签出到新创建的变更列表中。 #注意:此代码假定文件已添加到Performance。 #增强:修复上述约束。 ################################################################################ 打印“签出此子目录中已在Performce中的所有文件…\n”; 我的$directory='; opendir(DIR,$directory)或die$!; while(my$file=readdir(DIR)) { #我们只想要文件 下一个除非(-f“$directory/$file”); #跳过文本文件。 下一个if($file=~m/\.txt$/); #跳过Perl文件。 下一个if($file=~m/\.pl$/); 我的$CheckOutFileCommand=“”; $CheckOutFileCommand=“p4-c”; $CheckOutFileCommand.=$Client; $CHECKOUFIELCOMMAND.=“编辑”; $CheckOutFileCommand.=“-c”。$NewChangeListNumber.”; $CHECKOUFIELCOMMAND.=$WORKSPACEOOT.\\”$file; $CHECKOUFIELCOMMAND.=“|”; 打开(CHECKOUTFILECOMMAND,$CHECKOUTFILECOMMAND); 而() { 打印美元; } 关闭checkoutfile命令; } closedir(DIR);,version-control,perforce,changelist,Version Control,Perforce,Changelist,我今天遇到了这个问题,@Martin的回答非常有帮助。我想创建一个带有描述的变更列表,而不是将其留空,因此我使用他的命令作为起点,并将其调整为: export cl=`p4 change -o | sed 's/<enter description here>/"Change list description"/' | sed '/^#/d' | sed '/^$/d' | p4 change -i | cut -d ' ' -f 2` export cl=`p4 change-o

我今天遇到了这个问题,@Martin的回答非常有帮助。我想创建一个带有描述的变更列表,而不是将其留空,因此我使用他的命令作为起点,并将其调整为:

export cl=`p4 change -o | sed 's/<enter description here>/"Change list description"/' | sed '/^#/d' | sed '/^$/d' | p4 change -i | cut -d ' ' -f 2`
export cl=`p4 change-o|sed's//“变更列表说明”/'|sed'/^#/d'| sed'/^$/d'| p4 change-i | cut-d'-f 2`

以下是Maya(MEL)的一个实现:

proc字符串jp_newChangeList()
{
//这将以字符串形式返回文件格式
字符串$changelist=`system(“p4 change-o | | p4 change-i”)`;
//把绳子一行一行地分开
字符串$breakChange[];标记化$changelist“\n”$breakChange;
//找到名为“在此处输入描述”的行,并用文本编辑它(文本前面有4个空格以保留格式!!!)
整数$count=0;
int$mine=0;
对于($lii,单位为$breakChange)
{
$lii=`strip$lii`;
如果($lii==“”)$mine=$count;
$count++;
}
$breakChange[$mine]=“用户在此处输入描述文本”;
//获取一个本地虚拟文件位置并将其命名为“p4.txt”。我们将使用它生成一个变更列表
$exampleFileName=(`internalVar-userTmpDir`+“p4.txt”);
$fileId=`fopen$exampleFileName“w”`;
int$printCount=0;
//打印字符串数组,一次打印一行,直到您传递描述字符串(未指定“文件”部分)

虽然($printCount这里有一个在Windows cmd shell中工作的单行程序,它只使用p4命令行和Windows标准findstr实用程序,不需要任何临时文件

(p4 change -o | findstr /v "enter description here" & echo ○My new changelist)|p4 change -i
这将:

  • 生成变更列表规范(“p4变更-o”)
  • 删除“在此处输入说明”行(“findstr-v”)
  • 附加您的新描述(“echo”)
  • 最后创建新的变更列表(“p4变更-i”)

请注意,描述必须以制表符开头,这是一个很小的“○" guy。如果格式在发送到shell的过程中中断,您可以使用Alt-9键入制表符。

我正在寻找脚本中使用的命令行实现。
p4 change-o
p4 change-I
将是避免使用编辑器所必需的,这稍微简单一点:p4 change-o | findstr/v“在此处输入说明“| p4更改-在*NIX,bash v4.1中,它对我非常有用。我注意到,末尾有一个尾随空格,我不知道它来自何处…”更改列表描述'我已经尝试使用一个干净的默认变更列表,效果非常好,但如果列表中已经有任何文件,则会出现下一个错误。变更规范中有错误。无法包含文件尚未打开。请使用p4 add、p4 edit等打开新文件。有什么建议吗?最新的命令行界面似乎支持一个新的
--field
选项,该选项在此处很有用。您可能可以使用该选项将说明设置为文本,将文件列表设置为空,然后使用
p4 reopen
将文件移动到新的文件中变更列表。更多信息:
p4 submit
v followed by PgDown until you're done selecting all the files
:g!/.*pattern1.*#/d
:g!/.*pattern1.*#\|.*pattern2.*#\|.*pattern3.*#/d etc...
p4 change -o 
    | findstr /C:Description: /C:Change: /C:Client: /C:User: /C:Status: 
    | p4 change -i
p4 edit -c 1500 //depot/base/...files.c
p4 change -i < tempfile.txt
$newCLFormat = p4 change -o | select-string -pattern change, client, status
$newCLFormat += "Description: " + $myDescription
$newCLFormat | p4 change -i
$newCLFormat | p4 change -i | select-string "\b(\d)+" | %{$_.matches[0].value}
$newCLFormat | p4 change -i | %{ $_.split()[1] }
export cl=`p4 change -o | grep '^\(Change\|Client\|User\|Description\)' | p4 change -i | cut -d ' ' -f 2`
Here is my rough first pass at a Perl wrapper around p4 commands.
It would be most useful if you had a LOT of files to check in.
The form editor is NOT invoked.

#
# p4checkoutfiles.pl -
#
#       Will check out all files in current directory.
#       Print newly-created changelist number to display, for p4submitfiles.pl.
#       Optional command line parameter for Description, e.g. "Modifications from 07/25/2011".
#
#     USAGE:
#         1. Copy this script to a new folder.
#         2. Copy all files to be checked in to this same folder.
#         3. Run this script to check out all the files, as follows:
#
#               p4checkoutfiles.pl  <clientspec> <changelist_description>
#
#           For example:
#
#               p4checkoutfiles.pl ClientSpec-Mike "Modifications from 07/25/2011".
#
#
#         4. Manually copy these files over their older versions, in the correct workspace directory.
#         5. Run p4checkinfiles.pl.
#
# 

use strict;
use warnings;

################################################################################
# Save any command line parameters in local variables.
################################################################################

my $Client = shift;
die unless $Client;

my $ChangelistDescription = shift;


################################################################################
# Read default p4 form from pipe that executes p4 change command.
################################################################################

my $DefaultChangelistForm = "";

my $PrintDefaultChangelistCommand = "p4 change -o |";

open (PRINTDEFAULTCHANGELISTCOMMAND, $PrintDefaultChangelistCommand);

while (<PRINTDEFAULTCHANGELISTCOMMAND>)
{
    if (($_ !~ "Client") &&
        ($_ !~ "User") &&
        ($_ !~ "Status"))
    {
        $DefaultChangelistForm .= $_;
    }
}

# print "\$DefaultChangelistForm is: " . $DefaultChangelistForm; 

close PRINTDEFAULTCHANGELISTCOMMAND;



################################################################################
# Swap in any command line parameter for Description
################################################################################

if ($ChangelistDescription)
{
    $DefaultChangelistForm =~ s/<enter description here>/$ChangelistDescription/
}


################################################################################
# Write modified form values to disk, to be read by following p4 change -i.
################################################################################

open (FORMFORNEWCHANGELIST, ">formfornewchangelist.txt");
print FORMFORNEWCHANGELIST $DefaultChangelistForm;
close (FORMFORNEWCHANGELIST);



################################################################################
# Create new changelist using FORMFORNEWCHANGELIST.
# Read new changelist number from pipe that creates new changelist.
################################################################################

print "Creating new changelist...\n";

my $NewChangeList = "";
my $NewChangeListNumber = "";

my $CreateNewChangeListCommand = "";

$CreateNewChangeListCommand = "p4 -c ";
$CreateNewChangeListCommand .= $Client;
$CreateNewChangeListCommand .= " change -i < formfornewchangelist.txt |";

open (CREATENEWCHANGELISTCOMMAND, $CreateNewChangeListCommand);

while (<CREATENEWCHANGELISTCOMMAND>)
{
    if ($_ =~ "created")
    {
        # Save new change list number for below.
        $NewChangeListNumber = $_;
        print $_;
    }
}

close CREATENEWCHANGELISTCOMMAND;

################################################################################
# Save new changelist number to disk file newchangelistnumber.txt.
################################################################################

# Just parse numbers from string.
if ($NewChangeListNumber =~ /(\d+)/)
{
    $NewChangeListNumber = $1;
}


open (NEWCHANGELISTNUMBER, ">newchangelistnumber.txt");
print NEWCHANGELISTNUMBER $NewChangeListNumber;
close (NEWCHANGELISTNUMBER);


################################################################################
# Read workspace root from pipe that executes p4 client command.
################################################################################

my $WorkspaceRoot = "";

my $PrintClientCommand = "p4 client -o ";
$PrintClientCommand .= $Client;
$PrintClientCommand .= " |";

open (PRINTCLIENTCOMMAND, $PrintClientCommand);

while (<PRINTCLIENTCOMMAND>)
{
    # Save workspace root for edit command, below.
    if ($_ =~ "Root:")
    {
        $WorkspaceRoot = $_;

        # Just parse stuff after Root:
        if ($WorkspaceRoot =~ /Root:\s*(.*)/)
        {
            $WorkspaceRoot = $1;
        }
    }
}
close PRINTCLIENTCOMMAND;

die unless length($WorkspaceRoot) > 0;
# print "WorkspaceRoot is: " . $WorkspaceRoot;


################################################################################
# For each file (other than newchangelistnumber.txt),
# check out that file into newly-created changelist.
# NOTE: THIS CODE ASSUMES THE FILES HAVE ALREADY BEEN ADDED TO PERFORCE.
# Enhancement: Fix above constraint.
################################################################################

print "Checking out all files in this subdirectory already in Perforce...\n";

my $directory = '.';
opendir (DIR, $directory) or die $!;
while (my $file = readdir(DIR))
{
    # We only want files
        next unless (-f "$directory/$file");

    # Skip text files.
    next if ($file =~ m/\.txt$/);

    # Skip Perl files.
        next if ($file =~ m/\.pl$/);

    my $CheckOutFileCommand = "";

    $CheckOutFileCommand = "p4 -c ";
    $CheckOutFileCommand .= $Client;
    $CheckOutFileCommand .= " edit ";
    $CheckOutFileCommand .= " -c " . $NewChangeListNumber . " ";
    $CheckOutFileCommand .= $WorkspaceRoot . "\\" . $file;
    $CheckOutFileCommand .= " | ";

    open (CHECKOUTFILECOMMAND, $CheckOutFileCommand);

    while (<CHECKOUTFILECOMMAND>)
    {
        print $_;
    }

    close CHECKOUTFILECOMMAND;

}

closedir(DIR);
export cl=`p4 change -o | sed 's/<enter description here>/"Change list description"/' | sed '/^#/d' | sed '/^$/d' | p4 change -i | cut -d ' ' -f 2`
proc string jp_newChangeList()
{
    //This will return the file format as a string
    string $changelist = `system("p4 change -o || p4 change -i")`;
    //Break up the string by line
    string $breakChange[]; tokenize $changelist "\n" $breakChange;
    //Find the line called "enter description here" and edit it with your text (precede text with 4 SPACES to preserve format!!!)
    int $count = 0;
    int $mine = 0;
    for($lii in $breakChange)
    {
        $lii = `strip $lii`;
        if($lii == "<enter description here>") $mine = $count;
        $count++;
    }
    $breakChange[$mine] = "    User enters text for description here";
    //get a local dummy file location and call it "p4.txt". We will use this to generate a changelist
    $exampleFileName = ( `internalVar -userTmpDir` + "p4.txt" );
    $fileId=`fopen $exampleFileName "w"`;
    int $printCount = 0;
    //Print string array, one line at a time, until you pass the description string (leaving the "files" part unspecified)
    while($printCount <= $mine)
    {
        fprint $fileId ($breakChange[$printCount] + "\n");
        $printCount++;
    }
    //close the text file
    fclose $fileId;
    //Read the text file to return the changelist number 
    string $changelist = `system("p4 change -i < " + $exampleFileName)`;
    //Parse return statement to isolate changelist number
    string $changeNum[]; tokenize $changelist " " $changeNum;
    string $changeListNumber = $changeNum[1];
    return $changeListNumber;
}
(p4 change -o | findstr /v "enter description here" & echo ○My new changelist)|p4 change -i