@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Don't try to download diffs-of-diffs

Summary:
Ref T1715. When the user clicks "Download Raw Diff" in Differential, we try to build a diff of exactly what they're seeing. However:

- This doesn't work if any of the changes have multiple hunks, and fixing it seems hard.
- I suspect this diff is never actually useful anyway? And probably kind of confusing in the best case. You can't really apply it to anyhting, since you'd have to apply another diff first.

Instead, just build the right-side diff, which should align well with user expectation and doesn't suffer from the multi-hunk bug.

Some day, we could maybe add some of the fancy options in T1715.

See: <https://github.com/facebook/phabricator/issues/461>

Test Plan: Downloaded a multi-hunk diff, got the original back and applied it cleanly.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T1715

Differential Revision: https://secure.phabricator.com/D7694

+1 -32
+1 -32
src/applications/differential/controller/DifferentialRevisionViewController.php
··· 863 863 864 864 $viewer = $this->getRequest()->getUser(); 865 865 866 - $engine = new PhabricatorDifferenceEngine(); 867 - $generated_changesets = array(); 868 866 foreach ($changesets as $changeset) { 869 867 $changeset->attachHunks($changeset->loadHunks()); 870 - $right = $changeset->makeNewFile(); 871 - $choice = $changeset; 872 - $vs = idx($vs_map, $changeset->getID()); 873 - if ($vs == -1) { 874 - $left = $right; 875 - $right = $changeset->makeOldFile(); 876 - } else if ($vs) { 877 - $choice = $vs_changeset = $vs_changesets[$vs]; 878 - $vs_changeset->attachHunks($vs_changeset->loadHunks()); 879 - $left = $vs_changeset->makeNewFile(); 880 - } else { 881 - $left = $changeset->makeOldFile(); 882 - } 883 - 884 - $synthetic = $engine->generateChangesetFromFileContent( 885 - $left, 886 - $right); 887 - 888 - if (!$synthetic->getAffectedLineCount()) { 889 - $filetype = $choice->getFileType(); 890 - if ($filetype == DifferentialChangeType::FILE_TEXT || 891 - $filetype == DifferentialChangeType::FILE_SYMLINK) { 892 - continue; 893 - } 894 - } 895 - 896 - $choice->attachHunks($synthetic->getHunks()); 897 - 898 - $generated_changesets[] = $choice; 899 868 } 900 869 901 870 $diff = new DifferentialDiff(); 902 - $diff->attachChangesets($generated_changesets); 871 + $diff->attachChangesets($changesets); 903 872 $raw_changes = $diff->buildChangesList(); 904 873 $changes = array(); 905 874 foreach ($raw_changes as $changedict) {