Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/svn/tasks.py
Show All 21 Lines | |||||
@shared_task(name=__name__ + ".LoadSvnRepository") | @shared_task(name=__name__ + ".LoadSvnRepository") | ||||
def load_svn( | def load_svn( | ||||
*, | *, | ||||
url: Optional[str] = None, | url: Optional[str] = None, | ||||
origin_url: Optional[str] = None, | origin_url: Optional[str] = None, | ||||
destination_path: Optional[str] = None, | destination_path: Optional[str] = None, | ||||
swh_revision: Optional[str] = None, | swh_revision: Optional[str] = None, | ||||
visit_date: Optional[str] = None, | visit_date: Optional[str] = None, | ||||
start_from_scratch: Optional[bool] = False, | incremental: Optional[bool] = True, | ||||
): | ): | ||||
"""Import a svn repository | """Import a svn repository | ||||
Args: | Args: | ||||
- url: (mandatory) svn's repository url to ingest data from | url: (mandatory) svn's repository url to ingest data from | ||||
- origin_url: Optional original url override to use as origin reference | origin_url: Optional original url override to use as origin reference in the | ||||
in the archive. If not provided, "url" is used as origin. | archive. If not provided, "url" is used as origin. | ||||
- destination_path: (optional) root directory to | destination_path: (optional) root directory to locally retrieve svn's data | ||||
locally retrieve svn's data | swh_revision: (optional) extra revision hex to start from. See | ||||
- swh_revision: (optional) extra revision hex to | swh.loader.svn.SvnLoader.process docstring | ||||
start from. See swh.loader.svn.SvnLoader.process | visit_date: Optional date to override the visit date | ||||
docstring | incremental: If True, the default, starts from the last snapshot (if any). | ||||
- visit_date: Optional date to override the visit date | Otherwise, starts from the initial commit of the repository. | ||||
- start_from_scratch: Flag to allow starting back the svn repository from the | |||||
start | |||||
""" | """ | ||||
loader = SvnLoader.from_configfile( | loader = SvnLoader.from_configfile( | ||||
url=url, | url=url, | ||||
origin_url=origin_url, | origin_url=origin_url, | ||||
destination_path=destination_path, | destination_path=destination_path, | ||||
swh_revision=swh_revision, | swh_revision=swh_revision, | ||||
visit_date=convert_to_datetime(visit_date), | visit_date=convert_to_datetime(visit_date), | ||||
start_from_scratch=start_from_scratch, | incremental=incremental, | ||||
) | ) | ||||
return loader.load() | return loader.load() | ||||
@shared_task(name=__name__ + ".MountAndLoadSvnRepository") | @shared_task(name=__name__ + ".MountAndLoadSvnRepository") | ||||
def load_svn_from_archive( | def load_svn_from_archive( | ||||
*, | *, | ||||
url: Optional[str] = None, | url: Optional[str] = None, | ||||
archive_path: Optional[str] = None, | archive_path: Optional[str] = None, | ||||
visit_date: Optional[str] = None, | visit_date: Optional[str] = None, | ||||
start_from_scratch: Optional[bool] = False, | incremental: Optional[bool] = True, | ||||
): | ): | ||||
"""1. Mount an svn dump from archive as a local svn repository | """1. Mount an svn dump from archive as a local svn repository | ||||
2. Load it through the svn loader | 2. Load it through the svn loader | ||||
3. Clean up mounted svn repository archive | 3. Clean up mounted svn repository archive | ||||
Args: | Args: | ||||
- url: origin url | url: origin url | ||||
- archive_path: Path on disk to the archive holdin the svn repository to ingest | archive_path: Path on disk to the archive holdin the svn repository to ingest | ||||
- visit_date: Optional date to override the visit date | visit_date: Optional date to override the visit date | ||||
- start_from_scratch: Flag to allow starting back the svn repository from the | incremental: If True, the default, starts from the last snapshot (if any). | ||||
start | Otherwise, starts from the initial commit of the repository. | ||||
""" | """ | ||||
loader = SvnLoaderFromDumpArchive.from_configfile( | loader = SvnLoaderFromDumpArchive.from_configfile( | ||||
url=url, | url=url, | ||||
archive_path=archive_path, | archive_path=archive_path, | ||||
visit_date=convert_to_datetime(visit_date), | visit_date=convert_to_datetime(visit_date), | ||||
start_from_scratch=start_from_scratch, | incremental=incremental, | ||||
) | ) | ||||
return loader.load() | return loader.load() | ||||
@shared_task(name=__name__ + ".DumpMountAndLoadSvnRepository") | @shared_task(name=__name__ + ".DumpMountAndLoadSvnRepository") | ||||
def load_svn_from_remote_dump( | def load_svn_from_remote_dump( | ||||
*, | *, | ||||
url: Optional[str] = None, | url: Optional[str] = None, | ||||
origin_url: Optional[str] = None, | origin_url: Optional[str] = None, | ||||
visit_date: Optional[str] = None, | visit_date: Optional[str] = None, | ||||
start_from_scratch: Optional[bool] = False, | incremental: Optional[bool] = True, | ||||
): | ): | ||||
"""1. Mount a remote svn dump as a local svn repository. | """1. Mount a remote svn dump as a local svn repository. | ||||
2. Load it through the svn loader. | 2. Load it through the svn loader. | ||||
3. Clean up mounted svn repository archive. | 3. Clean up mounted svn repository archive. | ||||
Args: | Args: | ||||
- url: (mandatory) svn's repository url to ingest data from | url: (mandatory) svn's repository url to ingest data from | ||||
- origin_url: Optional original url override to use as origin reference | origin_url: Optional original url override to use as origin reference | ||||
in the archive. If not provided, "url" is used as origin. | in the archive. If not provided, "url" is used as origin. | ||||
- visit_date: Optional date to override the visit date | visit_date: Optional date to override the visit date | ||||
- start_from_scratch: Flag to allow starting back the svn repository from the | incremental: If True, the default, starts from the last snapshot (if any). | ||||
start | Otherwise, starts from the initial commit of the repository. | ||||
""" | """ | ||||
loader = SvnLoaderFromRemoteDump.from_configfile( | loader = SvnLoaderFromRemoteDump.from_configfile( | ||||
url=url, | url=url, | ||||
origin_url=origin_url, | origin_url=origin_url, | ||||
visit_date=convert_to_datetime(visit_date), | visit_date=convert_to_datetime(visit_date), | ||||
start_from_scratch=start_from_scratch, | incremental=incremental, | ||||
) | ) | ||||
return loader.load() | return loader.load() |