mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-19 13:22:42 +01:00
Maniphest - upgrade merging to real transactions
Summary: see title. Ref T5875. Test Plan: Merged one task into another task - verified transactions on both tasks. Merged two tasks into another task - verified transactions on all three tasks. Checked out my feed and saw MERGE_INTO stories and MERGE_FROM stories. Reviewers: epriestley Reviewed By: epriestley Subscribers: epriestley, Korvin Maniphest Tasks: T5875 Differential Revision: https://secure.phabricator.com/D10427
This commit is contained in:
parent
f4f8e9bb96
commit
fdccb0f405
4 changed files with 84 additions and 28 deletions
|
@ -26,6 +26,8 @@ final class ManiphestTransactionEditor
|
|||
$types[] = ManiphestTransaction::TYPE_CCS;
|
||||
$types[] = ManiphestTransaction::TYPE_SUBPRIORITY;
|
||||
$types[] = ManiphestTransaction::TYPE_PROJECT_COLUMN;
|
||||
$types[] = ManiphestTransaction::TYPE_MERGED_INTO;
|
||||
$types[] = ManiphestTransaction::TYPE_MERGED_FROM;
|
||||
$types[] = ManiphestTransaction::TYPE_UNBLOCK;
|
||||
$types[] = PhabricatorTransactions::TYPE_VIEW_POLICY;
|
||||
$types[] = PhabricatorTransactions::TYPE_EDIT_POLICY;
|
||||
|
@ -67,6 +69,9 @@ final class ManiphestTransactionEditor
|
|||
return $xaction->getOldValue();
|
||||
case ManiphestTransaction::TYPE_SUBPRIORITY:
|
||||
return $object->getSubpriority();
|
||||
case ManiphestTransaction::TYPE_MERGED_INTO:
|
||||
case ManiphestTransaction::TYPE_MERGED_FROM:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -86,6 +91,8 @@ final class ManiphestTransactionEditor
|
|||
case ManiphestTransaction::TYPE_DESCRIPTION:
|
||||
case ManiphestTransaction::TYPE_SUBPRIORITY:
|
||||
case ManiphestTransaction::TYPE_PROJECT_COLUMN:
|
||||
case ManiphestTransaction::TYPE_MERGED_INTO:
|
||||
case ManiphestTransaction::TYPE_MERGED_FROM:
|
||||
case ManiphestTransaction::TYPE_UNBLOCK:
|
||||
return $xaction->getNewValue();
|
||||
}
|
||||
|
@ -161,6 +168,11 @@ final class ManiphestTransactionEditor
|
|||
case ManiphestTransaction::TYPE_PROJECT_COLUMN:
|
||||
// these do external (edge) updates
|
||||
return;
|
||||
case ManiphestTransaction::TYPE_MERGED_INTO:
|
||||
$object->setStatus(ManiphestTaskStatus::getDuplicateStatus());
|
||||
return;
|
||||
case ManiphestTransaction::TYPE_MERGED_FROM:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,8 @@ final class ManiphestTransaction
|
|||
const TYPE_EDGE = 'edge';
|
||||
const TYPE_SUBPRIORITY = 'subpriority';
|
||||
const TYPE_PROJECT_COLUMN = 'projectcolumn';
|
||||
const TYPE_MERGED_INTO = 'mergedinto';
|
||||
const TYPE_MERGED_FROM = 'mergedfrom';
|
||||
|
||||
const TYPE_UNBLOCK = 'unblock';
|
||||
|
||||
|
@ -96,6 +98,12 @@ final class ManiphestTransaction
|
|||
$phids[] = $new['projectPHID'];
|
||||
$phids[] = head($new['columnPHIDs']);
|
||||
break;
|
||||
case self::TYPE_MERGED_INTO:
|
||||
$phids[] = $new;
|
||||
break;
|
||||
case self::TYPE_MERGED_FROM:
|
||||
$phids = array_merge($phids, $new);
|
||||
break;
|
||||
case self::TYPE_EDGE:
|
||||
$phids = array_mergev(
|
||||
array(
|
||||
|
@ -290,6 +298,10 @@ final class ManiphestTransaction
|
|||
return pht('Blocker');
|
||||
}
|
||||
|
||||
case self::TYPE_MERGED_INTO:
|
||||
case self::TYPE_MERGED_FROM:
|
||||
return pht('Merged');
|
||||
|
||||
}
|
||||
|
||||
return parent::getActionName();
|
||||
|
@ -334,6 +346,10 @@ final class ManiphestTransaction
|
|||
case self::TYPE_PROJECT_COLUMN:
|
||||
return 'fa-columns';
|
||||
|
||||
case self::TYPE_MERGED_INTO:
|
||||
case self::TYPE_MERGED_FROM:
|
||||
return 'fa-compress';
|
||||
|
||||
case self::TYPE_PRIORITY:
|
||||
if ($old == ManiphestTaskPriority::getDefaultPriority()) {
|
||||
return 'fa-arrow-right';
|
||||
|
@ -571,7 +587,22 @@ final class ManiphestTransaction
|
|||
$this->renderHandleLink($author_phid),
|
||||
$this->renderHandleLink($column_phid),
|
||||
$this->renderHandleLink($project_phid));
|
||||
break;
|
||||
break;
|
||||
|
||||
case self::TYPE_MERGED_INTO:
|
||||
return pht(
|
||||
'%s merged this task into %s.',
|
||||
$this->renderHandleLink($author_phid),
|
||||
$this->renderHandleLink($new));
|
||||
break;
|
||||
|
||||
case self::TYPE_MERGED_FROM:
|
||||
return pht(
|
||||
'%s merged %d task(s): %s.',
|
||||
$this->renderHandleLink($author_phid),
|
||||
count($new),
|
||||
$this->renderHandleList($new));
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
|
@ -815,7 +846,22 @@ final class ManiphestTransaction
|
|||
$this->renderHandleLink($object_phid),
|
||||
$this->renderHandleLink($column_phid),
|
||||
$this->renderHandleLink($project_phid));
|
||||
break;
|
||||
|
||||
case self::TYPE_MERGED_INTO:
|
||||
return pht(
|
||||
'%s merged task %s into %s.',
|
||||
$this->renderHandleLink($author_phid),
|
||||
$this->renderHandleLink($object_phid),
|
||||
$this->renderHandleLink($new));
|
||||
|
||||
case self::TYPE_MERGED_FROM:
|
||||
return pht(
|
||||
'%s merged %d task(s) %s into %s.',
|
||||
$this->renderHandleLink($author_phid),
|
||||
count($new),
|
||||
$this->renderHandleList($new),
|
||||
$this->renderHandleLink($object_phid));
|
||||
|
||||
}
|
||||
|
||||
return parent::getTitleForFeed($story);
|
||||
|
|
|
@ -154,10 +154,6 @@ final class PhabricatorSearchAttachController
|
|||
->setContinueOnNoEffect(true)
|
||||
->setContinueOnMissingFields(true);
|
||||
|
||||
$task_names = array();
|
||||
|
||||
$merge_into_name = 'T'.$task->getID();
|
||||
|
||||
$cc_vector = array();
|
||||
$cc_vector[] = $task->getCCPHIDs();
|
||||
foreach ($targets as $target) {
|
||||
|
@ -166,42 +162,30 @@ final class PhabricatorSearchAttachController
|
|||
$target->getAuthorPHID(),
|
||||
$target->getOwnerPHID());
|
||||
|
||||
$close_task = id(new ManiphestTransaction())
|
||||
->setTransactionType(ManiphestTransaction::TYPE_STATUS)
|
||||
->setNewValue(ManiphestTaskStatus::getDuplicateStatus());
|
||||
|
||||
$merge_comment = id(new ManiphestTransaction())
|
||||
->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)
|
||||
->attachComment(
|
||||
id(new ManiphestTransactionComment())
|
||||
->setContent("\xE2\x9C\x98 Merged into {$merge_into_name}."));
|
||||
$merged_into_txn = id(new ManiphestTransaction())
|
||||
->setTransactionType(ManiphestTransaction::TYPE_MERGED_INTO)
|
||||
->setNewValue($task->getPHID());
|
||||
|
||||
$editor->applyTransactions(
|
||||
$target,
|
||||
array(
|
||||
$close_task,
|
||||
$merge_comment,
|
||||
));
|
||||
array($merged_into_txn));
|
||||
|
||||
$task_names[] = 'T'.$target->getID();
|
||||
}
|
||||
$all_ccs = array_mergev($cc_vector);
|
||||
$all_ccs = array_filter($all_ccs);
|
||||
$all_ccs = array_unique($all_ccs);
|
||||
|
||||
$task_names = implode(', ', $task_names);
|
||||
|
||||
$add_ccs = id(new ManiphestTransaction())
|
||||
->setTransactionType(ManiphestTransaction::TYPE_CCS)
|
||||
->setNewValue($all_ccs);
|
||||
|
||||
$merged_comment = id(new ManiphestTransaction())
|
||||
->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)
|
||||
->attachComment(
|
||||
id(new ManiphestTransactionComment())
|
||||
->setContent("\xE2\x97\x80 Merged tasks: {$task_names}."));
|
||||
$merged_from_txn = id(new ManiphestTransaction())
|
||||
->setTransactionType(ManiphestTransaction::TYPE_MERGED_FROM)
|
||||
->setNewValue(mpull($targets, 'getPHID'));
|
||||
|
||||
$editor->applyTransactions($task, array($add_ccs, $merged_comment));
|
||||
$editor->applyTransactions(
|
||||
$task,
|
||||
array($add_ccs, $merged_from_txn));
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
|
|
@ -341,6 +341,20 @@ abstract class PhabricatorBaseEnglishTranslation
|
|||
),
|
||||
),
|
||||
|
||||
'%s merged %d task(s): %s.' => array(
|
||||
array(
|
||||
'%s merged a task: %3$s.',
|
||||
'%s merged tasks: %3$s.',
|
||||
),
|
||||
),
|
||||
|
||||
'%s merged %d task(s) %s into %s.' => array(
|
||||
array(
|
||||
'%s merged %3$s into %4$s.',
|
||||
'%s merged tasks %3$s into %4$s.',
|
||||
),
|
||||
),
|
||||
|
||||
'%s edited voting user(s), added %d: %s; removed %d: %s.' =>
|
||||
'%s edited voting users, added: %3$s; removed: %5$s',
|
||||
|
||||
|
|
Loading…
Reference in a new issue