| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -57,6 +57,7 @@ | |||
| 57 | 57 | ||
| 58 | 58 | if TYPE_CHECKING: | |
| 59 | 59 | from .base import IndexFile | |
| 60 | + from objects.tree import TreeCacheTup | ||
| 60 | 61 | # from git.objects.fun import EntryTupOrNone | |
| 61 | 62 | ||
| 62 | 63 | # ------------------------------------------------------------------------------------ | |
@@ -249,7 +250,7 @@ def read_cache(stream: IO[bytes]) -> Tuple[int, Dict[Tuple[PathLike, int], 'Inde | |||
| 249 | 250 | ||
| 250 | 251 | ||
| 251 | 252 | def write_tree_from_cache(entries: List[IndexEntry], odb, sl: slice, si: int = 0 | |
| 252 | - ) -> Tuple[bytes, List[Tuple[bytes, int, str]]]: | ||
| 253 | + ) -> Tuple[bytes, List[TreeCacheTup]]: | ||
| 253 | 254 | """Create a tree from the given sorted list of entries and put the respective | |
| 254 | 255 | trees into the given object database | |
| 255 | 256 | ||
@@ -259,7 +260,7 @@ def write_tree_from_cache(entries: List[IndexEntry], odb, sl: slice, si: int = 0 | |||
| 259 | 260 | :param sl: slice indicating the range we should process on the entries list | |
| 260 | 261 | :return: tuple(binsha, list(tree_entry, ...)) a tuple of a sha and a list of | |
| 261 | 262 | tree entries being a tuple of hexsha, mode, name""" | |
| 262 | - tree_items: List[Tuple[bytes, int, str]] = [] | ||
| 263 | + tree_items: List[TreeCacheTup] = [] | ||
| 263 | 264 | ||
| 264 | 265 | ci = sl.start | |
| 265 | 266 | end = sl.stop | |
@@ -305,7 +306,7 @@ def write_tree_from_cache(entries: List[IndexEntry], odb, sl: slice, si: int = 0 | |||
| 305 | 306 | return (istream.binsha, tree_items) | |
| 306 | 307 | ||
| 307 | 308 | ||
| 308 | - def _tree_entry_to_baseindexentry(tree_entry: Tuple[bytes, int, str], stage: int) -> BaseIndexEntry: | ||
| 309 | + def _tree_entry_to_baseindexentry(tree_entry: TreeCacheTup, stage: int) -> BaseIndexEntry: | ||
| 309 | 310 | return BaseIndexEntry((tree_entry[1], tree_entry[0], stage << CE_STAGESHIFT, tree_entry[2])) | |
| 310 | 311 | ||
| 311 | 312 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -215,7 +215,7 @@ def traverse_trees_recursive(odb: 'GitCmdObjectDB', tree_shas: Sequence[Union[by | |||
| 215 | 215 | return out | |
| 216 | 216 | ||
| 217 | 217 | ||
| 218 | - def traverse_tree_recursive(odb: 'GitCmdObjectDB', tree_sha: bytes, path_prefix: str) -> List[Tuple[bytes, int, str]]: | ||
| 218 | + def traverse_tree_recursive(odb: 'GitCmdObjectDB', tree_sha: bytes, path_prefix: str) -> List[EntryTup]: | ||
| 219 | 219 | """ | |
| 220 | 220 | :return: list of entries of the tree pointed to by the binary tree_sha. An entry | |
| 221 | 221 | has the following format: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -31,9 +31,14 @@ | |||
| 31 | 31 | from io import BytesIO | |
| 32 | 32 | ||
| 33 | 33 | TreeCacheTup = Tuple[bytes, int, str] | |
| 34 | + | ||
| 34 | 35 | TraversedTreeTup = Union[Tuple[Union['Tree', None], IndexObjUnion, | |
| 35 | 36 | Tuple['Submodule', 'Submodule']]] | |
| 36 | 37 | ||
| 38 | + | ||
| 39 | + def is_tree_cache(inp: Tuple[bytes, int, str]) -> TypeGuard[TreeCacheTup]: | ||
| 40 | + return isinstance(inp[0], bytes) and isinstance(inp[1], int) and isinstance([inp], str) | ||
| 41 | + | ||
| 37 | 42 | #-------------------------------------------------------- | |
| 38 | 43 | ||
| 39 | 44 | ||
@@ -141,11 +146,8 @@ def add(self, sha: bytes, mode: int, name: str, force: bool = False) -> 'TreeMod | |||
| 141 | 146 | sha = to_bin_sha(sha) | |
| 142 | 147 | index = self._index_by_name(name) | |
| 143 | 148 | ||
| 144 | - def is_tree_cache(inp: Tuple[bytes, int, str]) -> TypeGuard[TreeCacheTup]: | ||
| 145 | - return isinstance(inp[0], bytes) and isinstance(inp[1], int) and isinstance([inp], str) | ||
| 146 | - | ||
| 147 | 149 | item = (sha, mode, name) | |
| 148 | - assert is_tree_cache(item) | ||
| 150 | + # assert is_tree_cache(item) | ||
| 149 | 151 | ||
| 150 | 152 | if index == -1: | |
| 151 | 153 | self._cache.append(item) | |
@@ -223,12 +225,12 @@ def _set_cache_(self, attr: str) -> None: | |||
| 223 | 225 | if attr == "_cache": | |
| 224 | 226 | # Set the data when we need it | |
| 225 | 227 | ostream = self.repo.odb.stream(self.binsha) | |
| 226 | - self._cache: List[Tuple[bytes, int, str]] = tree_entries_from_data(ostream.read()) | ||
| 228 | + self._cache: List[TreeCacheTup] = tree_entries_from_data(ostream.read()) | ||
| 227 | 229 | else: | |
| 228 | 230 | super(Tree, self)._set_cache_(attr) | |
| 229 | 231 | # END handle attribute | |
| 230 | 232 | ||
| 231 | - def _iter_convert_to_object(self, iterable: Iterable[Tuple[bytes, int, str]] | ||
| 233 | + def _iter_convert_to_object(self, iterable: Iterable[TreeCacheTup] | ||
| 232 | 234 | ) -> Iterator[IndexObjUnion]: | |
| 233 | 235 | """Iterable yields tuples of (binsha, mode, name), which will be converted | |
| 234 | 236 | to the respective object representation""" | |
| Back | FazBrowse Home | New Git URL |
0 commit comments