8

...this... ...file.h ...theother... など、複数のファイル仕様を含む変更リストを送信したいのですが、Perforce では許可されません。ファイルから変更リストを作成することはできますが、ファイルを確認してコメントを入力する機会が必要です。これは、コマンドライン ソリューション用です。

4

9 に答える 9

15

UNIX/*NIX コマンド ライン ソリューションを探している場合、これにより新しいクリーンな変更リストが得られ、番号が に保持され$clます。

export cl=`p4 change -o | grep '^\(Change\|Client\|User\|Description\)' | p4 change -i | cut -d ' ' -f 2`
于 2010-07-02T09:03:25.960 に答える
10

これは際限なく苛立たしい問題です。次の手順を実行すると、エディターを呼び出さなくても、Windowsコマンドラインからp4チェンジリストを作成できるはずです。

p4 change -o 
    | findstr /C:Description: /C:Change: /C:Client: /C:User: /C:Status: 
    | p4 change -i

返される文字列は、「Change1500created」のようになります。チェンジリストを解析できます。次に、次のようにして個々のファイル仕様を追加できます。

p4 edit -c 1500 //depot/base/...files.c

またはそれらの線に沿った何か。このソリューションの比較的重要な問題は、説明を変更できないことです。または、必要な説明、変更、クライアントなどの文字列を使用して一時ファイルを作成し、次の方法で変更リストを作成することもできます。

p4 change -i < tempfile.txt

これはやや鈍いように見えますが、スクリプトソリューションの最良の代替手段となる可能性があります。

于 2009-12-21T23:31:36.233 に答える
5

Michael Gilbert の回答に基づいて、次のように powershell で説明を編集できます。

$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}

今、その数を引き出すためのより迅速できちんとした方法が必要ですか?

編集: findstr を select-string にリファクタリング

編集:変更リストを取得するためのより良い方法:

$newCLFormat | p4 change -i | %{ $_.split()[1] }
于 2010-06-30T08:01:05.920 に答える
4

保留中の変更リストを作成し、送信する前に必要なすべてのファイルをそこに移動できます。コマンドラインからでも、この機能には p4V の方が使いやすいと思います。

http://www.perforce.com/perforce/doc.current/manuals/cmdref/change.html#1040665

p4 change

保留中の変更リストを作成します。

p4 reopen 

ファイルを保留中の変更リストに移動します。

于 2009-10-15T06:59:08.287 に答える
4

これは、Windows コマンド シェルで p4 コマンド ラインと Windows 標準の findstr ユーティリティだけで動作し、一時ファイルを必要としないワンライナーです。

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

この意志:

  • チェンジリストの仕様を生成する ("p4 change -o")
  • 「ここに説明を入力してください」行を削除します (「findstr -v」)
  • 新しい説明を追加します ("echo")
  • 最後に、新しいチェンジリストを作成します ("p4 change -i")

説明はタブ文字で始まる必要があることに注意してください。これは小さな「○」の男です。シェルへの途中でフォーマットが壊れた場合は、Alt-9 でタブ文字を入力できます。

于 2015-02-05T23:40:00.137 に答える
4

今日この質問に出くわしました.@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`
于 2013-02-15T21:52:31.010 に答える
1
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);
于 2011-07-26T01:27:04.143 に答える
0

Maya (MEL) の実装は次のとおりです。

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;
}
于 2014-05-20T18:44:27.157 に答える
0

タイプ

p4 submit

P4EDITOR が vim の場合、vim 編集ウィンドウが表示されます。コマンドモードに移動し、「Files:」と入力して行の後のすべての行を選択します。

v followed by PgDown until you're done selecting all the files

それからする

:g!/.*pattern1.*#/d

このようなパターンが複数ある場合は、

:g!/.*pattern1.*#\|.*pattern2.*#\|.*pattern3.*#/d etc...

お役に立てれば!

于 2009-10-15T10:00:13.560 に答える