~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/shelf_ui.py

  • Committer: Aaron Bentley
  • Date: 2009-08-14 16:30:40 UTC
  • mto: (4603.1.22 shelve-editor)
  • mto: This revision was merged to the branch mainline in revision 4795.
  • Revision ID: aaron@aaronbentley.com-20090814163040-45zf4jo18ui670gs
Provide a reasonable count of changes when file edited.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
    errors,
28
28
    osutils,
29
29
    patches,
 
30
    patiencediff,
30
31
    shelf,
31
32
    textfile,
32
33
    trace,
334
335
        return lines, change_count
335
336
 
336
337
    def _edit_file(self, creator, file_id, differ):
 
338
        work_tree_lines = creator.work_tree.get_file_lines(file_id)
337
339
        lines = osutils.split_lines(differ.edit_file(file_id))
338
 
        return lines, len(lines)
 
340
        return lines, self._count_changed_regions(work_tree_lines, lines)
 
341
 
 
342
    @staticmethod
 
343
    def _count_changed_regions(old_lines, new_lines):
 
344
        matcher = patiencediff.PatienceSequenceMatcher(None, old_lines,
 
345
                                                       new_lines)
 
346
        blocks = matcher.get_matching_blocks()
 
347
        return len(blocks) - 2
339
348
 
340
349
 
341
350
class Unshelver(object):