403
403
posixpath.basename(from_dir), mode, hexsha)
404
404
if from_dir != "" or include_root:
405
405
yield (from_dir, "V", root_ie.kind, root_ie.file_id, root_ie)
407
407
if root_ie.kind == 'directory':
408
todo.add((store, from_dir.encode("utf-8"), hexsha, root_ie.file_id))
408
todo.append((store, from_dir.encode("utf-8"), hexsha, root_ie.file_id))
410
410
(store, path, hexsha, parent_id) = todo.pop()
411
411
tree = store[hexsha]
416
416
if stat.S_ISDIR(mode):
417
417
ie = self._get_dir_ie(child_path, parent_id)
419
todo.add((store, child_path, hexsha, ie.file_id))
419
todo.append((store, child_path, hexsha, ie.file_id))
421
421
ie = self._get_file_ie(store, child_path, name, mode, hexsha, parent_id)
422
422
yield child_path.decode('utf-8'), "V", ie.kind, ie.file_id, ie
424
424
def _get_file_ie(self, store, path, name, mode, hexsha, parent_id):
425
if type(path) is not bytes:
425
if not isinstance(path, bytes):
426
426
raise TypeError(path)
427
if type(name) is not bytes:
427
if not isinstance(name, bytes):
428
428
raise TypeError(name)
429
429
kind = mode_kind(mode)
430
path = path.decode('utf-8')
431
name = name.decode("utf-8")
430
432
file_id = self._fileid_map.lookup_file_id(path)
431
ie = entry_factory[kind](file_id, name.decode("utf-8"), parent_id)
433
ie = entry_factory[kind](file_id, name, parent_id)
432
434
if kind == 'symlink':
433
435
ie.symlink_target = store[hexsha].data.decode('utf-8')
434
436
elif kind == 'tree-reference':
443
445
def _get_dir_ie(self, path, parent_id):
446
path = path.decode('utf-8')
444
447
file_id = self._fileid_map.lookup_file_id(path)
445
return GitTreeDirectory(file_id,
446
posixpath.basename(path).decode("utf-8"), parent_id)
448
return GitTreeDirectory(file_id, posixpath.basename(path), parent_id)
448
450
def iter_child_entries(self, path, file_id=None):
449
451
(store, mode, tree_sha) = self._lookup_path(path)
619
621
target_extras = set()
620
622
ret = delta.TreeDelta()
621
623
for (oldpath, newpath), (oldmode, newmode), (oldsha, newsha) in changes:
622
if newpath == u'' and not include_root:
624
if newpath == b'' and not include_root:
624
626
if not (specific_files is None or
625
627
(oldpath is not None and osutils.is_inside_or_parent_of_any(specific_files, oldpath)) or
636
638
ret.unversioned.append(
637
639
(osutils.normalized_filename(newpath)[0], None, mode_kind(newmode)))
639
file_id = new_fileid_map.lookup_file_id(newpath)
640
ret.added.append((newpath.decode('utf-8'), file_id, mode_kind(newmode)))
641
newpath_decoded = newpath.decode('utf-8')
642
file_id = new_fileid_map.lookup_file_id(newpath_decoded)
643
ret.added.append((newpath_decoded, file_id, mode_kind(newmode)))
641
644
elif newpath is None or newmode == 0:
642
file_id = old_fileid_map.lookup_file_id(oldpath)
643
ret.removed.append((oldpath.decode('utf-8'), file_id, mode_kind(oldmode)))
645
oldpath_decoded = oldpath.decode('utf-8')
646
file_id = old_fileid_map.lookup_file_id(oldpath_decoded)
647
ret.removed.append((oldpath_decoded, file_id, mode_kind(oldmode)))
644
648
elif oldpath != newpath:
645
file_id = old_fileid_map.lookup_file_id(oldpath)
649
oldpath_decoded = oldpath.decode('utf-8')
650
file_id = old_fileid_map.lookup_file_id(oldpath_decoded)
646
651
ret.renamed.append(
647
(oldpath.decode('utf-8'), newpath.decode('utf-8'), file_id,
652
(oldpath_decoded, newpath.decode('utf-8'), file_id,
648
653
mode_kind(newmode), (oldsha != newsha),
649
654
(oldmode != newmode)))
650
655
elif mode_kind(oldmode) != mode_kind(newmode):
651
file_id = new_fileid_map.lookup_file_id(newpath)
656
newpath_decoded = newpath.decode('utf-8')
657
file_id = new_fileid_map.lookup_file_id(newpath_decoded)
652
658
ret.kind_changed.append(
653
(newpath.decode('utf-8'), file_id, mode_kind(oldmode),
659
(newpath_decoded, file_id, mode_kind(oldmode),
654
660
mode_kind(newmode)))
655
661
elif oldsha != newsha or oldmode != newmode:
656
662
if stat.S_ISDIR(oldmode) and stat.S_ISDIR(newmode):
658
file_id = new_fileid_map.lookup_file_id(newpath)
664
newpath_decoded = newpath.decode('utf-8')
665
file_id = new_fileid_map.lookup_file_id(newpath_decoded)
659
666
ret.modified.append(
660
(newpath.decode('utf-8'), file_id, mode_kind(newmode),
667
(newpath, file_id, mode_kind(newmode),
661
668
(oldsha != newsha), (oldmode != newmode)))
663
file_id = new_fileid_map.lookup_file_id(newpath)
664
ret.unchanged.append((newpath.decode('utf-8'), file_id, mode_kind(newmode)))
670
newpath_decoded = newpath.decode('utf-8')
671
file_id = new_fileid_map.lookup_file_id(newpath_decoded)
672
ret.unchanged.append((newpath, file_id, mode_kind(newmode)))
1046
1058
raise TypeError(value)
1047
1059
(ctime, mtime, dev, ino, mode, uid, gid, size, sha, flags) = value
1048
1060
file_id = self.path2id(path)
1049
if type(file_id) != str:
1050
raise AssertionError
1061
if not isinstance(file_id, bytes):
1062
raise TypeError(file_id)
1051
1063
kind = mode_kind(mode)
1052
1064
ie = entry_factory[kind](file_id, name, parent_id)
1053
1065
if kind == 'symlink':