mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-22 06:42:41 +01:00
Decompose TYPE_MULTICOPY changes into a MOVE_HERE plus one or more COPY_HERE
Summary: See T419 for some philosophical musing on this. The "ideal" way to represent these changes is two or more COPY_HERE plus a DELETE, but we can't build the DELETE patch yet. Just turn one of the COPY_HERE changes into a MOVE_HERE. While less idealistic, I think this should always work. Test Plan: This seemed to cleanly apply TenXer D265. TenXer guys, can you confirm that this makes it actually patch correctly? Reviewers: jonathanhester, bizrad6, kdeggelman, jungejason, btrahan Reviewed By: jungejason CC: aran, jonathanhester, jungejason, epriestley Maniphest Tasks: T419 Differential Revision: https://secure.phabricator.com/D1270
This commit is contained in:
parent
ecc8fb13a8
commit
cf00c44cc3
1 changed files with 44 additions and 0 deletions
|
@ -207,6 +207,50 @@ class ArcanistBundle {
|
|||
public function toGitPatch() {
|
||||
$result = array();
|
||||
$changes = $this->getChanges();
|
||||
|
||||
foreach (array_keys($changes) as $multicopy_key) {
|
||||
$multicopy_change = $changes[$multicopy_key];
|
||||
|
||||
$type = $multicopy_change->getType();
|
||||
if ($type != ArcanistDiffChangeType::TYPE_MULTICOPY) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Decompose MULTICOPY into one MOVE_HERE and several COPY_HERE because
|
||||
// we need more information than we have in order to build a delete patch
|
||||
// and represent it as a bunch of COPY_HERE plus a delete. For details,
|
||||
// see T419.
|
||||
|
||||
// Basically, MULTICOPY means there are 2 or more corresponding COPY_HERE
|
||||
// changes, so find one of them arbitrariy and turn it into a MOVE_HERE.
|
||||
|
||||
// TODO: We might be able to do this more cleanly after T230 is resolved.
|
||||
|
||||
$decompose_okay = false;
|
||||
foreach ($changes as $change_key => $change) {
|
||||
if ($change->getType() != ArcanistDiffChangeType::TYPE_COPY_HERE) {
|
||||
continue;
|
||||
}
|
||||
if ($change->getOldPath() != $multicopy_change->getCurrentPath()) {
|
||||
continue;
|
||||
}
|
||||
$decompose_okay = true;
|
||||
$change = clone $change;
|
||||
$change->setType(ArcanistDiffChangeType::TYPE_MOVE_HERE);
|
||||
$changes[$change_key] = $change;
|
||||
|
||||
// The multicopy is now fully represented by MOVE_HERE plus one or more
|
||||
// COPY_HERE, so throw it away.
|
||||
unset($changes[$multicopy_key]);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!$decompose_okay) {
|
||||
throw new Exception(
|
||||
"Failed to decompose multicopy changeset in order to generate diff.");
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($changes as $change) {
|
||||
$type = $change->getType();
|
||||
$file_type = $change->getFileType();
|
||||
|
|
Loading…
Reference in a new issue