Page MenuHomePhabricator

strange "moved from" signal in [Phriction] diff
Open, Needs TriagePublic

Description

in https://secure.phabricator.com/phriction/diff/328/?l=18&r=19:

pasted_file (409×1 px, 67 KB)

It reports line 73 as "moved from line 73," which is... not technically accurate.
I think it had some white-space removed from it's end.

Event Timeline

avivey raised the priority of this task from to Needs Triage.
avivey updated the task description. (Show Details)
avivey added a subscriber: avivey.

I think the root cause for this is a bit complicated to explain, but basically we try to match this as a move:

+ Moved line 1
  Unchanged line 2
+ Moved line 3

This lets us detect moves if there's something like a "}" in the middle of the block and the old code happened to also have that same common line.

However, I think we're currently detecting unchanged lines as valid parts of a block even if they aren't surrounded by moved lines, so we do something like this:

  Unchanged line 1
  Unchanged line 2
+ Moved Line 3

And incorrectly decide that's a perfectly acceptable three-line block of moved code.

There's a bunch of test coverage for this so it's a pretty straightforward fix.

I think it had some white-space removed from its end.

This is somewhat obscured in the screenshot, but is the key to the behavior:

Screen Shot 2019-02-20 at 5.20.57 AM.png (124×1 px, 44 KB)

We normally don't detect copies on lines that haven't changed, and don't detect copies from lines that are different. But whitespace-only changes are a special case that skips past both of these rules.

It's not immediately obvious to me how to fix this without breaking anything else, but I'm also not having a particularly good brain day today.