1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-09-20 08:58:55 +02:00

Properly handle file moves in arc patch under SVN

Summary:
If the file has no changes (probably because it has been moved or copied) then we fail.

Fixes T1708, fixes T1559.

Test Plan:
  $ svn mv a b
  $ arc diff --only
  $ svn revert a b
  $ arc patch --diff # of created diff

Reviewers: epriestley, btrahan

Reviewed By: btrahan

CC: aran, Korvin

Maniphest Tasks: T1559, T1708

Differential Revision: https://secure.phabricator.com/D3526
This commit is contained in:
vrana 2012-09-19 15:59:39 -07:00
parent 6929f4e57e
commit 6bd2b372f5
2 changed files with 29 additions and 13 deletions

View file

@ -212,6 +212,11 @@ final class ArcanistBundle {
$changes = $this->getChanges();
foreach ($changes as $change) {
$hunk_changes = $this->buildHunkChanges($change->getHunks());
if (!$hunk_changes) {
continue;
}
$old_path = $this->getOldPath($change);
$cur_path = $this->getCurrentPath($change);
@ -245,7 +250,11 @@ final class ArcanistBundle {
$result[] = '--- '.$old_path;
$result[] = '+++ '.$cur_path;
$result[] = $this->buildHunkChanges($change->getHunks());
$result[] = $hunk_changes;
}
if (!$result) {
return '';
}
$diff = implode("\n", $result)."\n";

View file

@ -532,10 +532,8 @@ EOTEXT
break;
}
if ($should_patch) {
if ($change->getHunks()) {
$cbundle = ArcanistBundle::newFromChanges(array($change));
$patches[$change->getCurrentPath()] = $cbundle->toUnifiedDiff();
}
$cbundle = ArcanistBundle::newFromChanges(array($change));
$patches[$change->getCurrentPath()] = $cbundle->toUnifiedDiff();
$prop_old = $change->getOldProperties();
$prop_new = $change->getNewProperties();
$props = $prop_old + $prop_new;
@ -601,15 +599,24 @@ EOTEXT
}
foreach ($patches as $path => $patch) {
$tmp = new TempFile();
Filesystem::writeFile($tmp, $patch);
$err = null;
passthru(
csprintf(
'(cd %s; patch -p0 < %s)',
$repository_api->getPath(),
$tmp),
$err);
if ($patch) {
$tmp = new TempFile();
Filesystem::writeFile($tmp, $patch);
passthru(
csprintf(
'(cd %s; patch -p0 < %s)',
$repository_api->getPath(),
$tmp),
$err);
} else {
passthru(
csprintf(
'(cd %s; touch %s)',
$repository_api->getPath(),
$path),
$err);
}
if ($err) {
$patch_err = max($patch_err, $err);
}