From 2dbfb1d5fb1753d4cc650a1bb691f49f636c4c22 Mon Sep 17 00:00:00 2001 From: epriestley Date: Sun, 9 Mar 2014 14:53:05 -0700 Subject: [PATCH] Remove DifferentialComment Summary: Ref T2222. Remove this; no more callsites. Test Plan: `grep` Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T2222 Differential Revision: https://secure.phabricator.com/D8477 --- resources/celerity/map.php | 32 +- .../autopatches/20140212.dx.1.armageddon.php | 8 +- src/__phutil_library_map__.php | 2 - .../storage/DifferentialComment.php | 359 ------------------ 4 files changed, 16 insertions(+), 385 deletions(-) delete mode 100644 src/applications/differential/storage/DifferentialComment.php diff --git a/resources/celerity/map.php b/resources/celerity/map.php index 30ce9f6b9a..24e620b5c1 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -11,7 +11,7 @@ return array( 'core.pkg.js' => 'b7bdab05', 'darkconsole.pkg.js' => 'ca8671ce', 'differential.pkg.css' => 'd1b3a605', - 'differential.pkg.js' => 'e0d3b0da', + 'differential.pkg.js' => '11a5b750', 'diffusion.pkg.css' => '3783278d', 'diffusion.pkg.js' => '5b4010f4', 'javelin.pkg.js' => '5b0f988e', @@ -357,7 +357,6 @@ return array( 'rsrc/js/application/conpherence/behavior-widget-pane.js' => 'd8ef8659', 'rsrc/js/application/countdown/timer.js' => '889c96f3', 'rsrc/js/application/differential/DifferentialInlineCommentEditor.js' => 'f2441746', - 'rsrc/js/application/differential/behavior-accept-with-errors.js' => 'e12c760a', 'rsrc/js/application/differential/behavior-add-reviewers-and-ccs.js' => '533a187b', 'rsrc/js/application/differential/behavior-comment-jump.js' => '71755c79', 'rsrc/js/application/differential/behavior-comment-preview.js' => '127f2018', @@ -546,7 +545,6 @@ return array( 'javelin-behavior-countdown-timer' => '889c96f3', 'javelin-behavior-dark-console' => 'e9fdb5e5', 'javelin-behavior-device' => '03d6ed07', - 'javelin-behavior-differential-accept-with-errors' => 'e12c760a', 'javelin-behavior-differential-add-reviewers-and-ccs' => '533a187b', 'javelin-behavior-differential-comment-jump' => '71755c79', 'javelin-behavior-differential-diff-radios' => 'e1ff79b1', @@ -1817,11 +1815,6 @@ return array( 1 => 'javelin-util', 2 => 'javelin-request', ), - 'e12c760a' => - array( - 0 => 'javelin-behavior', - 1 => 'javelin-dom', - ), 'e1ff79b1' => array( 0 => 'javelin-behavior', @@ -2140,18 +2133,17 @@ return array( 4 => 'javelin-behavior-differential-populate', 5 => 'javelin-behavior-differential-show-more', 6 => 'javelin-behavior-differential-diff-radios', - 7 => 'javelin-behavior-differential-accept-with-errors', - 8 => 'javelin-behavior-differential-comment-jump', - 9 => 'javelin-behavior-differential-add-reviewers-and-ccs', - 10 => 'javelin-behavior-differential-keyboard-navigation', - 11 => 'javelin-behavior-aphront-drag-and-drop-textarea', - 12 => 'javelin-behavior-phabricator-object-selector', - 13 => 'javelin-behavior-repository-crossreference', - 14 => 'javelin-behavior-load-blame', - 15 => 'differential-inline-comment-editor', - 16 => 'javelin-behavior-differential-dropdown-menus', - 17 => 'javelin-behavior-differential-toggle-files', - 18 => 'javelin-behavior-differential-user-select', + 7 => 'javelin-behavior-differential-comment-jump', + 8 => 'javelin-behavior-differential-add-reviewers-and-ccs', + 9 => 'javelin-behavior-differential-keyboard-navigation', + 10 => 'javelin-behavior-aphront-drag-and-drop-textarea', + 11 => 'javelin-behavior-phabricator-object-selector', + 12 => 'javelin-behavior-repository-crossreference', + 13 => 'javelin-behavior-load-blame', + 14 => 'differential-inline-comment-editor', + 15 => 'javelin-behavior-differential-dropdown-menus', + 16 => 'javelin-behavior-differential-toggle-files', + 17 => 'javelin-behavior-differential-user-select', ), 'diffusion.pkg.css' => array( diff --git a/resources/sql/autopatches/20140212.dx.1.armageddon.php b/resources/sql/autopatches/20140212.dx.1.armageddon.php index 77d9518121..db2fb1de73 100644 --- a/resources/sql/autopatches/20140212.dx.1.armageddon.php +++ b/resources/sql/autopatches/20140212.dx.1.armageddon.php @@ -42,10 +42,10 @@ foreach ($rows as $row) { $metadata = array(); } - $key_cc = DifferentialComment::METADATA_ADDED_CCS; - $key_add_rev = DifferentialComment::METADATA_ADDED_REVIEWERS; - $key_rem_rev = DifferentialComment::METADATA_REMOVED_REVIEWERS; - $key_diff_id = DifferentialComment::METADATA_DIFF_ID; + $key_cc = 'added-ccs'; + $key_add_rev = 'added-reviewers'; + $key_rem_rev = 'removed-reviewers'; + $key_diff_id = 'diff-id'; $xactions = array(); diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 70992c875e..b59bbbc548 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -343,7 +343,6 @@ phutil_register_library_map(array( 'DifferentialChangesetTwoUpRenderer' => 'applications/differential/render/DifferentialChangesetTwoUpRenderer.php', 'DifferentialChangesetTwoUpTestRenderer' => 'applications/differential/render/DifferentialChangesetTwoUpTestRenderer.php', 'DifferentialChangesetViewController' => 'applications/differential/controller/DifferentialChangesetViewController.php', - 'DifferentialComment' => 'applications/differential/storage/DifferentialComment.php', 'DifferentialCommentPreviewController' => 'applications/differential/controller/DifferentialCommentPreviewController.php', 'DifferentialCommentSaveController' => 'applications/differential/controller/DifferentialCommentSaveController.php', 'DifferentialCommitMessageParser' => 'applications/differential/parser/DifferentialCommitMessageParser.php', @@ -2864,7 +2863,6 @@ phutil_register_library_map(array( 'DifferentialChangesetTwoUpRenderer' => 'DifferentialChangesetHTMLRenderer', 'DifferentialChangesetTwoUpTestRenderer' => 'DifferentialChangesetTestRenderer', 'DifferentialChangesetViewController' => 'DifferentialController', - 'DifferentialComment' => 'PhabricatorMarkupInterface', 'DifferentialCommentPreviewController' => 'DifferentialController', 'DifferentialCommentSaveController' => 'DifferentialController', 'DifferentialCommitMessageParserTestCase' => 'PhabricatorTestCase', diff --git a/src/applications/differential/storage/DifferentialComment.php b/src/applications/differential/storage/DifferentialComment.php deleted file mode 100644 index b838a9c285..0000000000 --- a/src/applications/differential/storage/DifferentialComment.php +++ /dev/null @@ -1,359 +0,0 @@ -proxy = new DifferentialTransaction(); - } - - public function __clone() { - $this->proxy = clone $this->proxy; - if ($this->proxyComment) { - $this->proxyComment = clone $this->proxyComment; - } - } - - public static function newFromModernTransaction( - DifferentialTransaction $xaction) { - - $obj = new DifferentialComment(); - $obj->proxy = $xaction; - - if ($xaction->hasComment()) { - $obj->proxyComment = $xaction->getComment(); - } - - return $obj; - } - - public function getPHID() { - return $this->proxy->getPHID(); - } - - public function getContent() { - return $this->getProxyComment()->getContent(); - } - - public function setContent($content) { - $this->getProxyComment()->setContent($content); - return $this; - } - - public function getAuthorPHID() { - return $this->proxy->getAuthorPHID(); - } - - public function setAuthorPHID($author_phid) { - $this->proxy->setAuthorPHID($author_phid); - return $this; - } - - public function setContentSource($content_source) { - $this->proxy->setContentSource($content_source); - $this->proxyComment->setContentSource($content_source); - return $this; - } - - public function setAction($action) { - $meta = array(); - switch ($action) { - case DifferentialAction::ACTION_COMMENT: - $type = PhabricatorTransactions::TYPE_COMMENT; - $old = null; - $new = null; - break; - case DifferentialAction::ACTION_ADDREVIEWERS: - $type = PhabricatorTransactions::TYPE_EDGE; - $old = array(); - $new = array(); - $meta = array( - 'edge:type' => PhabricatorEdgeConfig::TYPE_DREV_HAS_REVIEWER, - ); - break; - case DifferentialAction::ACTION_ADDCCS: - $type = PhabricatorTransactions::TYPE_SUBSCRIBERS; - $old = array(); - $new = array(); - break; - case DifferentialAction::ACTION_UPDATE: - $type = DifferentialTransaction::TYPE_UPDATE; - $old = null; - $new = null; - break; - case DifferentialTransaction::TYPE_INLINE: - $type = $action; - $old = null; - $new = null; - break; - default: - $type = DifferentialTransaction::TYPE_ACTION; - $old = null; - $new = $action; - break; - } - - $xaction = $this->proxy; - - $xaction - ->setTransactionType($type) - ->setOldValue($old) - ->setNewValue($new); - - if ($meta) { - foreach ($meta as $key => $value) { - $xaction->setMetadataValue($key, $value); - } - } - - return $this; - } - - public function getAction() { - switch ($this->proxy->getTransactionType()) { - case PhabricatorTransactions::TYPE_SUBSCRIBERS: - return DifferentialAction::ACTION_ADDCCS; - case DifferentialTransaction::TYPE_UPDATE: - return DifferentialAction::ACTION_UPDATE; - case PhabricatorTransactions::TYPE_EDGE: - return DifferentialAction::ACTION_ADDREVIEWERS; - case PhabricatorTransactions::TYPE_COMMENT: - return DifferentialAction::ACTION_COMMENT; - case DifferentialTransaction::TYPE_INLINE: - return DifferentialTransaction::TYPE_INLINE; - default: - return $this->proxy->getNewValue(); - } - } - - public function setMetadata(array $metadata) { - if (!$this->proxy->getTransactionType()) { - throw new Exception(pht('Call setAction() before setMetadata()!')); - } - - $key_cc = self::METADATA_ADDED_CCS; - $key_add_rev = self::METADATA_ADDED_REVIEWERS; - $key_rem_rev = self::METADATA_REMOVED_REVIEWERS; - $key_diff_id = self::METADATA_DIFF_ID; - - switch ($this->proxy->getTransactionType()) { - case DifferentialTransaction::TYPE_UPDATE: - $id = idx($metadata, $key_diff_id); - $this->proxy->setNewValue($id); - break; - case PhabricatorTransactions::TYPE_EDGE: - $rem = idx($metadata, $key_rem_rev, array()); - $old = array(); - foreach ($rem as $phid) { - $old[$phid] = array( - 'src' => $this->proxy->getObjectPHID(), - 'type' => PhabricatorEdgeConfig::TYPE_DREV_HAS_REVIEWER, - 'dst' => $phid, - ); - } - $this->proxy->setOldValue($old); - - $add = idx($metadata, $key_add_rev, array()); - $new = array(); - foreach ($add as $phid) { - $new[$phid] = array( - 'src' => $this->proxy->getObjectPHID(), - 'type' => PhabricatorEdgeConfig::TYPE_DREV_HAS_REVIEWER, - 'dst' => $phid, - ); - } - $this->proxy->setNewValue($new); - break; - case PhabricatorTransactions::TYPE_SUBSCRIBERS: - $phids = idx($metadata, $key_cc, array()); - $new = array(); - foreach ($phids as $phid) { - $new[$phid] = $phid; - } - $this->proxy->setNewValue($new); - break; - default: - break; - } - - return $this; - } - - public function getMetadata() { - if (!$this->proxy->getTransactionType()) { - throw new Exception(pht('Call setAction() before getMetadata()!')); - } - - $key_cc = self::METADATA_ADDED_CCS; - $key_add_rev = self::METADATA_ADDED_REVIEWERS; - $key_rem_rev = self::METADATA_REMOVED_REVIEWERS; - $key_diff_id = self::METADATA_DIFF_ID; - - $type = $this->proxy->getTransactionType(); - - switch ($type) { - case PhabricatorTransactions::TYPE_SUBSCRIBERS: - $value = $this->proxy->getNewValue(); - if (!$value) { - $value = array(); - } - return array( - $key_cc => $value, - ); - case DifferentialTransaction::TYPE_UPDATE: - return array( - $key_diff_id => $this->proxy->getNewValue(), - ); - case PhabricatorTransactions::TYPE_EDGE: - case PhabricatorTransactions::TYPE_SUBSCRIBERS: - $old = $this->proxy->getOldValue(); - if (!$old) { - $old = array(); - } - $new = $this->proxy->getNewValue(); - if (!$new) { - $new = array(); - } - - $rem = array_diff_key($old, $new); - $add = array_diff_key($new, $old); - - if ($type == PhabricatorTransactions::TYPE_EDGE) { - return array( - $key_add_rev => array_keys($add), - $key_rem_rev => array_keys($rem), - ); - } else { - return array( - $key_cc => array_keys($add), - ); - } - default: - return array(); - } - } - - public function getContentSource() { - return $this->proxy->getContentSource(); - } - - private function getProxyComment() { - if (!$this->proxyComment) { - $this->proxyComment = new DifferentialTransactionComment(); - } - return $this->proxyComment; - } - - public function setProxyComment(DifferentialTransactionComment $proxy) { - $this->proxyComment = $proxy; - $this->proxy->attachComment($proxy); - return $this; - } - - public function setRevision(DifferentialRevision $revision) { - $this->getProxyComment()->setRevisionPHID($revision->getPHID()); - $this->proxy->setObjectPHID($revision->getPHID()); - return $this; - } - - public function giveFacebookSomeArbitraryDiff(DifferentialDiff $diff) { - $this->arbitraryDiffForFacebook = $diff; - return $this; - } - - public function getRequiredHandlePHIDs() { - switch ($this->proxy->getTransactionType()) { - case PhabricatorTransactions::TYPE_SUBSCRIBERS: - case PhabricatorTransactions::TYPE_EDGE: - return array_merge( - array_keys($this->proxy->getOldValue()), - array_keys($this->proxy->getNewValue())); - } - - return array(); - } - - public function getMarkupFieldKey($field) { - return 'DC:'.$this->getPHID(); - } - - public function newMarkupEngine($field) { - return PhabricatorMarkupEngine::newDifferentialMarkupEngine( - array( - 'differential.diff' => $this->arbitraryDiffForFacebook, - )); - } - - public function getMarkupText($field) { - return $this->getContent(); - } - - public function didMarkupText($field, $output, PhutilMarkupEngine $engine) { - return $output; - } - - public function shouldUseMarkupCache($field) { - return (bool)$this->getPHID(); - } - - public function getDateCreated() { - return $this->proxy->getDateCreated(); - } - - public function getRevisionPHID() { - return $this->proxy->getObjectPHID(); - } - - public function save() { - $this->proxy->openTransaction(); - $this->proxy - ->setViewPolicy('public') - ->setEditPolicy($this->getAuthorPHID()) - ->save(); - - if ($this->getContent() !== null || - $this->getProxyComment()->getChangesetID()) { - - $this->getProxyComment() - ->setAuthorPHID($this->getAuthorPHID()) - ->setViewPolicy('public') - ->setEditPolicy($this->getAuthorPHID()) - ->setCommentVersion(1) - ->setTransactionPHID($this->proxy->getPHID()) - ->save(); - - $this->proxy - ->setCommentVersion(1) - ->setCommentPHID($this->getProxyComment()->getPHID()) - ->save(); - } - - $this->proxy->saveTransaction(); - - return $this; - } - - public function delete() { - $this->proxy->delete(); - return $this; - } - - public function getProxyTransaction() { - return $this->proxy; - } - -}