vcs.svn
=======

.. py:module:: vcs.svn

.. autoapi-nested-parse::

   High-Level interface to SVN repository.

   Example::

       svn = SVNRepository(working_copy='/tmp/working_dir')
       svn.update(url='file:///path_to_local_repo', revision=1,
                  force_and_clean=True)



Attributes
----------

.. autoapisummary::

   vcs.svn.SVNCmd
   vcs.svn.logger


Classes
-------

.. autoapisummary::

   vcs.svn.SVNError
   vcs.svn.SVNRepository


Module Contents
---------------

.. py:data:: SVNCmd

.. py:data:: logger

.. py:class:: SVNError

   Bases: :py:obj:`e3.vcs.VCSError`


.. py:class:: SVNRepository(working_copy: str)

   Interface to a SVN Repository.

   :cvar svn_bin: path to the SVN binary
   :cvar log_stream: stream where the log commands will be redirected
       (default is stdout)
   :ivar working_copy: path to the SVN working copy


   .. py:attribute:: svn_bin
      :value: None



   .. py:attribute:: log_stream
      :type:  TextIO | IO[str]


   .. py:attribute:: working_copy


   .. py:method:: is_unix_svn() -> bool
      :classmethod:


      Check if svn is handling unix paths or windows paths.

      :return: True if unix paths should be used



   .. py:method:: local_url(repo_path: str) -> str
      :classmethod:


      Return the url of a svn repository hosted locally.

      :param repo_path: path to the repo
      :return: the url that can be used as repository url



   .. py:method:: create(repo_path: str, initial_content_path: str | None = None) -> str
      :classmethod:


      Create a local subversion repository.

      This creates a local repository (not a working copy) that can be
      referenced by using file:// protocol. The purpose of the this function
      is mainly to test svn-related functions without relying on a remote
      repository.

      :param repo_path: a local directory where to create the repository
      :param initial_content_path: directory containing the initial content
          of the repository. If set to None an empty repository is created.
      :return: the URL of the newly created repository



   .. py:method:: svn_cmd(cmd: SVNCmd, **kwargs: Any) -> e3.os.process.Run

      Run a svn command.

      Add the non-interactive option to all command (accepted on all SVN.
      subcommands from version 1.5).

      :param cmd: the command line as a list of string, all None entries will
          be discarded
      :param kwargs: additional parameters to provide to e3.os.process.Run
      :return: Result of the Run of the SVN command
      :raise: SVNError



   .. py:method:: get_info(item: str) -> str | None

      Return a specific item shown by svn info.

      The --show-item option is only available from 1.9.
      :raise: SVNError



   .. py:property:: url
      :type: str | None


      Return the last URL used for the checkout.

      :raise: SVNError



   .. py:property:: current_revision
      :type: str | None


      Return the current revision.

      :raise: SVNError



   .. py:method:: update(url: str | None = None, revision: str | None = None, force_and_clean: bool = False) -> bool

      Update a working copy or checkout a new one.

      If the directory is already a checkout, it tries to update it.
      If the directory is not associated to a (good) checkout or is empty
      it will checkout.
      The option --remove-unversioned of the svn subcommand
      cleanup exists only from svn version 1.9.
      :param url: URL of a SVN repository
      :param revision: specific revision (default is last)
      :param force_and_clean: if True: erase the content of non empty
      working_copy and use '--force' option for the svn update/checkout
      command
      :return: True if any local changes detected in the working copy
      :raise: SVNError



