Page MenuHomePhabricator

Extract scope line selection logic from the diff rendering engine so it can reasonably be iterated on
ClosedPublic

Authored by epriestley on Feb 14 2019, 6:11 PM.
Tags
None
Referenced Files
F13145258: D20171.diff
Fri, May 3, 8:52 AM
F13137339: D20171.id48206.diff
Thu, May 2, 6:23 PM
F13136684: D20171.id48156.diff
Thu, May 2, 3:06 PM
Unknown Object (File)
Thu, Apr 25, 2:39 AM
Unknown Object (File)
Sat, Apr 20, 4:35 PM
Unknown Object (File)
Thu, Apr 11, 9:56 AM
Unknown Object (File)
Mar 28 2024, 4:16 PM
Unknown Object (File)
Mar 16 2024, 12:02 AM
Subscribers
None

Details

Summary

Ref T13249. Ref T11738. See PHI985. Currently, we have a crude heuristic for guessing what line in a source file provides the best context.

We get it wrong in a lot of cases, sometimes selecting very silly lines like "{". Although we can't always pick the same line a human would pick, we can pile on heuristics until this is less frequently completely wrong and perhaps eventually get it to work fairly well most of the time.

Pull the logic for this into a separate standalone class and make it testable to prepare for adding heuristics.

Test Plan

Ran unit tests, browsed various files in the web UI and saw as-good-or-better context selection.

Diff Detail

Repository
rP Phabricator
Branch
scope1
Lint
Lint Passed
SeverityLocationCodeMessage
Advicesrc/infrastructure/diff/PhabricatorDiffScopeEngine.php:115XHP16TODO Comment
Unit
Tests Passed
Build Status
Buildable 22000
Build 30052: Run Core Tests
Build 30051: arc lint + arc unit

Event Timeline

This revision is now accepted and ready to land.Feb 19 2019, 6:19 PM

This and two other followups also all have some flavor of "convert tabs to spaces" or vice versa. I suspect we can have fewer copies of this code eventually, but since it's like 10 lines of code I'm not worrying about it too much for now.

This revision was automatically updated to reflect the committed changes.