diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index dcddcd6005..6527f5a0fd 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -156,6 +156,7 @@ phutil_register_library_map(array( 'DifferentialRevisionUpdateHistoryView' => 'applications/differential/view/revisionupdatehistory', 'DifferentialRevisionViewController' => 'applications/differential/controller/revisionview', 'DifferentialSubscribeController' => 'applications/differential/controller/subscribe', + 'DifferentialTasksAttacher' => 'applications/differential/tasks', 'DifferentialUnitStatus' => 'applications/differential/constants/unitstatus', 'DiffusionBranchInformation' => 'applications/diffusion/data/branch', 'DiffusionBranchQuery' => 'applications/diffusion/query/branch/base', diff --git a/src/applications/conduit/method/differential/getcommitmessage/ConduitAPI_differential_getcommitmessage_Method.php b/src/applications/conduit/method/differential/getcommitmessage/ConduitAPI_differential_getcommitmessage_Method.php index 597ca7366c..a61e5db669 100644 --- a/src/applications/conduit/method/differential/getcommitmessage/ConduitAPI_differential_getcommitmessage_Method.php +++ b/src/applications/conduit/method/differential/getcommitmessage/ConduitAPI_differential_getcommitmessage_Method.php @@ -66,6 +66,7 @@ class ConduitAPI_differential_getcommitmessage_Method extends ConduitAPIMethod { 'testPlan' => 'Test Plan', 'blameRevision' => 'Blame Revision', 'revertPlan' => 'Revert Plan', + 'tasks' => 'Tasks', ); foreach ($fields as $field => $value) { diff --git a/src/applications/conduit/method/differential/parsecommitmessage/ConduitAPI_differential_parsecommitmessage_Method.php b/src/applications/conduit/method/differential/parsecommitmessage/ConduitAPI_differential_parsecommitmessage_Method.php index 82bbc78603..2e4058a4c6 100644 --- a/src/applications/conduit/method/differential/parsecommitmessage/ConduitAPI_differential_parsecommitmessage_Method.php +++ b/src/applications/conduit/method/differential/parsecommitmessage/ConduitAPI_differential_parsecommitmessage_Method.php @@ -62,6 +62,7 @@ class ConduitAPI_differential_parsecommitmessage_Method 'ccPHIDs' => $message->getCCPHIDs(), 'revisionID' => $message->getRevisionID(), 'gitSVNID' => $message->getGitSVNID(), + 'tasks' => $message->getTasks(), ), ); } diff --git a/src/applications/differential/editor/revision/DifferentialRevisionEditor.php b/src/applications/differential/editor/revision/DifferentialRevisionEditor.php index 2f012dba41..0c0f23c13b 100644 --- a/src/applications/differential/editor/revision/DifferentialRevisionEditor.php +++ b/src/applications/differential/editor/revision/DifferentialRevisionEditor.php @@ -31,6 +31,7 @@ class DifferentialRevisionEditor { protected $diff; protected $comments; protected $silentUpdate; + protected $tasks = null; public function __construct(DifferentialRevision $revision, $actor_phid) { $this->revision = $revision; @@ -55,6 +56,11 @@ class DifferentialRevisionEditor { $editor->addDiff($diff, null); $editor->save(); + // Tasks can only be updated after revision has been saved to the + // database. Currently tasks are updated only when a revision is created. + // UI must be used to modify tasks after creating one. + $editor->updateTasks(); + return $revision; } @@ -70,6 +76,7 @@ class DifferentialRevisionEditor { $this->setReviewers($fields['reviewerPHIDs']); $this->setCCPHIDs($fields['ccPHIDs']); + $this->setTasks($fields['tasks']); } public function getRevision() { @@ -86,6 +93,10 @@ class DifferentialRevisionEditor { return $this; } + public function setTasks(array $tasks) { + $this->tasks = $tasks; + } + public function addDiff(DifferentialDiff $diff, $comments) { if ($diff->getRevisionID() && $diff->getRevisionID() != $this->getRevision()->getID()) { @@ -555,5 +566,20 @@ class DifferentialRevisionEditor { return $comment; } + private function updateTasks() { + if ($this->tasks) { + $task_class = PhabricatorEnv::getEnvConfig( + 'differential.attach-task-class'); + if ($task_class) { + PhutilSymbolLoader::loadClass($task_class); + $task_attacher = newv($task_class, array()); + $ret = $task_attacher->attachTasksToRevision( + $this->actorPHID, + $this->revision, + $this->tasks); + } + } + } + } diff --git a/src/applications/differential/editor/revision/__init__.php b/src/applications/differential/editor/revision/__init__.php index ad53cc8f87..969a88333f 100644 --- a/src/applications/differential/editor/revision/__init__.php +++ b/src/applications/differential/editor/revision/__init__.php @@ -19,6 +19,7 @@ phutil_require_module('phabricator', 'infrastructure/env'); phutil_require_module('phabricator', 'storage/qsprintf'); phutil_require_module('phabricator', 'storage/queryfx'); +phutil_require_module('phutil', 'symbols'); phutil_require_module('phutil', 'utils'); diff --git a/src/applications/differential/parser/commitmessage/DifferentialCommitMessage.php b/src/applications/differential/parser/commitmessage/DifferentialCommitMessage.php index ba3c5500d2..f0c1dbdc6e 100644 --- a/src/applications/differential/parser/commitmessage/DifferentialCommitMessage.php +++ b/src/applications/differential/parser/commitmessage/DifferentialCommitMessage.php @@ -39,6 +39,8 @@ class DifferentialCommitMessage { protected $revisionID; protected $gitSVNID; + protected $tasks = array(); + protected function __construct() { } @@ -160,6 +162,14 @@ class DifferentialCommitMessage { return $this; } + public function setTasks(array $tasks) { + $this->tasks = $tasks; + return $this; + } + + public function getTasks() { + return $this->tasks; + } public static function newFromRawCorpus($raw_corpus) { $message = new DifferentialCommitMessage(); @@ -202,6 +212,9 @@ class DifferentialCommitMessage { case 'Commenters': // Just drop this. break; + case 'Tasks': + $message->setTasks($data); + break; default: throw new Exception("Unrecognized field '{$field}'."); } @@ -298,7 +311,9 @@ class DifferentialCommitMessage { 'CC' => 'CC', 'Revert' => 'Revert Plan', 'Revert Plan' => 'Revert Plan', - + 'Task ID' => 'Tasks', + 'Task IDs' => 'Tasks', + 'Tasks' => 'Tasks', 'git-svn-id' => 'git-svn-id', // This appears only in "arc amend"-ed messages, just discard it. diff --git a/src/applications/differential/tasks/DifferentialTasksAttacher.php b/src/applications/differential/tasks/DifferentialTasksAttacher.php new file mode 100644 index 0000000000..72576ae250 --- /dev/null +++ b/src/applications/differential/tasks/DifferentialTasksAttacher.php @@ -0,0 +1,29 @@ +