1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-18 21:02:41 +01:00

When loading packages affected by a change to a particular path, ignore archived packages

Summary:
Ref T11650. Currently, we load packages and then discard the archived ones.

However, this gets "dominion" rules (where a more-general package gives up ownership if a more-specific package exists) wrong if the more-specific package is archived: we incorrectly give up ownership.

Instead, just ignore these packages completely when loading affected packages. This is slightly simpler.

(There are technically two pieces of code we have to do this for, which should be a single piece of code but which haven't yet been unified.)

Test Plan:
  - Created packages:
    - Package A, on "/" (strong dominion, autoreview).
    - Package B, on "/x/" (weak dominion, autoreview).
    - Package C, on "/x/y" (archived, autoreview).
  - Create a revision affecting "/x/y".
  - Saw correct path ownership in table of contents ("B", strongest package only).
  - Saw correct autoreview behavior (A + B).
  - (Prior to patch, in `master`, reproduced the problem behaviors described in T11650, with bad dominion rules and failure to autoreview B.)

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T11650

Differential Revision: https://secure.phabricator.com/D16564
This commit is contained in:
epriestley 2016-09-16 11:59:20 -07:00
parent 5cffe9e5e5
commit 7f6fa28363
4 changed files with 11 additions and 13 deletions

View file

@ -1511,13 +1511,6 @@ final class DifferentialTransactionEditor
$packages = PhabricatorOwnersPackage::loadAffectedPackages( $packages = PhabricatorOwnersPackage::loadAffectedPackages(
$repository, $repository,
$this->affectedPaths); $this->affectedPaths);
foreach ($packages as $key => $package) {
if ($package->isArchived()) {
unset($packages[$key]);
}
}
if (!$packages) { if (!$packages) {
return array(); return array();
} }

View file

@ -358,6 +358,13 @@ final class PhabricatorOwnersPackageQuery
$best_match = null; $best_match = null;
$include = false; $include = false;
// If this package is archived, it's no longer a controlling package
// for the given path. In particular, it can not force active packages
// with weak dominion to give up control.
if ($package->isArchived()) {
continue;
}
foreach ($package->getPaths() as $package_path) { foreach ($package->getPaths() as $package_path) {
if ($package_path->getRepositoryPHID() != $repository_phid) { if ($package_path->getRepositoryPHID() != $repository_phid) {
// If this path is for some other repository, skip it. // If this path is for some other repository, skip it.

View file

@ -211,10 +211,13 @@ final class PhabricatorOwnersPackage
$conn, $conn,
'SELECT pkg.id, pkg.dominion, p.excluded, p.path 'SELECT pkg.id, pkg.dominion, p.excluded, p.path
FROM %T pkg JOIN %T p ON p.packageID = pkg.id FROM %T pkg JOIN %T p ON p.packageID = pkg.id
WHERE p.path IN (%Ls) %Q', WHERE p.path IN (%Ls) AND pkg.status IN (%Ls) %Q',
$package->getTableName(), $package->getTableName(),
$path->getTableName(), $path->getTableName(),
$chunk, $chunk,
array(
self::STATUS_ACTIVE,
),
$repository_clause); $repository_clause);
} }
$rows = array_mergev($rows); $rows = array_mergev($rows);

View file

@ -77,11 +77,6 @@ final class PhabricatorRepositoryCommitOwnersWorker
continue; continue;
} }
if ($package->isArchived()) {
// Don't trigger audits if the package is archived.
continue;
}
if ($package->getAuditingEnabled()) { if ($package->getAuditingEnabled()) {
$reasons = $this->checkAuditReasons( $reasons = $this->checkAuditReasons(
$commit, $commit,