/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/git/tree.py

  • Committer: Jelmer Vernooij
  • Date: 2019-06-29 19:50:18 UTC
  • mto: This revision was merged to the branch mainline in revision 7389.
  • Revision ID: jelmer@jelmer.uk-20190629195018-jaldh0dliq1e79oh
TreeDelta holds TreeChange objects rather than tuples of various sizes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
683
683
    for (oldpath, newpath), (oldmode, newmode), (oldsha, newsha) in changes:
684
684
        if newpath == b'' and not include_root:
685
685
            continue
686
 
        if oldpath is None:
 
686
        if oldpath is not None:
 
687
            oldpath_decoded = oldpath.decode('utf-8')
 
688
        else:
687
689
            oldpath_decoded = None
 
690
        if newpath is not None:
 
691
            newpath_decoded = newpath.decode('utf-8')
688
692
        else:
689
 
            oldpath_decoded = oldpath.decode('utf-8')
690
 
        if newpath is None:
691
693
            newpath_decoded = None
692
 
        else:
693
 
            newpath_decoded = newpath.decode('utf-8')
694
694
        if not (specific_files is None or
695
695
                (oldpath is not None and
696
696
                    osutils.is_inside_or_parent_of_any(
699
699
                    osutils.is_inside_or_parent_of_any(
700
700
                        specific_files, newpath_decoded))):
701
701
            continue
 
702
 
 
703
        if oldpath_decoded is None:
 
704
            fileid = new_fileid_map.lookup_file_id(newpath_decoded)
 
705
            oldexe = None
 
706
            oldkind = None
 
707
            oldname = None
 
708
            oldparent = None
 
709
            oldversioned = False
 
710
        else:
 
711
            oldversioned = True
 
712
            if oldmode:
 
713
                oldexe = mode_is_executable(oldmode)
 
714
                oldkind = mode_kind(oldmode)
 
715
            else:
 
716
                oldexe = False
 
717
                oldkind = None
 
718
            if oldpath_decoded == u'':
 
719
                oldparent = None
 
720
                oldname = u''
 
721
            else:
 
722
                (oldparentpath, oldname) = osutils.split(oldpath_decoded)
 
723
                oldparent = mapping.generate_file_id(oldparentpath)
 
724
            fileid = old_fileid_map.lookup_file_id(oldpath_decoded)
 
725
        if newpath_decoded is None:
 
726
            newexe = None
 
727
            newkind = None
 
728
            newname = None
 
729
            newparent = None
 
730
            newversioned = False
 
731
        else:
 
732
            newversioned = (newpath_decoded not in target_extras)
 
733
            if newmode:
 
734
                newexe = mode_is_executable(newmode)
 
735
                newkind = mode_kind(newmode)
 
736
            else:
 
737
                newexe = False
 
738
                newkind = None
 
739
            if newpath_decoded == u'':
 
740
                newparent = None
 
741
                newname = u''
 
742
            else:
 
743
                newparentpath, newname = osutils.split(newpath_decoded)
 
744
                newparent = mapping.generate_file_id(newparentpath)
702
745
        if mapping.is_special_file(oldpath):
703
746
            oldpath = None
704
747
        if mapping.is_special_file(newpath):
705
748
            newpath = None
706
749
        if oldpath is None and newpath is None:
707
750
            continue
 
751
        change = _mod_tree.TreeChange(
 
752
            fileid, (oldpath_decoded, newpath_decoded), (oldsha != newsha),
 
753
            (oldversioned, newversioned),
 
754
            (oldparent, newparent), (oldname, newname),
 
755
            (oldkind, newkind), (oldexe, newexe))
708
756
        if oldpath is None:
709
 
            added.append((newpath, mode_kind(newmode)))
 
757
            added.append((newpath, newkind))
710
758
        elif newpath is None or newmode == 0:
711
 
            file_id = old_fileid_map.lookup_file_id(oldpath_decoded)
712
 
            ret.removed.append((oldpath_decoded, file_id, mode_kind(oldmode)))
 
759
            ret.removed.append(change)
713
760
        elif oldpath != newpath:
714
 
            file_id = old_fileid_map.lookup_file_id(oldpath_decoded)
715
 
            ret.renamed.append(
716
 
                (oldpath_decoded, newpath.decode('utf-8'), file_id,
717
 
                 mode_kind(newmode), (oldsha != newsha),
718
 
                 (oldmode != newmode)))
 
761
            ret.renamed.append(change)
719
762
        elif mode_kind(oldmode) != mode_kind(newmode):
720
 
            file_id = new_fileid_map.lookup_file_id(newpath_decoded)
721
 
            ret.kind_changed.append(
722
 
                (newpath_decoded, file_id, mode_kind(oldmode),
723
 
                 mode_kind(newmode)))
 
763
            ret.kind_changed.append(change)
724
764
        elif oldsha != newsha or oldmode != newmode:
725
765
            if stat.S_ISDIR(oldmode) and stat.S_ISDIR(newmode):
726
766
                continue
727
 
            file_id = new_fileid_map.lookup_file_id(newpath_decoded)
728
 
            ret.modified.append(
729
 
                (newpath_decoded, file_id, mode_kind(newmode),
730
 
                 (oldsha != newsha), (oldmode != newmode)))
 
767
            ret.modified.append(change)
731
768
        else:
732
 
            file_id = new_fileid_map.lookup_file_id(newpath_decoded)
733
 
            ret.unchanged.append(
734
 
                (newpath_decoded, file_id, mode_kind(newmode)))
 
769
            ret.unchanged.append(change)
735
770
 
736
771
    implicit_dirs = {b''}
737
772
    for path, kind in added:
743
778
        if kind == 'directory' and path not in implicit_dirs:
744
779
            continue
745
780
        path_decoded = osutils.normalized_filename(path)[0]
 
781
        parent_path, basename = osutils.split(path_decoded)
 
782
        parent_id = new_fileid_map.lookup_file_id(parent_path)
746
783
        if path in target_extras:
747
 
            ret.unversioned.append((path_decoded, None, kind))
 
784
            ret.unversioned.append(_mod_tree.TreeChange(
 
785
                None, (None, path_decoded),
 
786
                True, (False, False), (None, parent_id),
 
787
                (None, basename), (None, kind), (None, False)))
748
788
        else:
749
789
            file_id = new_fileid_map.lookup_file_id(path_decoded)
750
 
            ret.added.append((path_decoded, file_id, kind))
 
790
            ret.added.append(
 
791
                _mod_tree.TreeChange(
 
792
                    file_id, (None, path_decoded), True,
 
793
                    (False, True),
 
794
                    (None, parent_id),
 
795
                    (None, basename), (None, kind), (None, False)))
751
796
 
752
797
    return ret
753
798