Changeset View
Changeset View
Standalone View
Standalone View
swh/journal/replay.py
Show First 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | |||||
def _check_revision_date(rev): | def _check_revision_date(rev): | ||||
"""Exclude revisions with invalid dates. | """Exclude revisions with invalid dates. | ||||
See https://forge.softwareheritage.org/T1339""" | See https://forge.softwareheritage.org/T1339""" | ||||
return _check_date(rev['date']) and _check_date(rev['committer_date']) | return _check_date(rev['date']) and _check_date(rev['committer_date']) | ||||
def _fix_revisions(revisions): | def _fix_revisions(revisions): | ||||
good_revisions = [] | good_revisions = [] | ||||
for rev in revisions: | for rev in revisions: | ||||
anlambert: I would rather use
```lang=python
for rev in set(revisions):
```
to remove duplicates but I… | |||||
Not Done Inline ActionsThe order matters, and (ideally) we need to keep only the last version of the object. I guess the easiest solution is to put the revisions in a dict keyed by id, and return the values() of that dict. olasd: The order matters, and (ideally) we need to keep only the last version of the object.
I guess… | |||||
rev = _fix_revision_pypi_empty_string(rev) | rev = _fix_revision_pypi_empty_string(rev) | ||||
rev = _fix_revision_transplant_source(rev) | rev = _fix_revision_transplant_source(rev) | ||||
if not _check_revision_date(rev): | if not _check_revision_date(rev): | ||||
logging.warning('Excluding revision (invalid date): %r', rev) | logging.warning('Excluding revision (invalid date): %r', rev) | ||||
continue | continue | ||||
if rev not in good_revisions: | |||||
good_revisions.append(rev) | good_revisions.append(rev) | ||||
return good_revisions | return good_revisions | ||||
def _fix_origin_visits(visits): | def _fix_origin_visits(visits): | ||||
good_visits = [] | good_visits = [] | ||||
for visit in visits: | for visit in visits: | ||||
visit = visit.copy() | visit = visit.copy() | ||||
if 'type' not in visit: | if 'type' not in visit: | ||||
▲ Show 20 Lines • Show All 305 Lines • Show Last 20 Lines |
I would rather use
to remove duplicates but I don't know if the original revision ordering matters here.