swh.loader.svn.svn_repo module#

SVN client in charge of iterating over svn logs and yield commit representations including the hash tree/content computations per svn commit.

class swh.loader.svn.svn_repo.SvnRepo(remote_url: str, origin_url: str | None = None, local_dirname: str | None = None, max_content_length: int = 100000, debug: bool = False, username: str = '', password: str = '')[source]#

Bases: object

Svn repository representation.

Parameters:
  • remote_url – Remove svn repository url

  • origin_url – Associated origin identifier

  • local_dirname – Path to write intermediary svn action results

head_revision() int[source]#

Retrieve current head revision.

initial_revision() int[source]#

Retrieve the initial revision from which the remote url appeared.

logs(revision_start: int, revision_end: int) Iterator[Dict][source]#

Stream svn logs between revision_start and revision_end.

Yields revision information between revision_start and revision_end.

Parameters:
  • revision_start – the svn revision starting bound

  • revision_end – the svn revision ending bound

Yields:

dictionaries of revision data with the following keys – - rev: revision number - author_date: date of the commit - author_name: name of the author of the commit - message: commit message - has_changes: whether the commit has changes (can be False when loading subprojects) - changed_paths: list of paths changed by the commit

commit_info(revision: int) Dict | None[source]#

Return commit information.

Parameters:

revision – svn revision to return commit info

Returns:

A dictionary filled with commit info, see swh.loader.svn.svn_repo.logs() for details about its content.

remote_access() RemoteAccess[source]#

Simple wrapper around subvertpy.ra.RemoteAccess creation enabling to retry the operation if a network error occurs.

info(origin_url: str | None = None, peg_revision: int | None = None, revision: int | None = None)[source]#

Simple wrapper around subvertpy.client.Client.info enabling to retry the command if a network error occurs.

Parameters:

origin_url – If provided, query info about a specific repository, currently set origin URL will be used otherwise

export(url: str, to: str, rev: int | None = None, peg_rev: int | None = None, recurse: bool = True, ignore_externals: bool = False, overwrite: bool = False, ignore_keywords: bool = False, remove_dest_path: bool = True) int[source]#

Simple wrapper around subvertpy.client.Client.export enabling to retry the command if a network error occurs.

See documentation of svn_client_export5 function from subversion C API to get details about parameters.

checkout(url: str, path: str, rev: int | None = None, peg_rev: int | None = None, recurse: bool = True, ignore_externals: bool = False, allow_unver_obstructions: bool = False) int[source]#

Simple wrapper around subvertpy.client.Client.checkout enabling to retry the command if a network error occurs.

See documentation of svn_client_checkout3 function from subversion C API to get details about parameters.

propget(name: str, target: str, peg_rev: int | None, rev: int | None = None, recurse: bool = False) Dict[str, bytes][source]#

Simple wrapper around subvertpy.client.Client.propget enabling to retry the command if a network error occurs.

See documentation of svn_client_propget5 function from subversion C API to get details about parameters.

export_temporary(revision: int) Tuple[str, bytes][source]#

Export the repository to a given revision in a temporary location. This is up to the caller of this function to clean up the temporary location when done (cf. self.clean_fs method)

Parameters:

revision – Revision to export at

Returns:

The tuple local_dirname the temporary location root folder, local_url where the repository was exported.

swh_hash_data_per_revision(start_revision: int, end_revision: int) Iterator[Tuple[int, Dict, Tuple[List[Content], List[SkippedContent], List[Directory]], Directory]][source]#

Compute swh hash data per each revision between start_revision and end_revision.

Parameters:
  • start_revision – starting revision

  • end_revision – ending revision

Yields:

Tuple (rev, nextrev, commit, objects_per_path)

  • rev: current revision

  • commit: commit data (author, date, message) for such revision

  • objects_per_path: Tuple of list of objects between start_revision and end_revision

  • complete Directory representation

swh_hash_data_at_revision(revision: int) Tuple[Dict, Directory][source]#

Compute the information at a given svn revision. This is expected to be used for checks only.

Yields:

The tuple (commit dictionary, targeted directory object).

clean_fs(local_dirname: str | None = None) None[source]#

Clean up the local working copy.

Parameters:

local_dirname – Path to remove recursively if provided. Otherwise, remove the temporary upper root tree used for svn repository loading.

get_head_revision_at_date(date: datetime) int[source]#

Get HEAD revision number for a given date.

Parameters:

date – the reference date

Returns:

the revision number of the HEAD revision at that date

Raises:

ValueError – first revision date is greater than given date

swh.loader.svn.svn_repo.get_svn_repo(*args, **kwargs)[source]#

Instantiate an SvnRepo class and trap SubversionException if any raises. In case of connection error to the repository, its read access using anonymous credentials is also attempted.

Raises:
  • NotFound – if the repository is not found

  • SubversionException – if any other kind of subversion problems arise