Move detection – advanced bits

Wednesday, December 21, 2011 1 Comments

Move detection is one of the big features in 4.0, as I’m sure you’re already aware of.

It has been implemented on top of the same underlying technology we use for Xdiff and Xmerge.

The point is: you just move a file on your workspace without issuing a “cm mv” operation (command line, GUI or through a plugin), and later Plastic is able to “detect” the move happened.

How it works

The principles of move detection are quite easy: Plastic has a list of the files (stored under .plastic/plastic.wktree file on the workspace) that are “controlled” under the workspace. Then you decide to look for changes:
  • If a file on the workspace is not on the list: then it is proposed as an “added” candidate
  • If a file is on the list but not on the workspace: then it is proposed as a “deleted” candidate

    How the “moves” are detected? The “added candidates” are matched with the “deleted candidates” and if they’re “similar enough” then they’re proposed as “moved”.

    Let’s make it more complicated

    What if foo.c is something like the following?

    And we rename it to bar.c and modify it this way:

    The file was so small that this little change will make the two versions less than 90% different, so “pending changes” view will look like this:

    As you can see plastic detects a “potential add” and a “potential delete”.

    Matching manually

    Right click on the “potentially added” file and select “search matches”:

    And then the “matching” dialog will show up. You can slide the similarity bar until the candidate appears:

    And once you “accept the selected match”, the “pending changes view” will reflect the move:
  • 1 comment:

    1. > "less than 90% different"
      Shouldn't that be reversed since the changes was to different to be detected as a move?

      ReplyDelete