Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/in_memory.py
Show First 20 Lines • Show All 373 Lines • ▼ Show 20 Lines | class Storage: | ||||
def revision_add(self, revisions): | def revision_add(self, revisions): | ||||
"""Add revisions to the storage | """Add revisions to the storage | ||||
Args: | Args: | ||||
revisions (Iterable[dict]): iterable of dictionaries representing | revisions (Iterable[dict]): iterable of dictionaries representing | ||||
the individual revisions to add. Each dict has the following | the individual revisions to add. Each dict has the following | ||||
keys: | keys: | ||||
- id (sha1_git): id of the revision to add | - **id** (:class:`sha1_git`): id of the revision to add | ||||
- date (dict): date the revision was written | - **date** (:class:`dict`): date the revision was written | ||||
- committer_date (dict): date the revision got | - **committer_date** (:class:`dict`): date the revision got | ||||
added to the origin | added to the origin | ||||
- type (one of 'git', 'tar'): type of the revision added | - **type** (one of 'git', 'tar'): type of the | ||||
- directory (sha1_git): the directory the revision points at | revision added | ||||
- message (bytes): the message associated with the revision | - **directory** (:class:`sha1_git`): the directory the | ||||
- author (Dict[str, bytes]): dictionary with keys: | revision points at | ||||
name, fullname, email | - **message** (:class:`bytes`): the message associated with | ||||
- committer (Dict[str, bytes]): dictionary with keys: | the revision | ||||
name, fullname, email | - **author** (:class:`Dict[str, bytes]`): dictionary with | ||||
- metadata (jsonb): extra information as dictionary | keys: name, fullname, email | ||||
- synthetic (bool): revision's nature (tarball, directory | - **committer** (:class:`Dict[str, bytes]`): dictionary with | ||||
creates synthetic revision) | keys: name, fullname, email | ||||
- parents (list of sha1_git): the parents of this revision | - **metadata** (:class:`jsonb`): extra information as | ||||
dictionary | |||||
- **synthetic** (:class:`bool`): revision's nature (tarball, | |||||
directory creates synthetic revision`) | |||||
- **parents** (:class:`list[sha1_git]`): the parents of | |||||
this revision | |||||
ardumont: More than the type described here, svn, hg, etc...
We cannot really be exhaustive here, so we… | |||||
Not Done Inline ActionsIdeally we'd like to have a simple way of knowing which values are possible for a given instance of the platform. Or at least add a few words telling where these accepted values come from (here, the list of supported loader, or more precisely the possible values of the 'type' key in the origin member of loader instances, which is a bit painful to explain is a docstring...) Not sure what's the best link to put here to reference the origin "schema", but i would be nice to have such a link. Also applies to the same hunk on storage.py. douardda: Ideally we'd like to have a simple way of knowing which values are possible for a given… | |||||
Done Inline ActionsThe only reference I know of is this one: https://forge.softwareheritage.org/source/swh-storage/browse/master/swh/storage/sql/20-swh-enums.sql$8 :/ vlorentz: The only reference I know of is this one: https://forge.softwareheritage.org/source/swh… | |||||
Not Done Inline ActionsYes, i do not see a better link than this one right now. ardumont: Yes, i do not see a better link than this one right now. | |||||
date dictionaries have the form defined in :mod:`swh.model`. | date dictionaries have the form defined in :mod:`swh.model`. | ||||
""" | """ | ||||
for revision in revisions: | for revision in revisions: | ||||
if revision['id'] not in self._revisions: | if revision['id'] not in self._revisions: | ||||
self._revisions[revision['id']] = rev = copy.deepcopy(revision) | self._revisions[revision['id']] = rev = copy.deepcopy(revision) | ||||
rev['date'] = normalize_timestamp(rev.get('date')) | rev['date'] = normalize_timestamp(rev.get('date')) | ||||
rev['committer_date'] = normalize_timestamp( | rev['committer_date'] = normalize_timestamp( | ||||
▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | class Storage: | ||||
def release_add(self, releases): | def release_add(self, releases): | ||||
"""Add releases to the storage | """Add releases to the storage | ||||
Args: | Args: | ||||
releases (Iterable[dict]): iterable of dictionaries representing | releases (Iterable[dict]): iterable of dictionaries representing | ||||
the individual releases to add. Each dict has the following | the individual releases to add. Each dict has the following | ||||
keys: | keys: | ||||
- id (sha1_git): id of the release to add | - **id** (:class:`sha1_git`): id of the release to add | ||||
- revision (sha1_git): id of the revision the release points to | - **revision** (:class:`sha1_git`): id of the revision the | ||||
- date (dict): the date the release was made | release points to | ||||
- name (bytes): the name of the release | - **date** (:class:`dict`): the date the release was made | ||||
- comment (bytes): the comment associated with the release | - **name** (:class:`bytes`): the name of the release | ||||
- author (Dict[str, bytes]): dictionary with keys: | - **comment** (:class:`bytes`): the comment associated with | ||||
name, fullname, email | the release | ||||
- **author** (:class:`Dict[str, bytes]`): dictionary with | |||||
keys: name, fullname, email | |||||
the date dictionary has the form defined in :mod:`swh.model`. | the date dictionary has the form defined in :mod:`swh.model`. | ||||
""" | """ | ||||
for rel in releases: | for rel in releases: | ||||
rel['date'] = normalize_timestamp(rel['date']) | rel['date'] = normalize_timestamp(rel['date']) | ||||
self._objects[rel['id']].append( | self._objects[rel['id']].append( | ||||
('release', rel['id'])) | ('release', rel['id'])) | ||||
self._releases.update((rel['id'], rel) for rel in releases) | self._releases.update((rel['id'], rel) for rel in releases) | ||||
▲ Show 20 Lines • Show All 705 Lines • Show Last 20 Lines |
More than the type described here, svn, hg, etc...
We cannot really be exhaustive here, so we can make that examples, i think.