From 8160baec2a6bba1a9717d25f6805e9b5670fdbf6 Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 11 Aug 2017 07:55:54 -0700 Subject: [PATCH 01/46] Add a Differential revision status tokenizer datasource Summary: Ref T2543. This adds a tokenizer, similar to the Maniphest tokenizer, so the hard-coded `" with tokenizer Summary: Ref T2543. This updates the UI control in the web UI. Also: - This implicitly makes this queryable with the API (`differential.revision.search`); it previously was not. - This does NOT migrate existing saved queries. I'll do those in the next change, and hold this until it happens. - This will break some existing `/differential/?status=XYZ` links. For example, `status=open` now needs to be `status=open()`. I couldn't find any of these in the upstream, and I suspect these are rare in the wild (users would normally link directly to saved queries, not use URI query construction). Test Plan: {F5093611} Reviewers: chad Reviewed By: chad Maniphest Tasks: T2543 Differential Revision: https://secure.phabricator.com/D18393 --- .../constants/DifferentialLegacyQuery.php | 6 +++++- .../query/DifferentialRevisionQuery.php | 13 +++++++++++++ .../query/DifferentialRevisionSearchEngine.php | 15 ++++++++------- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/applications/differential/constants/DifferentialLegacyQuery.php b/src/applications/differential/constants/DifferentialLegacyQuery.php index 4a20267f10..6a87688e99 100644 --- a/src/applications/differential/constants/DifferentialLegacyQuery.php +++ b/src/applications/differential/constants/DifferentialLegacyQuery.php @@ -28,8 +28,12 @@ final class DifferentialLegacyQuery $status)); } + return self::getLegacyValues($map[$status]); + } + + public static function getLegacyValues(array $modern_values) { $values = array(); - foreach ($map[$status] as $status_constant) { + foreach ($modern_values as $status_constant) { $status_object = DifferentialRevisionStatus::newForStatus( $status_constant); diff --git a/src/applications/differential/query/DifferentialRevisionQuery.php b/src/applications/differential/query/DifferentialRevisionQuery.php index f53ec46a9f..79227df8ac 100644 --- a/src/applications/differential/query/DifferentialRevisionQuery.php +++ b/src/applications/differential/query/DifferentialRevisionQuery.php @@ -25,6 +25,7 @@ final class DifferentialRevisionQuery private $repositoryPHIDs; private $updatedEpochMin; private $updatedEpochMax; + private $statuses; const ORDER_MODIFIED = 'order-modified'; const ORDER_CREATED = 'order-created'; @@ -146,6 +147,11 @@ final class DifferentialRevisionQuery return $this; } + public function withStatuses(array $statuses) { + $this->statuses = $statuses; + return $this; + } + /** * Filter results to revisions on given branches. @@ -705,6 +711,13 @@ final class DifferentialRevisionQuery $statuses); } + if ($this->statuses !== null) { + $where[] = qsprintf( + $conn_r, + 'r.status in (%Ls)', + DifferentialLegacyQuery::getLegacyValues($this->statuses)); + } + $where[] = $this->buildWhereClauseParts($conn_r); return $this->formatWhereClause($where); } diff --git a/src/applications/differential/query/DifferentialRevisionSearchEngine.php b/src/applications/differential/query/DifferentialRevisionSearchEngine.php index 8cb8ffd2fb..dcbbaeedee 100644 --- a/src/applications/differential/query/DifferentialRevisionSearchEngine.php +++ b/src/applications/differential/query/DifferentialRevisionSearchEngine.php @@ -41,8 +41,8 @@ final class DifferentialRevisionSearchEngine $query->withRepositoryPHIDs($map['repositoryPHIDs']); } - if ($map['status']) { - $query->withStatus($map['status']); + if ($map['statuses']) { + $query->withStatuses($map['statuses']); } return $query; @@ -77,10 +77,11 @@ final class DifferentialRevisionSearchEngine ->setDatasource(new DiffusionRepositoryFunctionDatasource()) ->setDescription( pht('Find revisions from specific repositories.')), - id(new PhabricatorSearchSelectField()) - ->setLabel(pht('Status')) - ->setKey('status') - ->setOptions($this->getStatusOptions()) + id(new PhabricatorSearchDatasourceField()) + ->setLabel(pht('Statuses')) + ->setKey('statuses') + ->setAliases(array('status')) + ->setDatasource(new DifferentialRevisionStatusFunctionDatasource()) ->setDescription( pht('Find revisions with particular statuses.')), ); @@ -115,7 +116,7 @@ final class DifferentialRevisionSearchEngine return $query ->setParameter('responsiblePHIDs', array($viewer->getPHID())) - ->setParameter('status', DifferentialLegacyQuery::STATUS_OPEN) + ->setParameter('statuses', array('open()')) ->setParameter('bucket', $bucket_key); case 'authored': return $query From 212d4d0dc7530ed32e1e13d0b4870ba37922ddd4 Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 11 Aug 2017 09:03:47 -0700 Subject: [PATCH 03/46] Migrate Differential Revision SavedQueries to the new "statuses" tokenizer Summary: Ref T2543. This migrates existing saved queries so they use the right modern values for the new tokenizer control, introduced in D18393. Test Plan: - Saved a query with "Abandoned" selected as the status in the old "