swh.loader.svn.ra module

Remote Access client to svn server.

swh.loader.svn.ra.apply_txdelta_handler(sbuf, target_stream)[source]

Return a function that can be called repeatedly with txdelta windows. When done, closes the target_stream.

Adapted from subvertpy.delta.apply_txdelta_handler to close the stream when done.

Parameters
  • sbuf – Source buffer

  • target_stream – Target stream to write to.

Returns

Function to be called to apply txdelta windows

Read the svn link’s content.

Parameters

data (bytes) – svn link’s raw content

Returns

The tuple of (filetype, destination path)

Determine if a filepath is an svnlink or something else.

Parameters

fullpath (str/bytes) – Full path to the potential symlink to check

Returns

boolean value to determine if it’s indeed a symlink (as per svn) or not.

class swh.loader.svn.ra.FileEditor(directory, rootpath, path)[source]

Bases: object

File Editor in charge of updating file on disk and memory objects.

directory
path
executable
fullpath
change_prop(key, value)[source]
apply_textdelta(base_checksum)[source]
close()[source]

When done with the file, this is called.

So the file exists and is updated, we can:

  • adapt accordingly its execution flag if any

  • compute the objects’ checksums

  • replace the svnlink with a real symlink (for disk computation purposes)

class swh.loader.svn.ra.BaseDirEditor(directory, rootpath)[source]

Bases: object

Base class implementation of dir editor.

see DirEditor for an implementation that hashes every directory encountered.

Instantiate a new class inheriting from this class and define the following functions:

def update_checksum(self):
    # Compute the checksums at current state

def open_directory(self, *args):
    # Update an existing folder.

def add_directory(self, *args):
    # Add a new one.
directory
rootpath
remove_child(path)[source]

Remove a path from the current objects.

The path can be resolved as link, file or directory.

This function takes also care of removing the link between the child and the parent.

Parameters

path – to remove from the current objects.

update_checksum()[source]
open_directory(*args)[source]
add_directory(*args)[source]
open_file(*args)[source]

Updating existing file.

add_file(path, copyfrom_path=None, copyfrom_rev=- 1)[source]

Creating a new file.

change_prop(key, value)[source]

Change property callback on directory.

delete_entry(path, revision)[source]

Remove a path.

close()[source]

Function called when we finish walking a repository.

class swh.loader.svn.ra.DirEditor(directory, rootpath)[source]

Bases: swh.loader.svn.ra.BaseDirEditor

Directory Editor in charge of updating directory hashes computation.

This implementation includes empty folder in the hash computation.

update_checksum()[source]

Update the root path self.path’s checksums according to the children’s objects.

This function is expected to be called when the folder has been completely ‘walked’.

open_directory(*args)[source]

Updating existing directory.

add_directory(path, copyfrom_path=None, copyfrom_rev=- 1)[source]

Adding a new directory.

directory
rootpath
class swh.loader.svn.ra.Editor(rootpath, directory)[source]

Bases: object

Editor in charge of replaying svn events and computing objects along.

This implementation accounts for empty folder during hash computations.

set_target_revision(revnum)[source]
abort()[source]
close()[source]
open_root(base_revnum)[source]
class swh.loader.svn.ra.Replay(conn, rootpath, directory=None)[source]

Bases: object

Replay class.

replay(rev)[source]

Replay svn actions between rev and rev+1.

This method updates in place the self.editor.directory, as well as the filesystem.

Returns

The updated root directory

compute_objects(rev: int) → Tuple[List[swh.model.model.Content], List[swh.model.model.SkippedContent], List[swh.model.model.Directory]][source]

Compute objects at revisions rev. Expects the state to be at previous revision’s objects.

Parameters

rev – The revision to start the replay from.

Returns

The updated objects between rev and rev+1. Beware that this mutates the filesystem at rootpath accordingly.