commit - 4c864bc9ec52f825c70670c246cbeb74bb24c74e
commit + c070ed8c3cf4cdfbfa45516dd4802e62601ae6c0
blob - 8b6cfc2100bd83aa2fec9086c093832147c71344
blob + ee7ee0b5ea0e4ce29ac23ddb99757f2795a6de94
--- dulwich/index.py
+++ dulwich/index.py
@dataclass
class SerializedIndexEntry:
name: bytes
- ctime: int | float | Tuple[int, int]
- mtime: int | float | Tuple[int, int]
+ ctime: Union[int, float, Tuple[int, int]]
+ mtime: Union[int, float, Tuple[int, int]]
dev: int
ino: int
mode: int
@dataclass
class IndexEntry:
- ctime: int | float | Tuple[int, int]
- mtime: int | float | Tuple[int, int]
+ ctime: Union[int, float, Tuple[int, int]]
+ mtime: Union[int, float, Tuple[int, int]]
dev: int
ino: int
mode: int
yield read_cache_entry(f, version)
-def read_index_dict(f) -> Dict[bytes, IndexEntry | ConflictedIndexEntry]:
+def read_index_dict(f) -> Dict[bytes, Union[IndexEntry, ConflictedIndexEntry]]:
"""Read an index file and return it as a dictionary.
Dict Key is tuple of path and stage number, as
path alone is not unique
Args:
f: File object to read fromls.
"""
- ret: Dict[bytes, IndexEntry | ConflictedIndexEntry] = {}
+ ret: Dict[bytes, Union[IndexEntry, ConflictedIndexEntry]] = {}
for entry in read_index(f):
stage = entry.stage()
if stage == Stage.NORMAL:
def write_index_dict(
f: BinaryIO,
- entries: Dict[bytes, IndexEntry | ConflictedIndexEntry],
+ entries: Dict[bytes, Union[IndexEntry, ConflictedIndexEntry]],
version: Optional[int] = None,
) -> None:
"""Write an index file based on the contents of a dictionary.
class Index:
"""A Git Index file."""
- _byname: Dict[bytes, IndexEntry | ConflictedIndexEntry]
+ _byname: Dict[bytes, Union[IndexEntry, ConflictedIndexEntry]]
def __init__(self, filename: Union[bytes, str], read=True) -> None:
"""Create an index object associated with the given filename.
"""Number of entries in this index file."""
return len(self._byname)
- def __getitem__(self, key: bytes) -> IndexEntry | ConflictedIndexEntry:
+ def __getitem__(self, key: bytes) -> Union[IndexEntry, ConflictedIndexEntry]:
"""Retrieve entry by relative path and stage.
Returns: tuple with (ctime, mtime, dev, ino, mode, uid, gid, size, sha,
"""Remove all contents from this index."""
self._byname = {}
- def __setitem__(self, name: bytes, value: IndexEntry | ConflictedIndexEntry) -> None:
+ def __setitem__(self, name: bytes, value: Union[IndexEntry, ConflictedIndexEntry]) -> None:
assert isinstance(name, bytes)
self._byname[name] = value
def __delitem__(self, name: bytes) -> None:
del self._byname[name]
- def iteritems(self) -> Iterator[Tuple[bytes, IndexEntry | ConflictedIndexEntry]]:
+ def iteritems(self) -> Iterator[Tuple[bytes, Union[IndexEntry, ConflictedIndexEntry]]]:
return iter(self._byname.items())
- def items(self) -> Iterator[Tuple[bytes, IndexEntry | ConflictedIndexEntry]]:
+ def items(self) -> Iterator[Tuple[bytes, Union[IndexEntry, ConflictedIndexEntry]]]:
return iter(self._byname.items())
- def update(self, entries: Dict[bytes, IndexEntry | ConflictedIndexEntry]):
+ def update(self, entries: Dict[bytes, Union[IndexEntry, ConflictedIndexEntry]]):
for key, value in entries.items():
self[key] = value