Changeset View
Changeset View
Standalone View
Standalone View
swh/fuse/fs/artifact.py
Show First 20 Lines • Show All 132 Lines • ▼ Show 20 Lines | class Revision(FuseDirEntry): | ||||
- `root`: source tree at the time of the commit, as a symlink pointing into | - `root`: source tree at the time of the commit, as a symlink pointing into | ||||
`archive/`, to a SWHID of type `dir` | `archive/`, to a SWHID of type `dir` | ||||
- `parents/` (note the plural): a virtual directory containing entries named | - `parents/` (note the plural): a virtual directory containing entries named | ||||
`1`, `2`, `3`, etc., one for each parent commit. Each of these entry is a | `1`, `2`, `3`, etc., one for each parent commit. Each of these entry is a | ||||
symlink pointing into `archive/`, to the SWHID file for the given parent | symlink pointing into `archive/`, to the SWHID file for the given parent | ||||
commit | commit | ||||
- `parent` (note the singular): present if and only if the current commit | - `parent` (note the singular): present if and only if the current commit | ||||
has at least one parent commit (which is the most common case). When | has at least one parent commit (which is the most common case). When | ||||
present it is a symlink pointing into `parents/1/` | present it is a symlink pointing into `parents/1/` | ||||
haltode: Update the docstring once changes are done in design.md | |||||
- `history`: a virtual directory listing all its revision ancestors, sorted | |||||
in reverse topological order. Each entry is a symlink pointing into | |||||
`archive/SWHID`. | |||||
- `meta.json`: metadata for the current node, as a symlink pointing to the | - `meta.json`: metadata for the current node, as a symlink pointing to the | ||||
relevant `meta/<SWHID>.json` file """ | relevant `meta/<SWHID>.json` file """ | ||||
swhid: SWHID | swhid: SWHID | ||||
async def __aiter__(self) -> AsyncIterator[FuseEntry]: | async def __aiter__(self) -> AsyncIterator[FuseEntry]: | ||||
metadata = await self.fuse.get_metadata(self.swhid) | metadata = await self.fuse.get_metadata(self.swhid) | ||||
directory = metadata["directory"] | directory = metadata["directory"] | ||||
Show All 18 Lines | async def __aiter__(self) -> AsyncIterator[FuseEntry]: | ||||
parents=[x["id"] for x in parents], | parents=[x["id"] for x in parents], | ||||
) | ) | ||||
if len(parents) >= 1: | if len(parents) >= 1: | ||||
yield self.create_child( | yield self.create_child( | ||||
FuseSymlinkEntry, name="parent", target="parents/1/", | FuseSymlinkEntry, name="parent", target="parents/1/", | ||||
) | ) | ||||
yield self.create_child( | |||||
RevisionHistory, | |||||
name="history", | |||||
mode=int(EntryMode.RDONLY_DIR), | |||||
swhid=self.swhid, | |||||
) | |||||
@dataclass | @dataclass | ||||
class RevisionParents(FuseDirEntry): | class RevisionParents(FuseDirEntry): | ||||
""" Revision virtual `parents/` directory """ | """ Revision virtual `parents/` directory """ | ||||
parents: List[SWHID] | parents: List[SWHID] | ||||
async def __aiter__(self) -> AsyncIterator[FuseEntry]: | async def __aiter__(self) -> AsyncIterator[FuseEntry]: | ||||
root_path = self.get_relative_root_path() | root_path = self.get_relative_root_path() | ||||
for i, parent in enumerate(self.parents): | for i, parent in enumerate(self.parents): | ||||
yield self.create_child( | yield self.create_child( | ||||
FuseSymlinkEntry, | FuseSymlinkEntry, | ||||
name=str(i + 1), | name=str(i + 1), | ||||
target=Path(root_path, f"archive/{parent}"), | target=Path(root_path, f"archive/{parent}"), | ||||
) | ) | ||||
@dataclass | @dataclass | ||||
class RevisionHistory(FuseDirEntry): | |||||
""" Revision virtual `history/` directory """ | |||||
swhid: SWHID | |||||
async def __aiter__(self) -> AsyncIterator[FuseEntry]: | |||||
history = await self.fuse.get_history(self.swhid) | |||||
root_path = self.get_relative_root_path() | |||||
Not Done Inline ActionsThis history field might be a bit redundant because get_history is already utilizing a sqlite cache and we probably want something more general in all __aiter__ (see T2695). haltode: This `history` field might be a bit redundant because `get_history` is already utilizing a… | |||||
for swhid in history: | |||||
yield self.create_child( | |||||
FuseSymlinkEntry, | |||||
name=str(swhid), | |||||
target=Path(root_path, f"archive/{swhid}"), | |||||
) | |||||
@dataclass | |||||
class Release(FuseDirEntry): | class Release(FuseDirEntry): | ||||
""" Software Heritage release artifact. | """ Software Heritage release artifact. | ||||
Attributes: | Attributes: | ||||
swhid: Software Heritage persistent identifier | swhid: Software Heritage persistent identifier | ||||
Release nodes are represented on the file-system as directories with the | Release nodes are represented on the file-system as directories with the | ||||
following entries: | following entries: | ||||
▲ Show 20 Lines • Show All 101 Lines • Show Last 20 Lines |
Update the docstring once changes are done in design.md