Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/mercurial/loader.py
Show First 20 Lines • Show All 120 Lines • ▼ Show 20 Lines | def get_heads(self, repo): | ||||
return b | return b | ||||
def prepare_origin_visit(self, *, origin_url, visit_date, **kwargs): | def prepare_origin_visit(self, *, origin_url, visit_date, **kwargs): | ||||
self.origin_url = origin_url | self.origin_url = origin_url | ||||
self.origin = {'url': self.origin_url, 'type': self.visit_type} | self.origin = {'url': self.origin_url, 'type': self.visit_type} | ||||
if isinstance(visit_date, str): # visit_date can be string or datetime | if isinstance(visit_date, str): # visit_date can be string or datetime | ||||
visit_date = parser.parse(visit_date) | visit_date = parser.parse(visit_date) | ||||
self.visit_date = visit_date | self.visit_date = visit_date | ||||
self.last_visit = self.storage.origin_visit_get_latest( | |||||
self.origin['url'], require_snapshot=True) | |||||
def prepare(self, *, origin_url, visit_date, directory=None): | def prepare(self, *, origin_url, visit_date, directory=None): | ||||
"""Prepare the necessary steps to load an actual remote or local | """Prepare the necessary steps to load an actual remote or local | ||||
repository. | repository. | ||||
To load a local repository, pass the optional directory | To load a local repository, pass the optional directory | ||||
parameter as filled with a path to a real local folder. | parameter as filled with a path to a real local folder. | ||||
▲ Show 20 Lines • Show All 366 Lines • ▼ Show 20 Lines | def get_fetch_history_result(self): | ||||
"""Return the data to store in fetch_history.""" | """Return the data to store in fetch_history.""" | ||||
return { | return { | ||||
'contents': self.num_contents, | 'contents': self.num_contents, | ||||
'directories': self.num_directories, | 'directories': self.num_directories, | ||||
'revisions': self.num_revisions, | 'revisions': self.num_revisions, | ||||
'releases': self.num_releases, | 'releases': self.num_releases, | ||||
} | } | ||||
def load_status(self): | |||||
snapshot = self.get_snapshot() | |||||
load_status = 'eventful' | |||||
if (self.last_visit is not None and | |||||
self.last_visit['snapshot'] == snapshot['id']): | |||||
load_status = 'uneventful' | |||||
return { | |||||
'status': load_status, | |||||
} | |||||
class HgArchiveBundle20Loader(HgBundle20Loader): | class HgArchiveBundle20Loader(HgBundle20Loader): | ||||
"""Mercurial loader for repository wrapped within archives. | """Mercurial loader for repository wrapped within archives. | ||||
""" | """ | ||||
def __init__(self): | def __init__(self): | ||||
super().__init__( | super().__init__( | ||||
logging_class='swh.loader.mercurial.HgArchiveBundle20Loader') | logging_class='swh.loader.mercurial.HgArchiveBundle20Loader') | ||||
Show All 19 Lines |