{"id":8692,"library":"svn","title":"Subversion Command-Line Wrapper (svn)","description":"The `svn` library by dsoprea is an intuitive Python wrapper for the Subversion (SVN) command-line client, compatible with Python 2.7 and 3.3+. It provides a lightweight interface for common SVN operations such as listing, getting info, logging, checking out, exporting, adding, committing, updating, and diffing. The library itself wraps the `svn` command-line executable, which must be installed separately on the system. The current version is 1.0.1, with its last release in February 2020.","status":"active","version":"1.0.1","language":"en","source_language":"en","source_url":"https://github.com/dsoprea/PySvn","tags":["svn","subversion","vcs","version-control","wrapper","command-line"],"install":[{"cmd":"pip install svn","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"This Python library wraps the external `svn` command-line tool, which must be installed and accessible in the system's PATH.","package":"Subversion (svn) command-line client","optional":false}],"imports":[{"note":"For interacting with a local Subversion working copy.","symbol":"LocalClient","correct":"import svn.local\nclient = svn.local.LocalClient('/path/to/working/copy')"},{"note":"For interacting with a remote Subversion repository.","symbol":"RemoteClient","correct":"import svn.remote\nclient = svn.remote.RemoteClient('https://repo.local/svn')"},{"note":"In version 1.0+, `SvnException` is raised instead of `ValueError` for repository issues.","wrong":"from svn.exception import ValueError","symbol":"SvnException","correct":"from svn.exception import SvnException"},{"note":"The `svn` package provides `LocalClient` and `RemoteClient` within `svn.local` and `svn.remote` modules, respectively, not a top-level `svn.Client`.","wrong":"import svn\nclient = svn.Client()","symbol":"Client","correct":"import svn.local\nclient = svn.local.LocalClient(...)"},{"note":"This import belongs to the `pysvn` library (SWIG bindings), not the `svn` (command-line wrapper) package. Attempting this will result in an `ImportError`.","wrong":"import svn.core","symbol":"svn.core"}],"quickstart":{"code":"import svn.remote\nimport os\n\n# Example: Checkout a remote repository\n# Replace with your actual repository URL and desired local path\nrepo_url = os.environ.get('SVN_REPO_URL', 'https://example.com/svn/myproject/trunk')\nlocal_path = os.environ.get('SVN_LOCAL_PATH', '/tmp/myproject_working_copy')\n\nif not os.path.exists(local_path):\n    print(f\"Checking out '{repo_url}' to '{local_path}'...\")\n    try:\n        r = svn.remote.RemoteClient(repo_url)\n        # For repositories requiring credentials:\n        # r = svn.remote.RemoteClient(repo_url, username='myuser', password='mypassword')\n        r.checkout(local_path)\n        print(\"Checkout successful.\")\n\n        # Example: Get info about the checked out working copy\n        local_client = svn.local.LocalClient(local_path)\n        info = local_client.info()\n        print(\"\\nWorking copy info:\")\n        for key, value in info.items():\n            print(f\"  {key}: {value}\")\n\n    except svn.exception.SvnException as e:\n        print(f\"SVN Error: {e}\")\n    except Exception as e:\n        print(f\"An unexpected error occurred: {e}\")\nelse:\n    print(f\"'{local_path}' already exists. Skipping checkout.\")\n    print(\"You can use svn.local.LocalClient to interact with it.\")","lang":"python","description":"This quickstart demonstrates how to use `svn.remote.RemoteClient` to check out a remote Subversion repository. It then uses `svn.local.LocalClient` to retrieve information about the newly created working copy. Remember to replace placeholder URLs and paths, and handle credentials as needed."},"warnings":[{"fix":"For older `diff` behavior, downgrade to `svn==0.3.46`. Otherwise, update your code to handle the new `diff` output format.","message":"The `diff` implementation was re-written in version 1.0, making it backwards-incompatible. If your application relies on the older `diff` output, you must pin your dependency to version `0.3.46` or earlier.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Ensure the Subversion command-line tools are installed on your operating system (e.g., `sudo apt-get install subversion` on Debian/Ubuntu, `brew install subversion` on macOS, or via official installers on Windows).","message":"The Python `svn` library is a wrapper around the Subversion command-line client. The `svn` executable must be installed on the system where the Python code runs and be accessible in the system's PATH.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Update your exception handling from `except ValueError:` to `except svn.exception.SvnException:` to catch SVN-specific errors.","message":"From version 1.0 onwards, exceptions related to SVN repository issues are raised as `svn.exception.SvnException`, replacing `ValueError`.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"If you intend to use the command-line wrapper, do not import `svn.core`. Instead, use `import svn.local` or `import svn.remote`. If you genuinely need the `pysvn` SWIG bindings, ensure it is installed correctly and manage potential conflicts with the `svn` package.","cause":"This error often occurs when attempting to use features of the `pysvn` library (SWIG bindings) while having installed the `svn` (command-line wrapper) package. The `svn` package does not expose a `svn.core` module.","error":"ImportError: No module named svn.core"},{"fix":"Avoid using a single `svn.local.LocalClient` or `svn.remote.RemoteClient` instance across multiple threads simultaneously. Instantiate a new client object for each thread or ensure thread-safe access (e.g., using locks) if you must share a client.","cause":"The underlying Subversion client (whether the `pysvn` SWIG bindings or the `svn` command-line tool being shelled out to) is generally not thread-safe. Concurrent access from multiple threads to the same client instance can cause this error.","error":"pysvn.ClientError exception with the value 'client in use on another thread'"}]}