From a9e2e51b9821af5ce0b8076d4d03be0a8ff88e0c Mon Sep 17 00:00:00 2001 From: jungejason Date: Thu, 21 Apr 2011 18:47:04 -0700 Subject: [PATCH 1/4] Enable updating task->revision assoc Summary: add a conduit method to enable querying revisions' phid from their revision_IDs, and another one to update the task->revision assoc. Test Plan: for querying revision_phid method, tested empty, one, and two revisions in the query. For the one to update the task->revision assoc, I have another diff in facebook which verified it add and remove assoc correctly. Reviewers: tuomaspelkonen, epriestley CC: Differential Revision: 165 --- src/__phutil_library_map__.php | 2 + .../PhabricatorConduitConsoleController.php | 2 +- .../ConduitAPI_differential_find_Method.php | 7 +- ...rential_updatetaskrevisionassoc_Method.php | 71 +++++++++++++++++++ .../updatetaskrevisionassoc/__init__.php | 17 +++++ .../tasks/DifferentialTasksAttacher.php | 11 +++ 6 files changed, 106 insertions(+), 4 deletions(-) create mode 100644 src/applications/conduit/method/differential/updatetaskrevisionassoc/ConduitAPI_differential_updatetaskrevisionassoc_Method.php create mode 100644 src/applications/conduit/method/differential/updatetaskrevisionassoc/__init__.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 6527f5a0fd..7ce8fb0608 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -88,6 +88,7 @@ phutil_register_library_map(array( 'ConduitAPI_differential_parsecommitmessage_Method' => 'applications/conduit/method/differential/parsecommitmessage', 'ConduitAPI_differential_setdiffproperty_Method' => 'applications/conduit/method/differential/setdiffproperty', 'ConduitAPI_differential_updaterevision_Method' => 'applications/conduit/method/differential/updaterevision', + 'ConduitAPI_differential_updatetaskrevisionassoc_Method' => 'applications/conduit/method/differential/updatetaskrevisionassoc', 'ConduitAPI_diffusion_getcommits_Method' => 'applications/conduit/method/diffusion/getcommits', 'ConduitAPI_file_upload_Method' => 'applications/conduit/method/file/upload', 'ConduitAPI_path_getowners_Method' => 'applications/conduit/method/path/getowners', @@ -539,6 +540,7 @@ phutil_register_library_map(array( 'ConduitAPI_differential_parsecommitmessage_Method' => 'ConduitAPIMethod', 'ConduitAPI_differential_setdiffproperty_Method' => 'ConduitAPIMethod', 'ConduitAPI_differential_updaterevision_Method' => 'ConduitAPIMethod', + 'ConduitAPI_differential_updatetaskrevisionassoc_Method' => 'ConduitAPIMethod', 'ConduitAPI_diffusion_getcommits_Method' => 'ConduitAPIMethod', 'ConduitAPI_file_upload_Method' => 'ConduitAPIMethod', 'ConduitAPI_path_getowners_Method' => 'ConduitAPIMethod', diff --git a/src/applications/conduit/controller/console/PhabricatorConduitConsoleController.php b/src/applications/conduit/controller/console/PhabricatorConduitConsoleController.php index 4bee4284c5..4ffb6087fb 100644 --- a/src/applications/conduit/controller/console/PhabricatorConduitConsoleController.php +++ b/src/applications/conduit/controller/console/PhabricatorConduitConsoleController.php @@ -83,7 +83,7 @@ class PhabricatorConduitConsoleController id(new AphrontFormTextControl()) ->setLabel($param) ->setName("params[{$param}]") - ->setCaption($desc)); + ->setCaption(phutil_escape_html($desc))); } $form diff --git a/src/applications/conduit/method/differential/find/ConduitAPI_differential_find_Method.php b/src/applications/conduit/method/differential/find/ConduitAPI_differential_find_Method.php index fc4b986f1e..4cc284b0ce 100644 --- a/src/applications/conduit/method/differential/find/ConduitAPI_differential_find_Method.php +++ b/src/applications/conduit/method/differential/find/ConduitAPI_differential_find_Method.php @@ -34,7 +34,7 @@ class ConduitAPI_differential_find_Method extends ConduitAPIMethod { return array( 'query' => 'required enum<'.$types.'>', - 'guids' => 'required nonempty list', + 'guids' => 'required nonempty list', ); } @@ -49,11 +49,11 @@ class ConduitAPI_differential_find_Method extends ConduitAPIMethod { protected function execute(ConduitAPIRequest $request) { $query = $request->getValue('query'); - $phids = $request->getValue('guids'); + $guids = $request->getValue('guids'); $revisions = id(new DifferentialRevisionListData( $query, - (array)$phids)) + (array)$guids)) ->loadRevisions(); $results = array(); @@ -64,6 +64,7 @@ class ConduitAPI_differential_find_Method extends ConduitAPIMethod { } $results[] = array( 'id' => $revision->getID(), + 'phid' => $revision->getPHID(), 'name' => $revision->getTitle(), 'statusName' => DifferentialRevisionStatus::getNameForRevisionStatus( $revision->getStatus()), diff --git a/src/applications/conduit/method/differential/updatetaskrevisionassoc/ConduitAPI_differential_updatetaskrevisionassoc_Method.php b/src/applications/conduit/method/differential/updatetaskrevisionassoc/ConduitAPI_differential_updatetaskrevisionassoc_Method.php new file mode 100644 index 0000000000..45a3a6829b --- /dev/null +++ b/src/applications/conduit/method/differential/updatetaskrevisionassoc/ConduitAPI_differential_updatetaskrevisionassoc_Method.php @@ -0,0 +1,71 @@ + 'required nonempty string', + 'orig_rev_phids' => 'required list', + 'new_rev_phids' => 'required list', + ); + } + + public function defineReturnType() { + return 'void'; + } + + public function defineErrorTypes() { + return array( + 'ERR_NO_TASKATTACHER_DEFINED' => 'No task attacher defined.', + ); + } + + protected function execute(ConduitAPIRequest $request) { + $task_phid = $request->getValue('task_phid'); + $orig_rev_phids = $request->getValue('orig_rev_phids'); + if (empty($orig_rev_phids)) { + $orig_rev_phids = array(); + } + + $new_rev_phids = $request->getValue('new_rev_phids'); + if (empty($new_rev_phids)) { + $new_rev_phids = array(); + } + + $task_class = PhabricatorEnv::getEnvConfig( + 'differential.attach-task-class'); + if (!$task_class) { + throw new ConduitException('ERR_NO_TASKATTACHER_DEFINED'); + } + + PhutilSymbolLoader::loadClass($task_class); + $task_attacher = newv($task_class, array()); + $task_attacher->updateTaskRevisionAssoc( + $task_phid, + $orig_rev_phids, + $new_rev_phids); + } + +} + diff --git a/src/applications/conduit/method/differential/updatetaskrevisionassoc/__init__.php b/src/applications/conduit/method/differential/updatetaskrevisionassoc/__init__.php new file mode 100644 index 0000000000..0ad02cea4f --- /dev/null +++ b/src/applications/conduit/method/differential/updatetaskrevisionassoc/__init__.php @@ -0,0 +1,17 @@ + Date: Tue, 26 Apr 2011 21:59:44 -0700 Subject: [PATCH 2/4] Enable differential.find handle empty input. Summary: return empty array when the query input is empty. Test Plan: send empty input. Reviewed By: tuomaspelkonen Reviewers: tuomaspelkonen CC: tuomaspelkonen Differential Revision: 167 --- .../find/ConduitAPI_differential_find_Method.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/applications/conduit/method/differential/find/ConduitAPI_differential_find_Method.php b/src/applications/conduit/method/differential/find/ConduitAPI_differential_find_Method.php index 4cc284b0ce..1c00674718 100644 --- a/src/applications/conduit/method/differential/find/ConduitAPI_differential_find_Method.php +++ b/src/applications/conduit/method/differential/find/ConduitAPI_differential_find_Method.php @@ -51,12 +51,16 @@ class ConduitAPI_differential_find_Method extends ConduitAPIMethod { $query = $request->getValue('query'); $guids = $request->getValue('guids'); + $results = array(); + if (!$guids) { + return $results; + } + $revisions = id(new DifferentialRevisionListData( $query, (array)$guids)) ->loadRevisions(); - $results = array(); foreach ($revisions as $revision) { $diff = $revision->loadActiveDiff(); if (!$diff) { From 2b0b39c4e4b2dc0404f89dfddeae18e80c1b5c2d Mon Sep 17 00:00:00 2001 From: tuomaspelkonen Date: Wed, 27 Apr 2011 16:19:31 -0700 Subject: [PATCH 3/4] Differential defaults to 'ignore-trailing' until indentation issues are solved. Summary: 'ignore-all' is very confusing, especially for Python, because the indentation is incorrect. Test Plan: Tested loading D240353 without any options and made sure 'ignore-trailing' was selected and the diff looked correct. Reviewed By: aran Reviewers: jungejason, simpkins, aran, dpepper Commenters: dpepper CC: grglr, aran, dpepper, tuomaspelkonen Differential Revision: 171 --- .../DifferentialRevisionViewController.php | 285 +----------------- .../DifferentialChangesetListView.php | 12 +- 2 files changed, 18 insertions(+), 279 deletions(-) diff --git a/src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php b/src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php index 5a03483b2e..e73757d9c3 100644 --- a/src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php +++ b/src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php @@ -169,11 +169,18 @@ class DifferentialRevisionViewController extends DifferentialController { $comment_view->setUser($user); $comment_view->setTargetDiff($target); + $changeset_view = new DifferentialChangesetListView(); + $changeset_view->setChangesets($visible_changesets); + $changeset_view->setEditable(true); + $changeset_view->setRevision($revision); + $changeset_view->setVsMap($vs_map); + $changeset_view->setWhitespace($request->getStr('whitespace')); + $diff_history = new DifferentialRevisionUpdateHistoryView(); $diff_history->setDiffs($diffs); $diff_history->setSelectedVersusDiffID($diff_vs); $diff_history->setSelectedDiffID($target->getID()); - $diff_history->setSelectedWhitespace($request->getStr('whitespace')); + $diff_history->setSelectedWhitespace($changeset_view->getWhitespace()); $toc_view = new DifferentialDiffTableOfContentsView(); $toc_view->setChangesets($changesets); @@ -181,12 +188,6 @@ class DifferentialRevisionViewController extends DifferentialController { $toc_view->setVsMap($vs_map); $toc_view->setRevisionID($revision->getID()); - $changeset_view = new DifferentialChangesetListView(); - $changeset_view->setChangesets($visible_changesets); - $changeset_view->setEditable(true); - $changeset_view->setRevision($revision); - $changeset_view->setVsMap($vs_map); - $changeset_view->setWhitespace($request->getStr('whitespace')); $draft = id(new PhabricatorDraft())->loadOneWhere( 'authorPHID = %s AND draftKey = %s', @@ -594,273 +595,3 @@ class DifferentialRevisionViewController extends DifferentialController { } } -/* - - - protected function getSandcastleURI(Diff $diff) { - $uri = $this->getDiffProperty($diff, 'facebook:sandcastle_uri'); - if (!$uri) { - $uri = $diff->getSandboxURL(); - } - return $uri; - } - - protected function getDiffProperty(Diff $diff, $property, $default = null) { - $diff_id = $diff->getID(); - if (empty($this->diffProperties[$diff_id])) { - $props = id(new DifferentialDiffProperty()) - ->loadAllWhere('diffID = %s', $diff_id); - $dict = array_pull($props, 'getData', 'getName'); - $this->diffProperties[$diff_id] = $dict; - } - return idx($this->diffProperties[$diff_id], $property, $default); - } - - $diff_table->appendChild( - - - - {id(