683
683
for (oldpath, newpath), (oldmode, newmode), (oldsha, newsha) in changes:
684
684
if newpath == b'' and not include_root:
686
if oldpath is not None:
687
oldpath_decoded = oldpath.decode('utf-8')
687
689
oldpath_decoded = None
690
if newpath is not None:
691
newpath_decoded = newpath.decode('utf-8')
689
oldpath_decoded = oldpath.decode('utf-8')
691
693
newpath_decoded = None
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))):
703
if oldpath_decoded is None:
704
fileid = new_fileid_map.lookup_file_id(newpath_decoded)
713
oldexe = mode_is_executable(oldmode)
714
oldkind = mode_kind(oldmode)
718
if oldpath_decoded == u'':
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:
732
newversioned = (newpath_decoded not in target_extras)
734
newexe = mode_is_executable(newmode)
735
newkind = mode_kind(newmode)
739
if newpath_decoded == u'':
743
newparentpath, newname = osutils.split(newpath_decoded)
744
newparent = mapping.generate_file_id(newparentpath)
702
745
if mapping.is_special_file(oldpath):
704
747
if mapping.is_special_file(newpath):
706
749
if oldpath is None and newpath is None:
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)
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),
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):
727
file_id = new_fileid_map.lookup_file_id(newpath_decoded)
729
(newpath_decoded, file_id, mode_kind(newmode),
730
(oldsha != newsha), (oldmode != newmode)))
767
ret.modified.append(change)
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)
736
771
implicit_dirs = {b''}
737
772
for path, kind in added:
743
778
if kind == 'directory' and path not in implicit_dirs:
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)))
749
789
file_id = new_fileid_map.lookup_file_id(path_decoded)
750
ret.added.append((path_decoded, file_id, kind))
791
_mod_tree.TreeChange(
792
file_id, (None, path_decoded), True,
795
(None, basename), (None, kind), (None, False)))