Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/svn/svn.py
# Copyright (C) 2015-2018 The Software Heritage developers | # Copyright (C) 2015-2020 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
"""SVN client in charge of iterating over svn logs and yield commit | """SVN client in charge of iterating over svn logs and yield commit | ||||
representations including the hash tree/content computations per svn | representations including the hash tree/content computations per svn | ||||
commit. | commit. | ||||
Show All 19 Lines | class SvnRepo: | ||||
"""Svn repository representation. | """Svn repository representation. | ||||
Args: | Args: | ||||
remote_url (str): | remote_url (str): | ||||
origin_url (str): Associated origin identifier | origin_url (str): Associated origin identifier | ||||
local_dirname (str): Path to write intermediary svn action results | local_dirname (str): Path to write intermediary svn action results | ||||
""" | """ | ||||
def __init__(self, remote_url, origin_url, local_dirname): | def __init__(self, remote_url, origin_url, local_dirname, | ||||
max_content_length): | |||||
self.remote_url = remote_url.rstrip('/') | self.remote_url = remote_url.rstrip('/') | ||||
self.origin_url = origin_url | self.origin_url = origin_url | ||||
auth = Auth([get_username_provider()]) | auth = Auth([get_username_provider()]) | ||||
# one connection for log iteration | # one connection for log iteration | ||||
self.conn_log = RemoteAccess(self.remote_url, auth=auth) | self.conn_log = RemoteAccess(self.remote_url, auth=auth) | ||||
# another for replay | # another for replay | ||||
self.conn = RemoteAccess(self.remote_url, auth=auth) | self.conn = RemoteAccess(self.remote_url, auth=auth) | ||||
# one client for update operation | # one client for update operation | ||||
self.client = client.Client(auth=auth) | self.client = client.Client(auth=auth) | ||||
self.local_dirname = local_dirname | self.local_dirname = local_dirname | ||||
local_name = os.path.basename(self.remote_url) | local_name = os.path.basename(self.remote_url) | ||||
self.local_url = os.path.join(self.local_dirname, local_name).encode( | self.local_url = os.path.join(self.local_dirname, local_name).encode( | ||||
'utf-8') | 'utf-8') | ||||
self.uuid = self.conn.get_uuid().encode('utf-8') | self.uuid = self.conn.get_uuid().encode('utf-8') | ||||
self.swhreplay = ra.Replay(conn=self.conn, rootpath=self.local_url) | self.swhreplay = ra.Replay(conn=self.conn, rootpath=self.local_url) | ||||
self.max_content_length = max_content_length | |||||
def __str__(self): | def __str__(self): | ||||
return str({ | return str({ | ||||
'swh-origin': self.origin_url, | 'swh-origin': self.origin_url, | ||||
'remote_url': self.remote_url, | 'remote_url': self.remote_url, | ||||
'local_url': self.local_url, | 'local_url': self.local_url, | ||||
'uuid': self.uuid, | 'uuid': self.uuid, | ||||
}) | }) | ||||
▲ Show 20 Lines • Show All 168 Lines • ▼ Show 20 Lines | def swh_hash_data_at_revision(self, revision): | ||||
"""Compute the hash data at revision. | """Compute the hash data at revision. | ||||
Expected to be used for update only. | Expected to be used for update only. | ||||
""" | """ | ||||
# Update the disk at revision | # Update the disk at revision | ||||
self.export(revision) | self.export(revision) | ||||
# Compute the current hashes on disk | # Compute the current hashes on disk | ||||
directory = Directory.from_disk(path=os.fsencode(self.local_url), | directory = Directory.from_disk( | ||||
save_path=True) | path=os.fsencode(self.local_url), | ||||
max_content_length=self.max_content_length) | |||||
# Update the replay collaborator with the right state | # Update the replay collaborator with the right state | ||||
self.swhreplay = ra.Replay( | self.swhreplay = ra.Replay( | ||||
conn=self.conn, | conn=self.conn, | ||||
rootpath=self.local_url, | rootpath=self.local_url, | ||||
directory=directory) | directory=directory) | ||||
# Retrieve the commit information for revision | # Retrieve the commit information for revision | ||||
Show All 17 Lines |