Differential D19420 Diff 46461 src/applications/owners/xaction/PhabricatorOwnersPackagePathsTransaction.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/owners/xaction/PhabricatorOwnersPackagePathsTransaction.php
| Show First 20 Lines • Show All 102 Lines • ▼ Show 20 Lines | public function applyExternalEffects($object, $value) { | ||||
| $paths = $object->getPaths(); | $paths = $object->getPaths(); | ||||
| // We store paths in a normalized format with a trailing slash, regardless | // We store paths in a normalized format with a trailing slash, regardless | ||||
| // of whether the user enters "path/to/file.c" or "src/backend/". Normalize | // of whether the user enters "path/to/file.c" or "src/backend/". Normalize | ||||
| // paths now. | // paths now. | ||||
| $display_map = array(); | $display_map = array(); | ||||
| $seen_map = array(); | |||||
| foreach ($new as $key => $spec) { | foreach ($new as $key => $spec) { | ||||
| $display_path = $spec['path']; | $display_path = $spec['path']; | ||||
| $raw_path = rtrim($display_path, '/').'/'; | $raw_path = rtrim($display_path, '/').'/'; | ||||
| // If the user entered two paths which normalize to the same value | // If the user entered two paths in the same repository which normalize | ||||
| // (like "src/main.c" and "src/main.c/"), discard the duplicates. | // to the same value (like "src/main.c" and "src/main.c/"), discard the | ||||
| if (isset($display_map[$raw_path])) { | // duplicates. | ||||
| $repository_phid = $spec['repositoryPHID']; | |||||
| if (isset($seen_map[$repository_phid][$raw_path])) { | |||||
| unset($new[$key]); | unset($new[$key]); | ||||
| continue; | continue; | ||||
| } | } | ||||
| $new[$key]['path'] = $raw_path; | $new[$key]['path'] = $raw_path; | ||||
| $display_map[$raw_path] = $display_path; | $display_map[$raw_path] = $display_path; | ||||
| $seen_map[$repository_phid][$raw_path] = true; | |||||
| } | } | ||||
| $diffs = PhabricatorOwnersPath::getTransactionValueChanges($old, $new); | $diffs = PhabricatorOwnersPath::getTransactionValueChanges($old, $new); | ||||
| list($rem, $add) = $diffs; | list($rem, $add) = $diffs; | ||||
| $set = PhabricatorOwnersPath::getSetFromTransactionValue($rem); | $set = PhabricatorOwnersPath::getSetFromTransactionValue($rem); | ||||
| foreach ($paths as $path) { | foreach ($paths as $path) { | ||||
| $ref = $path->getRef(); | $ref = $path->getRef(); | ||||
| ▲ Show 20 Lines • Show All 90 Lines • Show Last 20 Lines | |||||