mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-12-23 05:50:54 +01:00
When converting a file to a binary, populate the binary's data
Summary: Currently, we prompt the user to mark non-UTF8 files as binary, but don't actually attach the data to the change when they do. This means we don't upload the data, and can't patch it later. A simple reproduction case is to build a test file (I used one with bytes from 1..255): $ # Don't include \0, since Git treats that specially. $ ./echo_every_byte_from_1_to_255_inclusive.erl > example.txt Then add it: $ git add example.txt $ git commit -a -m derp $ arc diff --only HEAD^ You'll be prompted to convert the file to binary: Do you want to mark this file as binary and continue? [Y/n] y Before this patch, that would be followed by: Uploading 0 files... ...which is incorrect; we need to upload the new data. After this patch, this shows: Uploading 1 files... ...which is also incorrect, but only grammatically. Diffs created after this patch apply back cleanly with `arc patch` and restore the file properly. Test Plan: Followed instructions above, restoring a textual binary conversion by using `arc patch`. Reviewers: zeeg, btrahan Reviewed By: btrahan CC: aran Differential Revision: https://secure.phabricator.com/D6815
This commit is contained in:
parent
a28d4ff3e4
commit
3ad72195bf
2 changed files with 17 additions and 5 deletions
|
@ -234,7 +234,18 @@ final class ArcanistDiffChange {
|
|||
return $line_map;
|
||||
}
|
||||
|
||||
public function convertToBinaryChange() {
|
||||
public function convertToBinaryChange(ArcanistRepositoryAPI $api) {
|
||||
|
||||
// Fill in the binary data from the working copy.
|
||||
|
||||
$this->setOriginalFileData(
|
||||
$api->getOriginalFileData(
|
||||
$this->getOldPath()));
|
||||
|
||||
$this->setCurrentFileData(
|
||||
$api->getCurrentFileData(
|
||||
$this->getCurrentPath()));
|
||||
|
||||
$this->hunks = array();
|
||||
$this->setFileType(ArcanistDiffChangeType::FILE_BINARY);
|
||||
return $this;
|
||||
|
|
|
@ -994,7 +994,7 @@ EOTEXT
|
|||
"{$byte_warning} If the file is not a text file, you can ".
|
||||
"mark it 'binary'. Mark this file as 'binary' and continue?";
|
||||
if (phutil_console_confirm($confirm)) {
|
||||
$change->convertToBinaryChange();
|
||||
$change->convertToBinaryChange($repository_api);
|
||||
} else {
|
||||
throw new ArcanistUsageException(
|
||||
"Aborted generation of gigantic diff.");
|
||||
|
@ -1080,7 +1080,7 @@ EOTEXT
|
|||
throw new ArcanistUsageException("Aborted workflow to fix UTF-8.");
|
||||
} else {
|
||||
foreach ($utf8_problems as $change) {
|
||||
$change->convertToBinaryChange();
|
||||
$change->convertToBinaryChange($repository_api);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2477,8 +2477,9 @@ EOTEXT
|
|||
$change->setMetadata("{$type}:file:size", $size);
|
||||
if ($spec['data'] === null) {
|
||||
// This covers the case where a file was added or removed; we don't
|
||||
// need to upload it. (This is distinct from an empty file, which we
|
||||
// do upload.)
|
||||
// need to upload the other half of it (e.g., the old file data for
|
||||
// a file which was just added). This is distinct from an empty
|
||||
// file, which we do upload.
|
||||
unset($need_upload[$key]);
|
||||
continue;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue