~brz/brz/3.1

« back to all changes in this revision

Viewing changes to breezy/git/tree.py

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2021-05-02 15:54:51 UTC
  • mfrom: (7695.1.2 dulwich-compat)
  • Revision ID: breezy.the.bot@gmail.com-20210502155451-ptcd9bb8xqarfiyp
Don't rely on index entries being a tuple of size 10.

Merged from https://code.launchpad.net/~jelmer/brz/dulwich-compat/+merge/402101

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
    commit_tree,
37
37
    index_entry_from_stat,
38
38
    Index,
 
39
    IndexEntry,
39
40
    )
40
41
from dulwich.object_store import (
41
42
    tree_lookup_path,
1207
1208
            for i in range(1, len(parts)):
1208
1209
                basepath = b'/'.join(parts[:i])
1209
1210
                try:
1210
 
                    (ctime, mtime, dev, ino, mode, uid, gid, size, sha,
1211
 
                     flags) = index[basepath]
 
1211
                    value = index[basepath]
1212
1212
                except KeyError:
1213
1213
                    continue
1214
1214
                else:
1215
 
                    if S_ISGITLINK(mode):
 
1215
                    if S_ISGITLINK(value.mode):
1216
1216
                        index = self._get_submodule_index(basepath)
1217
1217
                        remaining_path = b'/'.join(parts[i:])
1218
1218
                        break
1324
1324
            if index is None:
1325
1325
                index = self.index
1326
1326
            for path, value in index.items():
1327
 
                (ctime, mtime, dev, ino, mode, uid, gid, size, sha,
1328
 
                 flags) = value
1329
 
                if S_ISGITLINK(mode) and recurse_nested:
 
1327
                if S_ISGITLINK(value.mode) and recurse_nested:
1330
1328
                    subindex = self._get_submodule_index(path)
1331
1329
                    for entry in self._recurse_index_entries(
1332
1330
                            index=subindex, basepath=path,
1390
1388
            raise TypeError(name)
1391
1389
        if not isinstance(path, text_type):
1392
1390
            raise TypeError(path)
1393
 
        if not isinstance(value, tuple) or len(value) != 10:
 
1391
        if not isinstance(value, tuple) and not isinstance(value, IndexEntry):
1394
1392
            raise TypeError(value)
1395
 
        (ctime, mtime, dev, ino, mode, uid, gid, size, sha, flags) = value
1396
1393
        file_id = self.path2id(path)
1397
1394
        if not isinstance(file_id, bytes):
1398
1395
            raise TypeError(file_id)
1399
 
        kind = mode_kind(mode)
 
1396
        kind = mode_kind(value.mode)
1400
1397
        ie = entry_factory[kind](file_id, name, parent_id)
1401
1398
        if kind == 'symlink':
1402
1399
            ie.symlink_target = self.get_symlink_target(path)
1403
1400
        elif kind == 'tree-reference':
1404
1401
            ie.reference_revision = self.get_reference_revision(path)
1405
1402
        else:
1406
 
            ie.git_sha1 = sha
1407
 
            ie.text_size = size
1408
 
            ie.executable = bool(stat.S_ISREG(mode) and stat.S_IEXEC & mode)
 
1403
            ie.git_sha1 = value.sha
 
1404
            ie.text_size = value.size
 
1405
            ie.executable = bool(stat.S_ISREG(value.mode) and stat.S_IEXEC & value.mode)
1409
1406
        return ie
1410
1407
 
1411
1408
    def _add_missing_parent_ids(self, path, dir_ids):