Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/in_memory.py
Show First 20 Lines • Show All 283 Lines • ▼ Show 20 Lines | def directory_entry_get_by_path(self, directory, paths): | ||||
return | return | ||||
return self.directory_entry_get_by_path( | return self.directory_entry_get_by_path( | ||||
first_item['target'], paths[1:]) | first_item['target'], paths[1:]) | ||||
def revision_add(self, revisions): | def revision_add(self, revisions): | ||||
"""Add revisions to the storage | """Add revisions to the storage | ||||
Args: | Args: | ||||
revisions (iterable): iterable of dictionaries representing the | revisions (Iterable[dict]): iterable of dictionaries representing | ||||
ardumont: Iterable[dict] or List[dict]? | |||||
Not Done Inline Actionsping ;) ardumont: ping ;) | |||||
individual revisions to add. Each dict has the following keys: | the individual revisions to add. Each dict has the following | ||||
keys: | |||||
- id (sha1_git): id of the revision to add | - id (sha1_git): id of the revision to add | ||||
- date (datetime.DateTime): date the revision was written | - date (dict): date the revision was written | ||||
- date_offset (int): offset from UTC in minutes the revision | - committer_date (dict): date the revision got | ||||
was written | |||||
- date_neg_utc_offset (boolean): whether a null date_offset | |||||
represents a negative UTC offset | |||||
- committer_date (datetime.DateTime): date the revision got | |||||
added to the origin | added to the origin | ||||
- committer_date_offset (int): offset from UTC in minutes the | |||||
revision was added to the origin | |||||
- committer_date_neg_utc_offset (boolean): whether a null | |||||
committer_date_offset represents a negative UTC offset | |||||
- type (one of 'git', 'tar'): type of the revision added | - type (one of 'git', 'tar'): type of the revision added | ||||
- directory (sha1_git): the directory the revision points at | - directory (sha1_git): the directory the revision points at | ||||
- message (bytes): the message associated with the revision | - message (bytes): the message associated with the revision | ||||
- author_name (bytes): the name of the revision author | - author (Dict[str, bytes]): dictionary with keys: | ||||
- author_email (bytes): the email of the revision author | name, fullname, email | ||||
- committer_name (bytes): the name of the revision committer | - committer (Dict[str, bytes]): dictionary with keys: | ||||
- committer_email (bytes): the email of the revision committer | name, fullname, email | ||||
- metadata (jsonb): extra information as dictionary | - metadata (jsonb): extra information as dictionary | ||||
- synthetic (bool): revision's nature (tarball, directory | - synthetic (bool): revision's nature (tarball, directory | ||||
creates synthetic revision) | creates synthetic revision) | ||||
- parents (list of sha1_git): the parents of this revision | - parents (list of sha1_git): the parents of this revision | ||||
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( | ||||
rev.get('committer_date')) | rev.get('committer_date')) | ||||
self._objects[revision['id']].append( | self._objects[revision['id']].append( | ||||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | def revision_shortlog(self, revisions, limit=None): | ||||
""" | """ | ||||
yield from ((rev['id'], rev['parents']) | yield from ((rev['id'], rev['parents']) | ||||
for rev in self.revision_log(revisions, limit)) | for rev in self.revision_log(revisions, limit)) | ||||
def release_add(self, releases): | def release_add(self, releases): | ||||
"""Add releases to the storage | """Add releases to the storage | ||||
Args: | Args: | ||||
releases (iterable): iterable of dictionaries representing the | releases (Iterable[dict]): iterable of dictionaries representing | ||||
Not Done Inline Actionsi did not mention this as this was implicit... This one would need to be changed as well. ardumont: i did not mention this as this was implicit...
my bad...
This one would need to be changed as… | |||||
individual releases to add. Each dict has the following keys: | the individual releases to add. Each dict has the following | ||||
keys: | |||||
- id (sha1_git): id of the release to add | - id (sha1_git): id of the release to add | ||||
- revision (sha1_git): id of the revision the release points to | - revision (sha1_git): id of the revision the release points to | ||||
- date (datetime.DateTime): the date the release was made | - date (dict): the date the release was made | ||||
- date_offset (int): offset from UTC in minutes the release was | |||||
made | |||||
- date_neg_utc_offset (boolean): whether a null date_offset | |||||
represents a negative UTC offset | |||||
- name (bytes): the name of the release | - name (bytes): the name of the release | ||||
- comment (bytes): the comment associated with the release | - comment (bytes): the comment associated with the release | ||||
- author_name (bytes): the name of the release author | - author (Dict[str, bytes]): dictionary with keys: | ||||
- author_email (bytes): the email of the release author | name, fullname, email | ||||
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) | ||||
def release_missing(self, releases): | def release_missing(self, releases): | ||||
▲ Show 20 Lines • Show All 704 Lines • Show Last 20 Lines |
Iterable[dict] or List[dict]?