~bzr-gtk/bzr-gtk/gtk2

« back to all changes in this revision

Viewing changes to diff.py

  • Committer: Vincent Ladeuil
  • Date: 2008-10-22 07:56:53 UTC
  • mto: This revision was merged to the branch mainline in revision 617.
  • Revision ID: v.ladeuil+lp@free.fr-20081022075653-10v8wlpmisbotnjg
Fix bug #286834 bu handling 'missing' files corner case.

* tests/test_diff.py:
(Test_IterChangesToStatus.test_status_missing_file, )
(Test_IterChangesToStatus.test_status_removed): Add tests.

* diff.py:
(iter_changes_to_status): Handle 'missing' files corner case.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- coding: UTF-8 -*-
2
1
"""Difference window.
3
2
 
4
3
This module contains the code to manage the diff window which shows
5
4
the changes made between two revisions on a branch.
6
5
"""
7
6
 
8
 
__copyright__ = "Copyright © 2005 Canonical Ltd."
 
7
__copyright__ = "Copyright 2005 Canonical Ltd."
9
8
__author__    = "Scott James Remnant <scott@ubuntu.com>"
10
9
 
11
10
 
635
634
    renamed_and_modified = 'renamed and modified'
636
635
    modified = 'modified'
637
636
    kind_changed = 'kind changed'
 
637
    missing = 'missing'
638
638
 
639
639
    # TODO: Handle metadata changes
640
640
 
655
655
                    source_marker = ''
656
656
                else:
657
657
                    source_marker = osutils.kind_marker(kinds[0])
 
658
 
658
659
                if kinds[1] is None:
659
 
                    assert kinds[0] is not None
660
 
                    marker = osutils.kind_marker(kinds[0])
 
660
                    if kinds[0] is None:
 
661
                        # We assume bzr will flag only files in that case,
 
662
                        # there may be a bzr bug there as only files seems to
 
663
                        # not receive any kind.
 
664
                        marker = osutils.kind_marker('file')
 
665
                    else:
 
666
                        marker = osutils.kind_marker(kinds[0])
661
667
                else:
662
668
                    marker = osutils.kind_marker(kinds[1])
663
669
 
665
671
                if real_path is None:
666
672
                    real_path = paths[0]
667
673
                assert real_path is not None
668
 
                display_path = real_path + marker
669
674
 
670
675
                present_source = versioned[0] and kinds[0] is not None
671
676
                present_target = versioned[1] and kinds[1] is not None
672
677
 
673
 
                if present_source != present_target:
 
678
                if kinds[0] is None and kinds[1] is None:
 
679
                    change_type = missing
 
680
                    display_path = real_path + marker
 
681
                elif present_source != present_target:
674
682
                    if present_target:
675
683
                        change_type = added
676
684
                    else:
677
685
                        assert present_source
678
686
                        change_type = removed
 
687
                    display_path = real_path + marker
679
688
                elif names[0] != names[1] or parent_ids[0] != parent_ids[1]:
680
689
                    # Renamed
681
690
                    if changed_content or executables[0] != executables[1]:
691
700
                                    + ' => ' + paths[1] + marker)
692
701
                elif changed_content or executables[0] != executables[1]:
693
702
                    change_type = modified
 
703
                    display_path = real_path + marker
694
704
                else:
695
705
                    assert False, "How did we get here?"
696
706