mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-10 00:42:40 +01:00
Change patch generation for moving a file
Summary: The unix utility `patch` will not move a file (unless it is in or out of /dev/null). If a diff copies or moves a file and also makes changes to the file, the generated patch needs to list the new filename as the path to both the original and new files so the changes get written to the new file. (When arc applies this patch, it copies or moves the original as needed before running `patch`.) (This only matters for svn repos, since arc uses git commands for git repos instead of using `patch`.) Test Plan: Created an arc bundle of a diff that copied a file to a new location and made changes in both locations, and then ran arc patch with this bundle (in an svn repo) to see that it correctly patches. Reviewed By: epriestley Reviewers: epriestley, jungejason, tuomaspelkonen CC: aran, epriestley, nh Differential Revision: 813
This commit is contained in:
parent
7a72b0b4f9
commit
4c05dc3cd6
1 changed files with 11 additions and 0 deletions
|
@ -150,6 +150,17 @@ class ArcanistBundle {
|
||||||
$cur_path = '/dev/null';
|
$cur_path = '/dev/null';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// When the diff is used by `patch`, `patch` ignores what is listed as the
|
||||||
|
// current path and just makes changes to the file at the old path (unless
|
||||||
|
// the current path is '/dev/null'.
|
||||||
|
// If the old path and the current path aren't the same (and neither is
|
||||||
|
// /dev/null), this indicates the file was moved or copied. By listing
|
||||||
|
// both paths as the new file, `patch` will apply the diff to the new
|
||||||
|
// file.
|
||||||
|
if ($cur_path !== '/dev/null' && $old_path !== '/dev/null') {
|
||||||
|
$old_path = $cur_path;
|
||||||
|
}
|
||||||
|
|
||||||
$result[] = '--- '.$old_path;
|
$result[] = '--- '.$old_path;
|
||||||
$result[] = '+++ '.$cur_path;
|
$result[] = '+++ '.$cur_path;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue