Page MenuHomePhabricator

Detect moves and copies with some unchanged lines as moves or copies
ClosedPublic

Authored by epriestley on Mar 24 2015, 7:00 PM.
Tags
None
Referenced Files
F14066608: D12146.diff
Tue, Nov 19, 10:47 AM
F13990395: D12146.diff
Tue, Oct 22, 3:22 AM
F13990352: D12146.id29195.diff
Tue, Oct 22, 2:57 AM
F13973545: D12146.diff
Oct 18 2024, 1:22 AM
F13959678: D12146.id.diff
Oct 14 2024, 8:16 PM
Unknown Object (File)
Sep 23 2024, 9:47 AM
Unknown Object (File)
Sep 23 2024, 5:24 AM
Unknown Object (File)
Sep 23 2024, 5:00 AM
Subscribers

Details

Reviewers
btrahan
Maniphest Tasks
Restricted Maniphest Task
Commits
Restricted Diffusion Commit
rPaa310230b6bc: Detect moves and copies with some unchanged lines as moves or copies
Summary

Ref T1266. We won't detect a move/copy if fewer than 3 lines are changed.

However, you may move a block like:

Complicated Line A
Trivial Line B
Complicated Line C

...where "Trivial Line B" is something like a curly brace. If you move this block somewhere that happened to previously have a similar trivial curly brace line, we won't be able to find 3 contiguous added lines in order to detect the copy/move.

Instead, consider both changed and unchanged lines when trying to find contiguous blocks. This allows us to detect across gaps where lines were not actually changed.

This new algorithm may be too liberal (for example, we may end up incorrectly identifying moved/copied code before or after changed lines, not just between changed lines), but we can keep an eye on it and tweak it. The algorithm is better factored and better covered, now.

Test Plan
  • Added a unit test for this case.
  • Spot-checked a handful of diffs and generally saw behavior that made sense and looked better than before.

Diff Detail

Repository
rP Phabricator
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

epriestley retitled this revision from to Detect moves and copies with some unchanged lines as moves or copies.
epriestley updated this object.
epriestley edited the test plan for this revision. (Show Details)
epriestley added a reviewer: btrahan.
epriestley added a task: Restricted Maniphest Task.
btrahan edited edge metadata.
This revision is now accepted and ready to land.Mar 24 2015, 8:09 PM
This revision was automatically updated to reflect the committed changes.