Updated to complete functionality in Downloader to handle updates, returning change logs.
parent
1015957659
commit
7fdcdb4c54
|
@ -22,6 +22,7 @@ use Composer\Util\Perforce;
|
||||||
class PerforceDownloader extends VcsDownloader
|
class PerforceDownloader extends VcsDownloader
|
||||||
{
|
{
|
||||||
protected $perforce;
|
protected $perforce;
|
||||||
|
protected $perforceInjected = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
|
@ -31,6 +32,7 @@ class PerforceDownloader extends VcsDownloader
|
||||||
$ref = $package->getSourceReference();
|
$ref = $package->getSourceReference();
|
||||||
$label = $package->getPrettyVersion();
|
$label = $package->getPrettyVersion();
|
||||||
|
|
||||||
|
$this->io->write(" Cloning ".$ref);
|
||||||
$this->initPerforce($package, $path);
|
$this->initPerforce($package, $path);
|
||||||
$this->perforce->setStream($ref);
|
$this->perforce->setStream($ref);
|
||||||
$this->perforce->queryP4User($this->io);
|
$this->perforce->queryP4User($this->io);
|
||||||
|
@ -40,7 +42,7 @@ class PerforceDownloader extends VcsDownloader
|
||||||
}
|
}
|
||||||
|
|
||||||
private function initPerforce($package, $path){
|
private function initPerforce($package, $path){
|
||||||
if (isset($this->perforce)){
|
if ($this->perforceInjected){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$repository = $package->getRepository();
|
$repository = $package->getRepository();
|
||||||
|
@ -50,6 +52,7 @@ class PerforceDownloader extends VcsDownloader
|
||||||
|
|
||||||
public function injectPerforce($perforce){
|
public function injectPerforce($perforce){
|
||||||
$this->perforce = $perforce;
|
$this->perforce = $perforce;
|
||||||
|
$this->perforceInjected = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getRepoConfig(VcsRepository $repository){
|
private function getRepoConfig(VcsRepository $repository){
|
||||||
|
@ -62,7 +65,7 @@ class PerforceDownloader extends VcsDownloader
|
||||||
public function doUpdate(PackageInterface $initial, PackageInterface $target, $path)
|
public function doUpdate(PackageInterface $initial, PackageInterface $target, $path)
|
||||||
{
|
{
|
||||||
print("PerforceDownloader:doUpdate\n");
|
print("PerforceDownloader:doUpdate\n");
|
||||||
throw new Exception("Unsupported Operation: PerforceDownloader:doUpdate");
|
$this->doDownload($target, $path);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -70,8 +73,8 @@ class PerforceDownloader extends VcsDownloader
|
||||||
*/
|
*/
|
||||||
public function getLocalChanges($path)
|
public function getLocalChanges($path)
|
||||||
{
|
{
|
||||||
print("PerforceDownloader:getLocalChanges\n");
|
print ("Perforce driver does not check for local changes before overriding\n");
|
||||||
throw new Exception("Unsupported Operation: PerforceDownloader:getLocalChanges");
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -80,8 +83,8 @@ class PerforceDownloader extends VcsDownloader
|
||||||
*/
|
*/
|
||||||
protected function getCommitLogs($fromReference, $toReference, $path)
|
protected function getCommitLogs($fromReference, $toReference, $path)
|
||||||
{
|
{
|
||||||
print("PerforceDownloader:getCommitLogs\n");
|
$commitLogs = $this->perforce->getCommitLogs($fromReference, $toReference);
|
||||||
throw new Exception("Unsupported Operation: PerforceDownloader:getCommitLogs");
|
return $commitLogs;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -437,4 +437,35 @@ class Perforce {
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getChangeList($reference){
|
||||||
|
$index = strpos($reference, "@");
|
||||||
|
if ($index === false){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$label = substr($reference, $index);
|
||||||
|
$command = $this->generateP4Command(" changes -m1 $label");
|
||||||
|
$changes = $this->executeCommand($command);
|
||||||
|
if (strpos($changes, "Change") !== 0){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$fields = explode(" ", $changes);
|
||||||
|
$changeList = $fields[1];
|
||||||
|
return $changeList;
|
||||||
|
}
|
||||||
|
public function getCommitLogs($fromReference, $toReference){
|
||||||
|
$fromChangeList = $this->getChangeList($fromReference);
|
||||||
|
if ($fromChangeList == null){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$toChangeList = $this->getChangeList($toReference);
|
||||||
|
if ($toChangeList == null){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$index = strpos($fromReference, "@");
|
||||||
|
$main = substr($fromReference, 0, $index) . "/...";
|
||||||
|
$command = $this->generateP4Command("filelog $main@$fromChangeList,$toChangeList");
|
||||||
|
$result = $this->executeCommand($command);
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue