/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/plugins/git/tree.py

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2018-07-25 18:15:53 UTC
  • mfrom: (7045.4.7 python3-s)
  • Revision ID: breezy.the.bot@gmail.com-20180725181553-mz6zhncntlovb8ii
Fix another couple of hundred tests on Python 3.

Merged from https://code.launchpad.net/~jelmer/brz/python3-s/+merge/350749

Show diffs side-by-side

added added

removed removed

Lines of Context:
281
281
        change_scanner = self._repository._file_change_scanner
282
282
        if self.commit_id == ZERO_SHA:
283
283
            return NULL_REVISION
284
 
        (path, commit_id) = change_scanner.find_last_change_revision(
 
284
        (unused_path, commit_id) = change_scanner.find_last_change_revision(
285
285
            path.encode('utf-8'), self.commit_id)
286
286
        return self._repository.lookup_foreign_revision_id(commit_id, self.mapping)
287
287
 
301
301
            path = self._fileid_map.lookup_path(file_id)
302
302
        except ValueError:
303
303
            raise errors.NoSuchId(self, file_id)
304
 
        path = path.decode('utf-8')
305
304
        if self.is_versioned(path):
306
305
            return path
307
306
        raise errors.NoSuchId(self, file_id)
686
685
    if target_extras is None:
687
686
        target_extras = set()
688
687
    for (oldpath, newpath), (oldmode, newmode), (oldsha, newsha) in changes:
 
688
        if oldpath is not None:
 
689
            oldpath_decoded = oldpath.decode('utf-8')
 
690
        else:
 
691
            oldpath_decoded = None
 
692
        if newpath is not None:
 
693
            newpath_decoded = newpath.decode('utf-8')
 
694
        else:
 
695
            newpath_decoded = None
689
696
        if not (specific_files is None or
690
 
                (oldpath is not None and osutils.is_inside_or_parent_of_any(specific_files, oldpath)) or
691
 
                (newpath is not None and osutils.is_inside_or_parent_of_any(specific_files, newpath))):
 
697
                (oldpath_decoded is not None and osutils.is_inside_or_parent_of_any(specific_files, oldpath_decoded)) or
 
698
                (newpath_decoded is not None and osutils.is_inside_or_parent_of_any(specific_files, newpath_decoded))):
692
699
            continue
693
 
        path = (oldpath, newpath)
694
700
        if oldpath is not None and mapping.is_special_file(oldpath):
695
701
            continue
696
702
        if newpath is not None and mapping.is_special_file(newpath):
697
703
            continue
698
 
        if oldpath is None:
699
 
            fileid = mapping.generate_file_id(newpath)
 
704
        if oldpath_decoded is None:
 
705
            fileid = mapping.generate_file_id(newpath_decoded)
700
706
            oldexe = None
701
707
            oldkind = None
702
708
            oldname = None
704
710
            oldversioned = False
705
711
        else:
706
712
            oldversioned = True
707
 
            oldpath = oldpath.decode("utf-8")
708
713
            if oldmode:
709
714
                oldexe = mode_is_executable(oldmode)
710
715
                oldkind = mode_kind(oldmode)
711
716
            else:
712
717
                oldexe = False
713
718
                oldkind = None
714
 
            if oldpath == u'':
 
719
            if oldpath_decoded == u'':
715
720
                oldparent = None
716
 
                oldname = ''
 
721
                oldname = u''
717
722
            else:
718
 
                (oldparentpath, oldname) = osutils.split(oldpath)
 
723
                (oldparentpath, oldname) = osutils.split(oldpath_decoded)
719
724
                oldparent = mapping.generate_file_id(oldparentpath)
720
 
            fileid = mapping.generate_file_id(oldpath)
721
 
        if newpath is None:
 
725
            fileid = mapping.generate_file_id(oldpath_decoded)
 
726
        if newpath_decoded is None:
722
727
            newexe = None
723
728
            newkind = None
724
729
            newname = None
725
730
            newparent = None
726
731
            newversioned = False
727
732
        else:
728
 
            newversioned = (newpath not in target_extras)
 
733
            newversioned = (newpath_decoded not in target_extras)
729
734
            if newmode:
730
735
                newexe = mode_is_executable(newmode)
731
736
                newkind = mode_kind(newmode)
732
737
            else:
733
738
                newexe = False
734
739
                newkind = None
735
 
            newpath = newpath.decode("utf-8")
736
 
            if newpath == u'':
 
740
            if newpath_decoded == u'':
737
741
                newparent = None
738
742
                newname = u''
739
743
            else:
740
 
                newparentpath, newname = osutils.split(newpath)
 
744
                newparentpath, newname = osutils.split(newpath_decoded)
741
745
                newparent = mapping.generate_file_id(newparentpath)
742
746
        if (not include_unchanged and
743
747
            oldkind == 'directory' and newkind == 'directory' and
744
 
            oldpath == newpath):
 
748
            oldpath_decoded == newpath_decoded):
745
749
            continue
746
 
        yield (fileid, (oldpath, newpath), (oldsha != newsha),
 
750
        yield (fileid, (oldpath_decoded, newpath_decoded), (oldsha != newsha),
747
751
             (oldversioned, newversioned),
748
752
             (oldparent, newparent), (oldname, newname),
749
753
             (oldkind, newkind), (oldexe, newexe))
901
905
                path = self._fileid_map.lookup_path(file_id)
902
906
            except ValueError:
903
907
                raise errors.NoSuchId(self, file_id)
904
 
            path = path.decode('utf-8')
905
908
            if self.is_versioned(path):
906
909
                return path
907
910
            raise errors.NoSuchId(self, file_id)
910
913
        self._fileid_map.set_file_id("", file_id)
911
914
 
912
915
    def get_root_id(self):
913
 
        return self.path2id("")
 
916
        return self.path2id(u"")
914
917
 
915
918
    def _add(self, files, ids, kinds):
916
919
        for (path, file_id, kind) in zip(files, ids, kinds):
1230
1233
                    pass
1231
1234
                self._index_add_entry(to_rel, kind)
1232
1235
            else:
1233
 
                todo = [(p, i) for (p, i) in self._recurse_index_entries() if p.startswith(from_path+'/')]
 
1236
                todo = [(p, i) for (p, i) in self._recurse_index_entries() if p.startswith(from_path+b'/')]
1234
1237
                for child_path, child_value in todo:
1235
1238
                    (child_to_index, child_to_index_path) = self._lookup_index(
1236
1239
                            posixpath.join(to_path, posixpath.relpath(child_path, from_path)))