fab.tools.versioning#

Versioning tools such as Subversion and Git.

Classes

Fcm()

This is the base class for FCM.

Git()

Interface to Git version control system.

Subversion([name, exec_name, category])

Interface to the Subversion version control system.

Versioning(name, exec_name, category)

Base class for versioning tools like Git and Subversion.

class fab.tools.versioning.Versioning(name, exec_name, category)#

Base class for versioning tools like Git and Subversion.

Constructor.

Parameters:
  • name (str) – Display name of this tool.

  • exec_name (Union[str, Path]) – Executable for this tool.

  • category (Category) – Tool belongs to this category.

class fab.tools.versioning.Git#

Interface to Git version control system.

Constructor.

Parameters:
  • name – Display name of this tool.

  • exec_name – Executable for this tool.

  • category – Tool belongs to this category.

current_commit(folder=None)#
Return type:

str

Returns:

the hash of the current commit.

Parameters:

folder (Union[Path, str, None]) – the folder for which to determine the current commitf (defaults to .). (default: None)

init(folder)#

Initialises a directory.

Parameters:

folder (Union[Path, str]) – the directory to initialise.

clean(folder)#

Removes all non versioned files in a directory.

Parameters:

folder (Union[Path, str]) – the directory to clean.

fetch(src, dst, revision)#

Runs git fetch in the specified directory

Parameters:
  • src (Union[str, Path]) – the source directory from which to fetch

  • revision (Optional[str]) – the revision to fetch (can be “” for latest revision)

  • dst (Union[str, Path]) – the directory in which to run fetch.

checkout(src, dst='', revision=None)#

Checkout or update a Git repo.

Parameters:
  • src (str) – the source directory from which to checkout.

  • dst (str) – the directory in which to run checkout. (default: '')

  • revision (Optional[str]) – the revision to check out (can be “” for latest revision). (default: None)

merge(dst, revision=None)#

Merge a git repo into a local working copy. If the merge fails, it will run git merge –abort to clean the directory.

Parameters:
  • dst (Union[str, Path]) – the directory to merge in.

  • revision (Optional[str]) – the revision number (only used for error message, it relies on git fetch running previously). (default: None)

class fab.tools.versioning.Subversion(name=None, exec_name=None, category=Category.SUBVERSION)#

Interface to the Subversion version control system.

Constructor.

This is class is extended by the FCM interface which is why name and executable are mutable.

Parameters:
  • name (Optional[str]) – Tool name, defaults to “subversion.” (default: None)

  • exec_name (Union[Path, str, None]) – Tool executable, defaults to “svn.” (default: None)

  • category (Category) – Tool category, defaults to SUBVERSION. (default: <Category.SUBVERSION: 9>)

execute(pre_commands=None, revision=None, post_commands=None, env=None, cwd=None, capture_output=True)#

Executes a svn command.

Parameters:
  • pre_commands (Optional[List[str]]) – List of strings to be sent to subprocess.run() as the command. (default: None)

  • revision (Union[int, str, None]) – optional revision number as argument (default: None)

  • post_commands (Optional[List[str]]) – List of additional strings to be sent to subprocess.run() after the optional revision number. (default: None)

  • env (Optional[Dict[str, str]]) – Optional env for the command. By default it will use the current session’s environment. (default: None)

  • capture_output – If True, capture and return stdout. If False, the command will print its output directly to the console. (default: True)

Return type:

str

export(src, dst, revision=None)#

Runs svn export.

Parameters:
checkout(src, dst, revision=None)#

Runs svn checkout.

Parameters:
update(dst, revision=None)#

Runs svn checkout.

Parameters:
merge(src, dst, revision=None)#

Runs svn merge.

Parameters:
class fab.tools.versioning.Fcm#

This is the base class for FCM. All commands will be mapped back to the corresponding subversion commands.

Constructor.

This is class is extended by the FCM interface which is why name and executable are mutable.

Parameters:
  • name – Tool name, defaults to “subversion.”

  • exec_name – Tool executable, defaults to “svn.”

  • category – Tool category, defaults to SUBVERSION.