Page MenuHomeSoftware Heritage

D977.diff
No OneTemporary

D977.diff

diff --git a/swh/loader/svn/tasks.py b/swh/loader/svn/tasks.py
--- a/swh/loader/svn/tasks.py
+++ b/swh/loader/svn/tasks.py
@@ -3,93 +3,70 @@
# License: GNU General Public License version 3, or any later version
# See top-level LICENSE file for more information
-
-from swh.scheduler.task import Task
+from celery import current_app as app
from .loader import (
SvnLoader, SvnLoaderFromDumpArchive, SvnLoaderFromRemoteDump
)
-class LoadSvnRepository(Task):
- """Load an svn repository to Software Heritage.
-
- """
- task_queue = 'swh_loader_svn'
-
- def run_task(self, *, svn_url,
- destination_path=None,
- swh_revision=None,
- origin_url=None,
- visit_date=None,
- start_from_scratch=None):
- """Import a svn repository
-
- Args:
- args: ordered arguments (expected None)
- kwargs: Dictionary with the following expected keys:
-
- - svn_url (str): (mandatory) svn's repository url
- - destination_path (str): (mandatory) root directory to
- locally retrieve svn's data
- - origin_url (str): Optional original url override
- - swh_revision (dict): (optional) extra revision hex to
- start from. see swh.loader.svn.SvnLoader.process
- docstring
+@app.task(name=__name__ + '.LoadSvnRepository')
+def load_svn(svn_url,
+ destination_path=None,
+ swh_revision=None,
+ origin_url=None,
+ visit_date=None,
+ start_from_scratch=None):
+ """Import a svn repository
- """
- loader = SvnLoader()
- loader.log = self.log
- return loader.load(
- svn_url=svn_url,
- destination_path=destination_path,
- origin_url=origin_url,
- swh_revision=swh_revision,
- visit_date=visit_date,
- start_from_scratch=start_from_scratch)
+ Args:
+ args: ordered arguments (expected None)
+ kwargs: Dictionary with the following expected keys:
-
-class MountAndLoadSvnRepository(Task):
- """Mount an archive dump into an svn repository, then load the
- repository to Software Heritage.
+ - svn_url (str): (mandatory) svn's repository url
+ - destination_path (str): (mandatory) root directory to
+ locally retrieve svn's data
+ - origin_url (str): Optional original url override
+ - swh_revision (dict): (optional) extra revision hex to
+ start from. see swh.loader.svn.SvnLoader.process
+ docstring
"""
- task_queue = 'swh_loader_svn_mount_and_load'
+ return SvnLoader().load(
+ svn_url=svn_url,
+ destination_path=destination_path,
+ origin_url=origin_url,
+ swh_revision=swh_revision,
+ visit_date=visit_date,
+ start_from_scratch=start_from_scratch)
+
+
+@app.task(name=__name__ + '.MountAndLoadSvnRepository')
+def mount_load_svn(archive_path, origin_url=None, visit_date=None,
+ start_from_scratch=False):
+ """1. Mount an svn dump from archive as a local svn repository
+ 2. Load it through the svn loader
+ 3. Clean up mounted svn repository archive
- def run_task(self, *, archive_path, origin_url=None, visit_date=None,
- start_from_scratch=False):
- """1. Mount an svn dump from archive as a local svn repository
- 2. Load it through the svn loader
- 3. Clean up mounted svn repository archive
+ """
+ return SvnLoaderFromDumpArchive(archive_path).load(
+ svn_url=None,
+ origin_url=origin_url,
+ visit_date=visit_date,
+ archive_path=archive_path,
+ start_from_scratch=start_from_scratch)
- """
- loader = SvnLoaderFromDumpArchive(archive_path)
- loader.log = self.log
- return loader.load(svn_url=None,
- origin_url=origin_url,
- visit_date=visit_date,
- archive_path=archive_path,
- start_from_scratch=start_from_scratch)
+@app.task(name=__name__ + '.DumpMountAndLoadSvnRepository')
+def dump_mount_load_svn(self, *, svn_url, origin_url=None, visit_date=None,
+ start_from_scratch=False):
+ """1. Mount an svn dump from archive as a local svn repository.
+ 2. Load it through the svn loader.
+ 3. Clean up mounted svn repository archive.
-class DumpMountAndLoadSvnRepository(Task):
- """
- Create a dump of a remote repository through the svnrdump
- tool, mount it locally then load the repository into the
- Software Heritage archive.
"""
- task_queue = 'swh_loader_svn_dump_mount_and_load'
-
- def run_task(self, *, svn_url, origin_url=None, visit_date=None,
- start_from_scratch=False):
- """1. Mount an svn dump from archive as a local svn repository.
- 2. Load it through the svn loader.
- 3. Clean up mounted svn repository archive.
-
- """
- loader = SvnLoaderFromRemoteDump()
- loader.log = self.log
- return loader.load(svn_url=svn_url,
- origin_url=origin_url,
- visit_date=visit_date,
- start_from_scratch=start_from_scratch)
+ return SvnLoaderFromRemoteDump().load(
+ svn_url=svn_url,
+ origin_url=origin_url,
+ visit_date=visit_date,
+ start_from_scratch=start_from_scratch)

File Metadata

Mime Type
text/plain
Expires
Thu, Jul 3, 12:19 PM (2 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3221776

Event Timeline