Jump to content

Do anybody know how to write PHP script for connecting Perforce?


reksss

Recommended Posts

Hello....

If i run this program i got the below error msg.

 

Run -> edit successfully

[P4.run()] Errors during command execution( "p4 submit -r" )

 

        [Error]: No files to submit from the default changelist.

 

 

Error: No files to submit from the default changelist.

 

 

<?php

$p4 = new P4();
$input_file = "//Consumer/WSE/Dev/SSO-1.0/SSO/QA/edit.txt";

//***********  Connect to Perforce  *************************************
$p4->port = "tw-p4proxy.tw.trendnet.org:1667";
$p4->user = "***";
$p4->client = "WSE_QA_tw-rekha";
$template = "WSE_QA_tw-rekha";
$client_root = "C:/Users/rekha_sokiyan/WSE_QA_tw-rekha";
$client_name = "WSE_QA_tw-rekha";
$p4->connect();
$p4->run_login('******' );


try {

          //***************  SYNC  ********************************************
          $p4->exception_level = 1;
                // Convert client spec into an array
                $client = $p4->fetch_client("-t", $template);
                $client['Root'] = $client_root;
                //print_r($client);
                $p4->save_client($client);
                // File(s) up-to-date is a warning; no exception raised
                if($p4->run_sync($input_file))
                   echo "\nRun -> sync successfully\n";

                //****************  EDIT  ********************************************
                if($p4->run("edit",$input_file))
                   echo "\nRun -> edit successfully\n";
                $p4->client;


                //***************  SUBMIT  *******************************************
                $change = $p4->fetch_change();
                // Files were opened elsewhere and we want to submit a subset that we already know about.
                $myfiles = array(
                                        '//Consumer/WSE/Dev/SSO-1.0/SSO/QA/edit.txt',
                                        '//Consumer/WSE/Dev/SSO-1.0/SSO/QA/test.txt'
                );


                $change['Files'] = $myfiles;
                $p4->input = $change;
                $p4->change = $change;
                $change['Description'] = "My changelist\nSubmitted from P4PHP\n";
                //print_r($change);
                $p4->run_submit("-r",$change);

                $spec = $p4->fetch_change();
                $spec["Description"] = "My changelist\nSubmitted from P4PHP\n";
                //$p4->run_submit($spec);

                //print_r($spec);

                //if($p4->run_submit("-i",$change))
                //   echo "\nRun -> Submitted from P4PHP\n";


//****************  EDIT  ********************************************
                if($p4->run("edit",$input_file))
                   echo "\nRun -> edit successfully\n";
                $p4->client;


                //***************  SUBMIT  *******************************************
                $change = $p4->fetch_change();
                // Files were opened elsewhere and we want to submit a subset that we already know about.
                $myfiles = array(
                                        '//Consumer/WSE/Dev/SSO-1.0/SSO/QA/edit.txt',
                                        '//Consumer/WSE/Dev/SSO-1.0/SSO/QA/test.txt'
                );


                $change['Files'] = $myfiles;
                $p4->input = $change;
                $p4->change = $change;
                $change['Description'] = "My changelist\nSubmitted from P4PHP\n";
                //print_r($change);
                $p4->run_submit("-r",$change);


}catch (P4_Exception $e) {
         print $e->getMessage() . "\n";
         foreach ($p4->errors as $error) {
         print "Error: $error\n";
        }
}
?>                                                                              
[code]

Do anybody help me to fix it?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.