Merge pull request #7936 from naderman/solve-without-installed
Separate Install & Update code, no longer use vendor dir as input to solvermain
commit
8810c6467d
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Composer.
|
||||
*
|
||||
* (c) Nils Adermann <naderman@naderman.de>
|
||||
* Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Composer\DependencyResolver;
|
||||
|
||||
use Composer\DependencyResolver\Operation\MarkAliasUninstalledOperation;
|
||||
use Composer\DependencyResolver\Operation\UninstallOperation;
|
||||
use Composer\Package\AliasPackage;
|
||||
use Composer\Package\Link;
|
||||
use Composer\Package\PackageInterface;
|
||||
use Composer\Repository\PlatformRepository;
|
||||
use Composer\Repository\RepositoryInterface;
|
||||
use Composer\Semver\Constraint\Constraint;
|
||||
|
||||
/**
|
||||
* @author Nils Adermann <naderman@naderman.de>
|
||||
*/
|
||||
class LocalRepoTransaction extends Transaction
|
||||
{
|
||||
public function __construct(RepositoryInterface $lockedRepository, $localRepository)
|
||||
{
|
||||
parent::__construct(
|
||||
$localRepository->getPackages(),
|
||||
$lockedRepository->getPackages()
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Composer.
|
||||
*
|
||||
* (c) Nils Adermann <naderman@naderman.de>
|
||||
* Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Composer\DependencyResolver;
|
||||
|
||||
use Composer\DependencyResolver\Operation\OperationInterface;
|
||||
use Composer\Package\AliasPackage;
|
||||
use Composer\Package\RootAliasPackage;
|
||||
use Composer\Package\RootPackageInterface;
|
||||
use Composer\Repository\ArrayRepository;
|
||||
use Composer\Repository\RepositoryInterface;
|
||||
use Composer\Test\Repository\ArrayRepositoryTest;
|
||||
|
||||
/**
|
||||
* @author Nils Adermann <naderman@naderman.de>
|
||||
*/
|
||||
class LockTransaction extends Transaction
|
||||
{
|
||||
/**
|
||||
* packages in current lock file, platform repo or otherwise present
|
||||
* @var array
|
||||
*/
|
||||
protected $presentMap;
|
||||
|
||||
/**
|
||||
* Packages which cannot be mapped, platform repo, root package, other fixed repos
|
||||
* @var array
|
||||
*/
|
||||
protected $unlockableMap;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $resultPackages;
|
||||
|
||||
public function __construct(Pool $pool, $presentMap, $unlockableMap, $decisions)
|
||||
{
|
||||
$this->presentMap = $presentMap;
|
||||
$this->unlockableMap = $unlockableMap;
|
||||
|
||||
$this->setResultPackages($pool, $decisions);
|
||||
parent::__construct($this->presentMap, $this->resultPackages['all']);
|
||||
|
||||
}
|
||||
|
||||
// TODO make this a bit prettier instead of the two text indexes?
|
||||
public function setResultPackages(Pool $pool, Decisions $decisions)
|
||||
{
|
||||
$this->resultPackages = array('all' => array(), 'non-dev' => array(), 'dev' => array());
|
||||
foreach ($decisions as $i => $decision) {
|
||||
$literal = $decision[Decisions::DECISION_LITERAL];
|
||||
|
||||
if ($literal > 0) {
|
||||
$package = $pool->literalToPackage($literal);
|
||||
$this->resultPackages['all'][] = $package;
|
||||
if (!isset($this->unlockableMap[$package->id])) {
|
||||
$this->resultPackages['non-dev'][] = $package;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function setNonDevPackages(LockTransaction $extractionResult)
|
||||
{
|
||||
$packages = $extractionResult->getNewLockPackages(false);
|
||||
|
||||
$this->resultPackages['dev'] = $this->resultPackages['non-dev'];
|
||||
$this->resultPackages['non-dev'] = array();
|
||||
|
||||
foreach ($packages as $package) {
|
||||
foreach ($this->resultPackages['dev'] as $i => $resultPackage) {
|
||||
// TODO this comparison is probably insufficient, aliases, what about modified versions? I guess they aren't possible?
|
||||
if ($package->getName() == $resultPackage->getName()) {
|
||||
$this->resultPackages['non-dev'][] = $resultPackage;
|
||||
unset($this->resultPackages['dev'][$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO additionalFixedRepository needs to be looked at here as well?
|
||||
public function getNewLockPackages($devMode, $updateMirrors = false)
|
||||
{
|
||||
$packages = array();
|
||||
foreach ($this->resultPackages[$devMode ? 'dev' : 'non-dev'] as $package) {
|
||||
if (!($package instanceof AliasPackage) && !($package instanceof RootAliasPackage)) {
|
||||
// if we're just updating mirrors we need to reset references to the same as currently "present" packages' references to keep the lock file as-is
|
||||
// we do not reset references if the currently present package didn't have any, or if the type of VCS has changed
|
||||
if ($updateMirrors && !isset($this->presentMap[spl_object_hash($package)])) {
|
||||
foreach ($this->presentMap as $presentPackage) {
|
||||
if ($package->getName() == $presentPackage->getName() &&
|
||||
$package->getVersion() == $presentPackage->getVersion() &&
|
||||
$presentPackage->getSourceReference() &&
|
||||
$presentPackage->getSourceType() === $package->getSourceType()
|
||||
) {
|
||||
$package->setSourceDistReferences($presentPackage->getSourceReference());
|
||||
}
|
||||
}
|
||||
}
|
||||
$packages[] = $package;
|
||||
}
|
||||
}
|
||||
|
||||
return $packages;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,204 @@
|
||||
--TEST--
|
||||
Update mirrors updates URLs for all packages if they have changed without updating versions
|
||||
|
||||
a/a is dev and gets everything updated as it updates to a new ref
|
||||
b/b is a tag and gets everything updated by updating the package URL directly
|
||||
c/c is a tag and not whitelisted and gets the new URL but keeps its old ref
|
||||
d/d is dev but with a #ref so it should get URL updated but not the reference
|
||||
e/e is dev and newly installed with a #ref so it should get the correct URL but with the #111 ref
|
||||
e/e is dev but not whitelisted and gets the new URL but keeps its old ref
|
||||
g/g is dev and installed in a different ref than the #ref, so it gets updated and gets the new URL but not the new ref
|
||||
--COMPOSER--
|
||||
{
|
||||
"repositories": [
|
||||
{
|
||||
"type": "package",
|
||||
"package": [
|
||||
{
|
||||
"name": "a/a", "version": "dev-master",
|
||||
"source": { "reference": "2222222222222222222222222222222222222222", "url": "https://github.com/a/newa", "type": "git" },
|
||||
"dist": { "reference": "2222222222222222222222222222222222222222", "url": "https://api.github.com/repos/a/newa/zipball/2222222222222222222222222222222222222222", "type": "zip" }
|
||||
},
|
||||
{
|
||||
"name": "b/b", "version": "2.0.3",
|
||||
"source": { "reference": "2222222222222222222222222222222222222222", "url": "https://github.com/b/newb", "type": "git" },
|
||||
"dist": { "reference": "2222222222222222222222222222222222222222", "url": "https://api.github.com/repos/b/newb/zipball/2222222222222222222222222222222222222222", "type": "zip" }
|
||||
},
|
||||
{
|
||||
"name": "c/c", "version": "1.0.0",
|
||||
"source": { "reference": "2222222222222222222222222222222222222222", "url": "https://github.com/c/newc", "type": "git" },
|
||||
"dist": { "reference": "2222222222222222222222222222222222222222", "url": "https://api.github.com/repos/c/newc/zipball/2222222222222222222222222222222222222222", "type": "zip" }
|
||||
},
|
||||
{
|
||||
"name": "d/d", "version": "dev-master",
|
||||
"source": { "reference": "2222222222222222222222222222222222222222", "url": "https://github.com/d/newd", "type": "git" },
|
||||
"dist": { "reference": "2222222222222222222222222222222222222222", "url": "https://api.github.com/repos/d/newd/zipball/2222222222222222222222222222222222222222", "type": "zip" }
|
||||
},
|
||||
{
|
||||
"name": "e/e", "version": "dev-master",
|
||||
"source": { "reference": "2222222222222222222222222222222222222222", "url": "https://github.com/e/newe", "type": "git" },
|
||||
"dist": { "reference": "2222222222222222222222222222222222222222", "url": "https://api.github.com/repos/e/newe/zipball/2222222222222222222222222222222222222222", "type": "zip" }
|
||||
},
|
||||
{
|
||||
"name": "f/f", "version": "dev-master",
|
||||
"source": { "reference": "2222222222222222222222222222222222222222", "url": "https://github.com/f/newf", "type": "git" },
|
||||
"dist": { "reference": "2222222222222222222222222222222222222222", "url": "https://api.github.com/repos/f/newf/zipball/2222222222222222222222222222222222222222", "type": "zip" }
|
||||
},
|
||||
{
|
||||
"name": "g/g", "version": "dev-master",
|
||||
"source": { "reference": "2222222222222222222222222222222222222222", "url": "https://github.com/g/newg", "type": "git" },
|
||||
"dist": { "reference": "2222222222222222222222222222222222222222", "url": "https://api.github.com/repos/g/newg/zipball/2222222222222222222222222222222222222222", "type": "zip" }
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"a/a": "dev-master",
|
||||
"b/b": "2.0.3",
|
||||
"c/c": "1.0.0",
|
||||
"d/d": "dev-master#1111111111111111111111111111111111111111",
|
||||
"e/e": "dev-master#1111111111111111111111111111111111111111",
|
||||
"f/f": "dev-master",
|
||||
"g/g": "dev-master#1111111111111111111111111111111111111111"
|
||||
}
|
||||
}
|
||||
--INSTALLED--
|
||||
[
|
||||
{
|
||||
"name": "a/a", "version": "dev-master",
|
||||
"source": { "reference": "1111111111111111111111111111111111111111", "url": "https://github.com/a/a", "type": "git" },
|
||||
"dist": { "reference": "1111111111111111111111111111111111111111", "url": "https://api.github.com/repos/a/a/zipball/1111111111111111111111111111111111111111", "type": "zip" }
|
||||
},
|
||||
{
|
||||
"name": "b/b", "version": "2.0.3",
|
||||
"source": { "reference": "1111111111111111111111111111111111111111", "url": "https://github.com/b/b", "type": "git" },
|
||||
"dist": { "reference": "1111111111111111111111111111111111111111", "url": "https://api.github.com/repos/b/b/zipball/1111111111111111111111111111111111111111", "type": "zip" }
|
||||
},
|
||||
{
|
||||
"name": "c/c", "version": "1.0.0",
|
||||
"source": { "reference": "1111111111111111111111111111111111111111", "url": "https://github.com/c/c", "type": "git" },
|
||||
"dist": { "reference": "1111111111111111111111111111111111111111", "url": "https://api.github.com/repos/c/c/zipball/1111111111111111111111111111111111111111", "type": "zip" }
|
||||
},
|
||||
{
|
||||
"name": "d/d", "version": "dev-master",
|
||||
"source": { "reference": "1111111111111111111111111111111111111111", "url": "https://github.com/d/d", "type": "git" },
|
||||
"dist": { "reference": "1111111111111111111111111111111111111111", "url": "https://api.github.com/repos/d/d/zipball/1111111111111111111111111111111111111111", "type": "zip" }
|
||||
},
|
||||
{
|
||||
"name": "f/f", "version": "dev-master",
|
||||
"source": { "reference": "1111111111111111111111111111111111111111", "url": "https://github.com/f/f", "type": "git" },
|
||||
"dist": { "reference": "1111111111111111111111111111111111111111", "url": "https://api.github.com/repos/f/f/zipball/1111111111111111111111111111111111111111", "type": "zip" }
|
||||
},
|
||||
{
|
||||
"name": "g/g", "version": "dev-master",
|
||||
"source": { "reference": "0000000000000000000000000000000000000000", "url": "https://github.com/g/g", "type": "git" },
|
||||
"dist": { "reference": "0000000000000000000000000000000000000000", "url": "https://api.github.com/repos/g/g/zipball/0000000000000000000000000000000000000000", "type": "zip" }
|
||||
}
|
||||
]
|
||||
--LOCK--
|
||||
{
|
||||
"packages": [
|
||||
{
|
||||
"name": "a/a", "version": "dev-master",
|
||||
"source": { "reference": "1111111111111111111111111111111111111111", "url": "https://github.com/a/a", "type": "git" },
|
||||
"dist": { "reference": "1111111111111111111111111111111111111111", "url": "https://api.github.com/repos/a/a/zipball/1111111111111111111111111111111111111111", "type": "zip" },
|
||||
"type": "library"
|
||||
},
|
||||
{
|
||||
"name": "b/b", "version": "2.0.3",
|
||||
"source": { "reference": "1111111111111111111111111111111111111111", "url": "https://github.com/b/b", "type": "git" },
|
||||
"dist": { "reference": "1111111111111111111111111111111111111111", "url": "https://api.github.com/repos/b/b/zipball/1111111111111111111111111111111111111111", "type": "zip" },
|
||||
"type": "library"
|
||||
},
|
||||
{
|
||||
"name": "c/c", "version": "1.0.0",
|
||||
"source": { "reference": "1111111111111111111111111111111111111111", "url": "https://github.com/c/c", "type": "git" },
|
||||
"dist": { "reference": "1111111111111111111111111111111111111111", "url": "https://api.github.com/repos/c/c/zipball/1111111111111111111111111111111111111111", "type": "zip" },
|
||||
"type": "library"
|
||||
},
|
||||
{
|
||||
"name": "d/d", "version": "dev-master",
|
||||
"source": { "reference": "1111111111111111111111111111111111111111", "url": "https://github.com/d/d", "type": "git" },
|
||||
"dist": { "reference": "1111111111111111111111111111111111111111", "url": "https://api.github.com/repos/d/d/zipball/1111111111111111111111111111111111111111", "type": "zip" },
|
||||
"type": "library"
|
||||
},
|
||||
{
|
||||
"name": "f/f", "version": "dev-master",
|
||||
"source": { "reference": "1111111111111111111111111111111111111111", "url": "https://github.com/f/f", "type": "git" },
|
||||
"dist": { "reference": "1111111111111111111111111111111111111111", "url": "https://api.github.com/repos/f/f/zipball/1111111111111111111111111111111111111111", "type": "zip" },
|
||||
"type": "library"
|
||||
},
|
||||
{
|
||||
"name": "g/g", "version": "dev-master",
|
||||
"source": { "reference": "0000000000000000000000000000000000000000", "url": "https://github.com/g/g", "type": "git" },
|
||||
"dist": { "reference": "0000000000000000000000000000000000000000", "url": "https://api.github.com/repos/g/g/zipball/0000000000000000000000000000000000000000", "type": "zip" },
|
||||
"type": "library"
|
||||
}
|
||||
],
|
||||
"packages-dev": [],
|
||||
"aliases": [],
|
||||
"minimum-stability": "stable",
|
||||
"stability-flags": {},
|
||||
"prefer-stable": false,
|
||||
"prefer-lowest": false,
|
||||
"platform": [],
|
||||
"platform-dev": []
|
||||
}
|
||||
--EXPECT-LOCK--
|
||||
{
|
||||
"packages": [
|
||||
{
|
||||
"name": "a/a", "version": "dev-master",
|
||||
"source": { "reference": "1111111111111111111111111111111111111111", "url": "https://github.com/a/newa", "type": "git" },
|
||||
"dist": { "reference": "1111111111111111111111111111111111111111", "url": "https://api.github.com/repos/a/newa/zipball/1111111111111111111111111111111111111111", "type": "zip" },
|
||||
"type": "library"
|
||||
},
|
||||
{
|
||||
"name": "b/b", "version": "2.0.3",
|
||||
"source": { "reference": "1111111111111111111111111111111111111111", "url": "https://github.com/b/newb", "type": "git" },
|
||||
"dist": { "reference": "1111111111111111111111111111111111111111", "url": "https://api.github.com/repos/b/newb/zipball/1111111111111111111111111111111111111111", "type": "zip" },
|
||||
"type": "library"
|
||||
},
|
||||
{
|
||||
"name": "c/c", "version": "1.0.0",
|
||||
"source": { "reference": "1111111111111111111111111111111111111111", "url": "https://github.com/c/newc", "type": "git" },
|
||||
"dist": { "reference": "1111111111111111111111111111111111111111", "url": "https://api.github.com/repos/c/newc/zipball/1111111111111111111111111111111111111111", "type": "zip" },
|
||||
"type": "library"
|
||||
},
|
||||
{
|
||||
"name": "d/d", "version": "dev-master",
|
||||
"source": { "reference": "1111111111111111111111111111111111111111", "url": "https://github.com/d/newd", "type": "git" },
|
||||
"dist": { "reference": "1111111111111111111111111111111111111111", "url": "https://api.github.com/repos/d/newd/zipball/1111111111111111111111111111111111111111", "type": "zip" },
|
||||
"type": "library"
|
||||
},
|
||||
{
|
||||
"name": "f/f", "version": "dev-master",
|
||||
"source": { "reference": "1111111111111111111111111111111111111111", "url": "https://github.com/f/newf", "type": "git" },
|
||||
"dist": { "reference": "1111111111111111111111111111111111111111", "url": "https://api.github.com/repos/f/newf/zipball/1111111111111111111111111111111111111111", "type": "zip" },
|
||||
"type": "library"
|
||||
},
|
||||
{
|
||||
"name": "g/g", "version": "dev-master",
|
||||
"source": { "reference": "0000000000000000000000000000000000000000", "url": "https://github.com/g/newg", "type": "git" },
|
||||
"dist": { "reference": "0000000000000000000000000000000000000000", "url": "https://api.github.com/repos/g/newg/zipball/0000000000000000000000000000000000000000", "type": "zip" },
|
||||
"type": "library"
|
||||
}
|
||||
],
|
||||
"packages-dev": [],
|
||||
"aliases": [],
|
||||
"minimum-stability": "stable",
|
||||
"stability-flags": {
|
||||
"a/a": 20,
|
||||
"d/d": 20,
|
||||
"e/e": 20,
|
||||
"f/f": 20,
|
||||
"g/g": 20
|
||||
},
|
||||
"prefer-stable": false,
|
||||
"prefer-lowest": false,
|
||||
"platform": [],
|
||||
"platform-dev": []
|
||||
}
|
||||
--RUN--
|
||||
update mirrors
|
||||
--EXPECT--
|
@ -0,0 +1,67 @@
|
||||
--TEST--
|
||||
A composer update should remove unused locked dependencies from the lock file and remove unused installed deps from disk
|
||||
--COMPOSER--
|
||||
{
|
||||
"repositories": [
|
||||
{
|
||||
"type": "package",
|
||||
"package": [
|
||||
{ "name": "a/a", "version": "1.0.0" },
|
||||
{ "name": "b/b", "version": "1.0.0" }
|
||||
]
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"a/a": "*"
|
||||
}
|
||||
}
|
||||
--LOCK--
|
||||
{
|
||||
"packages": [
|
||||
{ "name": "a/a", "version": "1.0.0" },
|
||||
{ "name": "b/b", "version": "1.0.0" }
|
||||
],
|
||||
"packages-dev": [],
|
||||
"aliases": [],
|
||||
"minimum-stability": "stable",
|
||||
"stability-flags": [],
|
||||
"prefer-stable": false,
|
||||
"prefer-lowest": false,
|
||||
"platform": [],
|
||||
"platform-dev": []
|
||||
}
|
||||
--INSTALLED--
|
||||
[
|
||||
{ "name": "a/a", "version": "1.0.0" },
|
||||
{ "name": "b/b", "version": "1.0.0" },
|
||||
{ "name": "c/c", "version": "1.0.0" }
|
||||
]
|
||||
--RUN--
|
||||
update
|
||||
--EXPECT-LOCK--
|
||||
{
|
||||
"packages": [
|
||||
{ "name": "a/a", "version": "1.0.0", "type": "library" }
|
||||
],
|
||||
"packages-dev": [],
|
||||
"aliases": [],
|
||||
"minimum-stability": "stable",
|
||||
"stability-flags": [],
|
||||
"prefer-stable": false,
|
||||
"prefer-lowest": false,
|
||||
"platform": [],
|
||||
"platform-dev": []
|
||||
}
|
||||
--EXPECT-OUTPUT--
|
||||
Loading composer repositories with package information
|
||||
Updating dependencies
|
||||
Lock file operations: 0 installs, 0 updates, 1 removal
|
||||
- Uninstalling b/b (1.0.0)
|
||||
Writing lock file
|
||||
Installing dependencies from lock file (including require-dev)
|
||||
Package operations: 0 installs, 0 updates, 2 removals
|
||||
Generating autoload files
|
||||
|
||||
--EXPECT--
|
||||
Uninstalling c/c (1.0.0)
|
||||
Uninstalling b/b (1.0.0)
|
Loading…
Reference in New Issue