You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
2.3 KiB
PHTML

<?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* Contributor: Matt Whittom <Matt.Whittom@veteransunited.com>
* Date: 7/17/13
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer\Downloader;
use Composer\Package\PackageInterface;
11 years ago
use Composer\Repository\VcsRepository;
use Composer\Util\Perforce;
/**
* @author Matt Whittom <Matt.Whittom@veteransunited.com>
*/
class PerforceDownloader extends VcsDownloader
{
11 years ago
protected $perforce;
protected $perforceInjected = false;
11 years ago
/**
* {@inheritDoc}
*/
public function doDownload(PackageInterface $package, $path)
{
$ref = $package->getSourceReference();
$label = $package->getPrettyVersion();
$this->io->write(" Cloning ".$ref);
11 years ago
$this->initPerforce($package, $path);
$this->perforce->setStream($ref);
$this->perforce->queryP4User($this->io);
$this->perforce->writeP4ClientSpec();
$this->perforce->connectClient();
$this->perforce->syncCodeBase($label);
$this->perforce->cleanupClientSpec();
11 years ago
}
11 years ago
private function initPerforce($package, $path){
if ($this->perforceInjected){
11 years ago
return;
}
11 years ago
$repository = $package->getRepository();
11 years ago
$repoConfig = $repository->getRepoConfig();
$this->perforce = Perforce::createPerforce($repoConfig, $package->getSourceUrl(), $path);
11 years ago
}
/**
* {@inheritDoc}
*/
public function doUpdate(PackageInterface $initial, PackageInterface $target, $path)
{
$this->doDownload($target, $path);
}
/**
* {@inheritDoc}
*/
public function getLocalChanges(PackageInterface $package, $path)
{
print ("Perforce driver does not check for local changes before overriding\n");
return;
}
/**
* {@inheritDoc}
*/
protected function getCommitLogs($fromReference, $toReference, $path)
{
$commitLogs = $this->perforce->getCommitLogs($fromReference, $toReference);
return $commitLogs;
}
11 years ago
public function injectPerforce($perforce){
$this->perforce = $perforce;
$this->perforceInjected = true;
}
}