#3967 SCM / Patience diff algorithm doesn't recognize file renames

v1.0.0
closed
nobody
42cc (432)
General
Cory Johns
2015-08-20
2012-03-29
Cory Johns
No

In the commit view, there is a category for "copied" which appears to be for file renames, but it doesn't work. File renames, even with 100% similarity, are treated as remove + add. We should detect renames and show diffs between the two files whenever possible. If it was a straight rename (100% similarity), a message indicating that should be displayed.

Discussion

  • Dave Brondsema

    Dave Brondsema - 2012-08-02
    • labels: --> 42cc
     
  • Igor Bondarenko - 2012-08-08

    We plan to change Commit.diffs method to mark renamed files as copied.

    Now this method looks like this:

    Allura/allura/model/repo.py:255

        def diffs(self):
            di = DiffInfoDoc.m.get(_id=self._id)
            if di is None:
                return Object(added=[], removed=[], changed=[], copied=[])
            added = []
            removed = []
            changed = []
            copied = []
            for change in di.differences:
                if change.rhs_id is None:
                    removed.append(change.name)
                elif change.lhs_id is None:
                    added.append(change.name)
                else:
                    changed.append(change.name)
            return Object(
                added=added, removed=removed,
                changed=changed, copied=copied)
    

    copied list is always empty. To fill it we can check similarity between files in removed and added lists using difflib.SequenceMatcher. If similarity is more than some threshold (say 50%, like git default) we should treat such files as renamed and show diffs between them, or just show a message if it was a straight rename (100% similarity).

     
  • Igor Bondarenko - 2012-08-08

    For now we've got working code that implements this approach but it still dirty and needs some refactoring.

     
  • Dave Brondsema

    Dave Brondsema - 2012-08-08

    Ok

     
  • Yaroslav Luzin - 2012-08-11

    closed #141, branch - 42cc_3967

     
  • Yaroslav Luzin - 2012-08-11
    • status: open --> code-review
     
  • Dave Brondsema

    Dave Brondsema - 2012-08-15
    • qa: Cory Johns
     
  • Cory Johns - 2012-08-15
    • status: code-review --> closed
    • milestone: forge-backlog --> forge-aug-24
     

Log in to post a comment.