GithubHelp home page GithubHelp logo

dsoprea / pysvn Goto Github PK

View Code? Open in Web Editor NEW
215.0 25.0 144.0 222 KB

Lightweight Subversion library for Python.

License: GNU General Public License v2.0

Python 99.89% Shell 0.11%
version-control python2 python python3

pysvn's Introduction

Build_Status Coverage_Status

Introduction

svn is a simple Subversion library for Python. I wrote it so that there could be a lightweight and accessible library that was also available on PyPI. It is compatible with both Python 2.7 and 3.3+.

The library wraps the svn commandline client, which should consequently be installed on the local system.

Functions currently implemented:

  • list
  • info
  • log
  • checkout
  • export
  • cat
  • diff (with raw and summary support)
  • status
  • add
  • commit
  • update
  • cleanup
  • remove (i.e. rm, del, delete)

In addition, there is also an "admin" class (svn.admin.Admin) that provides a create method with which to create repositories.

You are more than welcome to submit pull-requests to add more support for additional subcommands.

Usage

Usage is divided between two clients that either allow for access to a local working-directory or a remote repository.

Both clients inherit a common set of methods that work with both local working- directories and remote repositories.

svn.utility.get_client is provided for convenience. If you provide a location that starts with a backslash, it will return a LocalClient instance. Otherwise, it will return a RemoteClient instance.

You may pass username and password as optional arguments to both the constructor and utility function.

LocalClient

LocalClient allows access to a local working copy.

RemoteClient

RemoteClient allows access to a remote repository.

SvnException

SvnException is raised whenever there is an issue with the svn repository. We are no longer supporting catching ValueError.

checkout(path)

Checkout a remote repository:

import svn.remote

r = svn.remote.RemoteClient('https://repo.local/svn')
r.checkout('/tmp/working')

Common Functionality

These methods are available on both clients.

info(rel_path=None)

Get information about the directory.

import pprint

import svn.local

r = svn.local.LocalClient('/tmp/test_repo.co')
info = r.info()
pprint.pprint(info)

#{'commit#revision': 0,
# 'commit/author': None,
# 'commit/date': datetime.datetime(2015, 4, 24, 2, 53, 21, 874970, tzinfo=tzutc()),
# 'commit_author': None,
# 'commit_date': datetime.datetime(2015, 4, 24, 2, 53, 21, 874970, tzinfo=tzutc()),
# 'commit_revision': 0,
# 'entry#kind': 'dir',
# 'entry#path': '/tmp/test_repo.co',
# 'entry#revision': 0,
# 'entry_kind': 'dir',
# 'entry_path': '/tmp/test_repo.co',
# 'entry_revision': 0,
# 'relative_url': None,
# 'repository/root': 'file:///tmp/test_repo',
# 'repository/uuid': '7446d4e9-8846-46c0-858a-34a2a1739d1c',
# 'repository_root': 'file:///tmp/test_repo',
# 'repository_uuid': '7446d4e9-8846-46c0-858a-34a2a1739d1c',
# 'url': 'file:///tmp/test_repo',
# 'wc-info/depth': None,
# 'wc-info/schedule': None,
# 'wc-info/wcroot-abspath': None,
# 'wcinfo_depth': None,
# 'wcinfo_schedule': None,
# 'wcinfo_wcroot_abspath': None}

NOTE: The keys named with dashes, slashes, and hashes are considered obsolete, and only available for backwards compatibility. We have since moved to using only underscores to separate words.

cat(rel_filepath)

Get file-data as string.

import svn.local

l = svn.local.LocalClient('/tmp/test_repo')
content = l.cat('test_file')

log_default(timestamp_from_dt=None, timestamp_to_dt=None, limit=None, rel_filepath='', stop_on_copy=False, revision_from=None, revision_to=None, changelist=False)

Perform a log-listing that can be bounded by time or revision number and/or take a maximum-count.

import svn.local

l = svn.local.LocalClient('/tmp/test_repo.co')

for e in l.log_default():
    print(e)

#LogEntry(date=datetime.datetime(2015, 4, 24, 3, 2, 39, 895975, tzinfo=tzutc()), msg='Added second file.', revision=2, author='dustin')
#LogEntry(date=datetime.datetime(2015, 4, 24, 2, 54, 2, 136170, tzinfo=tzutc()), msg='Initial commit.', revision=1, author='dustin')

export(to_path, revision=None, force=False)

Checkout the tree without embedding an meta-information.

import svn.remote

r = svn.remote.RemoteClient('file:///tmp/test_repo')
r.export('/tmp/test_export')

We can also use force option to force the svn export.

list(extended=False, rel_path=None)

Return either a flat-list of filenames or a list of objects describing even more information about each.

import pprint

import svn.local

l = svn.local.LocalClient('/tmp/test_repo.co')

# Flat list.

entries = l.list()
for filename in entries:
    print(filename)

#aa
#bb

# Extended information.

entries = l.list(extended=True)
for entry in entries:
    pprint.pprint(entry)

#{'author': 'dustin',
# 'commit_revision': 1,
# 'date': datetime.datetime(2015, 4, 24, 2, 54, 2, 136170, tzinfo=tzutc()),
# 'is_directory': False,
# 'kind': 'file',
# 'name': 'aa',
# 'size': 0,
# 'timestamp': datetime.datetime(2015, 4, 24, 2, 54, 2, 136170, tzinfo=tzutc())}
#{'author': 'dustin',
# 'commit_revision': 2,
# 'date': datetime.datetime(2015, 4, 24, 3, 2, 39, 895975, tzinfo=tzutc()),
# 'is_directory': False,
# 'kind': 'file',
# 'name': 'bb',
# 'size': 0,
# 'timestamp': datetime.datetime(2015, 4, 24, 3, 2, 39, 895975, tzinfo=tzutc())}

list_recursive(rel_path=None, yield_dirs=False, path_filter_cb=None)

List all entries at and beneath the root or given relative-path.

import pprint

import svn.local

l = svn.local.LocalClient('/tmp/test_repo.co')

for rel_path, e in l.list_recursive():
    print('')
    print('[' + rel_path + ']')
    print('')

    pprint.pprint(e)

#[]
#
#{'author': 'dustin',
# 'commit_revision': 1,
# 'date': datetime.datetime(2015, 4, 24, 2, 54, 2, 136170, tzinfo=tzutc()),
# 'is_directory': False,
# 'kind': 'file',
# 'name': 'aa',
# 'size': 0,
# 'timestamp': datetime.datetime(2015, 4, 24, 2, 54, 2, 136170, tzinfo=tzutc())}
#
#[]
#
#{'author': 'dustin',
# 'commit_revision': 2,
# 'date': datetime.datetime(2015, 4, 24, 3, 2, 39, 895975, tzinfo=tzutc()),
# 'is_directory': False,
# 'kind': 'file',
# 'name': 'bb',
# 'size': 0,
# 'timestamp': datetime.datetime(2015, 4, 24, 3, 2, 39, 895975, tzinfo=tzutc())}
#
#[dir1]
#
#{'author': 'dustin',
# 'commit_revision': 3,
# 'date': datetime.datetime(2015, 4, 24, 3, 25, 13, 479212, tzinfo=tzutc()),
# 'is_directory': False,
# 'kind': 'file',
# 'name': 'cc',
# 'size': 0,
# 'timestamp': datetime.datetime(2015, 4, 24, 3, 25, 13, 479212, tzinfo=tzutc())}

diff_summary(start_revision, end_revision)

A lower-level diff summary that doesn't actually provide the content differences.

import svn.remote

l = svn.remote.RemoteClient('http://svn.apache.org/repos/asf')
print l.diff_summary(1760022, 1760023)

# [{'item': 'modified',
#  'kind': 'file',
#  'path': 'http://svn.apache.org/repos/asf/sling/trunk/pom.xml'},
# {'item': 'added',
#  'kind': 'file',
#  'path': 'http://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/models/pom.xml'}]

diff(start_revision, end_revision)

Diffs between start and end revisions

Notice of Diff Reimplementation in 1.0.0

There was a previous contribution to the diff implementation that has been reported and confirmed to often throw an exception due to shoddy handling of the file-paths in the output. It also made secondary shell calls and mixed both text and XML output in the response. As a result of this, the decision has been made to just reimplement it and reshape the output in a backwards-incompatible way at the same time. If you need to stick to the older implementation, tie your dependencies to the 0.3.46 release.

pysvn's People

Contributors

daa avatar dsoprea avatar encompass avatar friedyam avatar fsiddi avatar gotakk avatar ideasman42 avatar jforand avatar jhosmer avatar johanzietsman-em avatar mheppner avatar ml-bnr avatar stevejefferiesidbs avatar sybrenstuvel avatar tbare598 avatar trozen avatar tusharmakkar08 avatar verybadsoldier avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pysvn's Issues

Unable to differentiate between SVN command failing and other errors

The library raises a ValueError when the SVN CLI client fails. This exception is very common, and can be raised for a number of reasons. As a result, it is difficult for the caller to distinguish between the SVN CLI client failing and other issues.

Please change the exception type, for example to a subclass of ValueError for backward compatibility. I've sent in a pull request (#43) for this.

Releasing a version with svn update and other nice, new features

Looks like you added support for svn update and other commands a couple weeks after the release of 0.3.44. Any plan to release these new features? They'd be really useful. For now, I can call run_command to do the svn update, but would prefer to do it the "right" way.

Thanks for writing this. It's incredibly nice to have a Python svn package that works in a virtualenv and doesn't need to be installed as a system package.

Advantages over PySvn

Hey @dsoprea

I was planning to add helpdoc in README.md or maybe host it via github.io, where we explain why our PySvn is better than Pysvn. I searched for this because the earlier Pysvn which I was using causes a lot of issues while setting up. Some of the rants of developers facing issues are:

This would do 2 things:

  • It would make clear why to have our Pysvn when the old Pysvn is already there
  • What benefits does our Pysvn provide over the old Pysvn

which would in-turn lead to more adaptability of our PySvn. What do you think about this?

Thanks

Issue with request like ^/tags

I notice that this command doesn't work :

repo.list(False, '^/tags')

This issue is due to the concatenation of the self.__url_or_path with the input path rel_filepath
Why do you think about change directory in the working directory before executing the command ?

license

Hi,

I'm working on a library @https://github.com/tony/libvcs/ that could utilize this project for richer functionality. However there is a snag I found that the current license on pysvn conflicts with libvcs (BSD).

Any thoughts on making this license compatible with MIT/BSD?

ValueError when URL not found

When trying to access a RemoteClient on a non-existent repo, it throws a slightly odd ValueError. This would be easier to handle errors correctly if this threw a more specific SvnError or SvnUrlNotFoundError or similar.

import svn.remote
r = svn.remote.RemoteClient("https://plugins.svn.wordpress.org/gravityforms/trunk")
r.checkout("gravity")

Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.4/dist-packages/svn/remote.py", line 20, in checkout
self.run_command('checkout', cmd)
File "/usr/local/lib/python3.4/dist-packages/svn/common.py", line 46, in run_command
(p.returncode, cmd, stdout))
ValueError: Command failed with (1): ['svn', '--non-interactive', 'checkout', 'https://plugins.svn.wordpress.org/gravityforms/trunk', 'gravity']
b"svn: E170000: URL 'https://plugins.svn.wordpress.org/gravityforms/trunk' doesn't exist\n"

remote_info entry_revision vs commit_revision

When running the svn command line client against a repo URL, I get:

Path: Config
URL: https://<root_url>/.../Config
Relative URL: .../Config
Repository Root: <root_url>
Repository UUID: c6c330d0-ed96-11df-a23f-a1aa3014a860
Revision: 1775750
Node Kind: directory
Last Changed Author: <author>
Last Changed Rev: 1616232
Last Changed Date: 2017-10-20 19:29:39 +0200 (Fr, 20 Okt 2017)

Revision is the HEAD repo revision, the 'Last Changed Rev' refers to the revision of the path 'Config' that I requested info for.

PySvn returns this:

'entry_revision' (139902232167152) = {int} 1775765
'commit_revision' (139902232121072) = {int} 1616232

I think the name entry_revision is misleading. It should be repo_revision.
What do you think?

six version requirement

I've just installed svn 0.3.38 on Python 2.7 using pip. It downgraded my version of six from 1.8.0 to 1.7.2. The current version on PyPI is 1.10.0.

Would you please consider changing requirements.txt to have six>=1.7.2

I have no immediate problem but if some other package makes the same call to use a fixed version of six then there could be a clash. The same goes for python-dateutil.

It is good for applications to use fixed versions in their requirements but libraries ought to be more flexible.

Feature Request: Have log_default() support the use of the -g flag (or --use-merge-history)

Would change the function signature to something like

def log_default(self, timestamp_from_dt=None, timestamp_to_dt=None,
                    limit=None, rel_filepath=None, stop_on_copy=False,
                    revision_from=None, revision_to=None, changelist=False,
                    use_merge_history=False):

and then somewhere in the function, would need to add

if use_merge_history is True:
 args += ['--use-merge-history]

import svn.remote - ImportError: No module named remote

I have installed in my Ubuntu 14.04 using the next:
pip install svn

and I tried the following code:

import svn.remote

r = svn.remote.RemoteClient('https://my.remote.repo/svn')
r.checkout('/tmp/working')

And I get the next error

Traceback (most recent call last):
  File "svn.py", line 1, in <module>
    import svn.remote
  File "/home/manu/Desktop/UQASAR/pythonanywhere/snv/svn.py", line 1, in <module>
    import svn.remote
ImportError: No module named remote

Maybe I forgot doing something?

Thanks in advance!

Creation of Test Suite

Hey @dsoprea

What do you think about forming a test suite for PySvn ? I can contribute for that if other maintainers can pitch in.

Thanks

Accepting a self signed certificate.

I think my PySvn is not working now due to a self signed certificate used on the svn server I am trying to connect to. Is there a way to deal with accepting the certificate from pysvn itself.
My code works just fine when there is no self signed cert.

list_recursive does not support browsing svn with windows client

I call list_recursive in a script running under windows .

in svn/common.py file, line 391 path extension is made using os.path
next_rel_path = os.path.join(current_rel_path, entry['name'])

I think this behavior is right if made on filesystem but if remoteclient is initialized using an url, this join must be replaced by specific code regarding where the remote client is "connected to" (i.e. file or url)

Please document that this is a wrapper for the CLI svn client

This library just wraps the svn commandline client, executing it using subprocess. In my opinion, this should be documented in the README, as it has implications for performance (each command needs to execute svn, which has to re-establish a HTTPS connection, etc.) as well as deployment (the machine the code runs on needs the svn CLI client).

properties method failed when no props defined

Ask for properties on an element taht does ot have properties defined raise an AttributeError NoneType as no attribute findall

svn\common.py", line 197, in properties
for p in target_elem.findall('property')]
AttributeError: 'NoneType' object has no attribute 'findall'

Need to robustify I think

Cannot install with pip on python 3.4

Hi. I tried to install this module with pip, but this is what I get (command is pip install svn):

I have python 3.4 installed.

Downloading/unpacking svn
  Downloading svn-0.3.18.tar.gz
  Running setup.py (path:C:\Users\XXXX\AppData\Local\Temp\pip_build_XXXX\svn\setup.py) egg_info for package svn
    Traceback (most recent call last):
      File "<string>", line 17, in <module>
      File "C:\Users\XXXX\AppData\Local\Temp\pip_build_XXXX\svn\setup.py", line 4, in <module>
        import svn
      File "C:\Users\XXXX\AppData\Local\Temp\pip_build_XXXX\svn\svn\__init__.py", line 1, in <module>
        from svn.local import LocalClient
      File "C:\Users\XXXX\AppData\Local\Temp\pip_build_XXXX\svn\svn\local.py", line 5, in <module>
        from svn import common
      File "C:\Users\Ferrarim\AppData\Local\Temp\pip_build_XXXX\svn\svn\common.py", line 3, in <module>
        import dateutil.parser
    ImportError: No module named 'dateutil'
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 17, in <module>

  File "C:\Users\XXXX\AppData\Local\Temp\pip_build_XXXX\svn\setup.py", line 4, in <module>

    import svn

  File "C:\Users\XXXX\AppData\Local\Temp\pip_build_XXXX\svn\svn\__init__.py", line 1, in <module>

    from svn.local import LocalClient

  File "C:\Users\XXXX\AppData\Local\Temp\pip_build_XXXX\svn\svn\local.py", line 5, in <module>

    from svn import common

  File "C:\Users\XXXX\AppData\Local\Temp\pip_build_XXXX\svn\svn\common.py", line 3, in <module>

    import dateutil.parser

ImportError: No module named 'dateutil'

Than I installed python-dateutil manually. After that now I get:

Downloading/unpacking svn
  Downloading svn-0.3.18.tar.gz
  Running setup.py (path:C:\Users\XXXX\AppData\Local\Temp\pip_build_XXXX\svn\setup.py) egg_info for package svn
    error in svn setup command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers
    Complete output from command python setup.py egg_info:
    error in svn setup command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers

----------------------------------------
Cleaning up...

And finally this is the pip debug log after the last pip install svn command:

Downloading/unpacking svn
  Getting page https://pypi.python.org/simple/svn/
  URLs to search for versions for svn:
  * https://pypi.python.org/simple/svn/
  Analyzing links from page https://pypi.python.org/simple/svn/
    Skipping https://pypi.python.org/packages/2.7/s/svn/svn-0.3.15-py2-none-any.whl#md5=8ceecff146a55ed64fe1b8152c60c29b (from https://pypi.python.org/simple/svn/) because it is not compatible with this Python
    Skipping https://pypi.python.org/packages/2.7/s/svn/svn-0.3.16-py2-none-any.whl#md5=21c54db306fa67440bea7bc422e14d03 (from https://pypi.python.org/simple/svn/) because it is not compatible with this Python
    Skipping https://pypi.python.org/packages/2.7/s/svn/svn-0.3.17-py2-none-any.whl#md5=aac01742e7b45a6488b5378a936f5250 (from https://pypi.python.org/simple/svn/) because it is not compatible with this Python
    Skipping https://pypi.python.org/packages/2.7/s/svn/svn-0.3.18-py2-none-any.whl#md5=3f34754ff5852e67df935c09af680d04 (from https://pypi.python.org/simple/svn/) because it is not compatible with this Python
    Found link https://pypi.python.org/packages/source/s/svn/svn-0.3.10.tar.gz#md5=b8ebb6a393f94f6b3fd6689e79ff6c4d (from https://pypi.python.org/simple/svn/), version: 0.3.10
    Found link https://pypi.python.org/packages/source/s/svn/svn-0.3.11.tar.gz#md5=fea56e83fe3f763487738ba0c0c08609 (from https://pypi.python.org/simple/svn/), version: 0.3.11
    Found link https://pypi.python.org/packages/source/s/svn/svn-0.3.12.tar.gz#md5=50e3a52b9e13758938801bed087e0d89 (from https://pypi.python.org/simple/svn/), version: 0.3.12
    Found link https://pypi.python.org/packages/source/s/svn/svn-0.3.13.tar.gz#md5=d02db603924f08663febdfee923414dc (from https://pypi.python.org/simple/svn/), version: 0.3.13
    Found link https://pypi.python.org/packages/source/s/svn/svn-0.3.14.tar.gz#md5=ea52c293eada1e7b7dc176c3810b2d0f (from https://pypi.python.org/simple/svn/), version: 0.3.14
    Found link https://pypi.python.org/packages/source/s/svn/svn-0.3.15.tar.gz#md5=9aa1ad131afdef7ef16938f158625efe (from https://pypi.python.org/simple/svn/), version: 0.3.15
    Found link https://pypi.python.org/packages/source/s/svn/svn-0.3.16.tar.gz#md5=5ad395d893f1149826c49fbe4eab1dd5 (from https://pypi.python.org/simple/svn/), version: 0.3.16
    Found link https://pypi.python.org/packages/source/s/svn/svn-0.3.17.tar.gz#md5=bd792a4806c2cba7113538e7f60e2c6c (from https://pypi.python.org/simple/svn/), version: 0.3.17
    Found link https://pypi.python.org/packages/source/s/svn/svn-0.3.18.tar.gz#md5=08950896bc3970e2c3817a3464c0af39 (from https://pypi.python.org/simple/svn/), version: 0.3.18
    Found link https://pypi.python.org/packages/source/s/svn/svn-0.3.3-dirty.tar.gz#md5=66e602acb420d74ad88440fc6be9f08c (from https://pypi.python.org/simple/svn/), version: 0.3.3-dirty
    Found link https://pypi.python.org/packages/source/s/svn/svn-0.3.4.tar.gz#md5=dc4560ae5e052c7e2dbed047dd2e3b1f (from https://pypi.python.org/simple/svn/), version: 0.3.4
    Found link https://pypi.python.org/packages/source/s/svn/svn-0.3.5.tar.gz#md5=857b6effd3c5f42593d81217a50f4caa (from https://pypi.python.org/simple/svn/), version: 0.3.5
    Found link https://pypi.python.org/packages/source/s/svn/svn-0.3.6.tar.gz#md5=167b6c2f7459895fe6589bd9e0beed00 (from https://pypi.python.org/simple/svn/), version: 0.3.6
    Found link https://pypi.python.org/packages/source/s/svn/svn-0.3.7.tar.gz#md5=ff9c44f0fc4d6e8908c97bb8fba58a63 (from https://pypi.python.org/simple/svn/), version: 0.3.7
  Ignoring link https://pypi.python.org/packages/source/s/svn/svn-0.3.3-dirty.tar.gz#md5=66e602acb420d74ad88440fc6be9f08c (from https://pypi.python.org/simple/svn/), version 0.3.3-dirty is a pre-release (use --pre to allow).
  Using version 0.3.18 (newest of versions: 0.3.18, 0.3.17, 0.3.16, 0.3.15, 0.3.14, 0.3.13, 0.3.12, 0.3.11, 0.3.10, 0.3.7, 0.3.6, 0.3.5, 0.3.4)
  Downloading svn-0.3.18.tar.gz
  Downloading from URL https://pypi.python.org/packages/source/s/svn/svn-0.3.18.tar.gz#md5=08950896bc3970e2c3817a3464c0af39 (from https://pypi.python.org/simple/svn/)
  Running setup.py (path:C:\Users\XXXX\AppData\Local\Temp\pip_build_XXXX\svn\setup.py) egg_info for package svn
    error in svn setup command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers
    Complete output from command python setup.py egg_info:
    error in svn setup command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers

----------------------------------------
Cleaning up...
  Removing temporary dir C:\Users\XXXX\AppData\Local\Temp\pip_build_XXXX...
Command python setup.py egg_info failed with error code 1 in C:\Users\XXXX\AppData\Local\Temp\pip_build_XXXX\svn
Exception information:
Traceback (most recent call last):
  File "C:\Python34\lib\site-packages\pip\basecommand.py", line 122, in main
    status = self.run(options, args)
  File "C:\Python34\lib\site-packages\pip\commands\install.py", line 278, in run
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
  File "C:\Python34\lib\site-packages\pip\req.py", line 1229, in prepare_files
    req_to_install.run_egg_info()
  File "C:\Python34\lib\site-packages\pip\req.py", line 325, in run_egg_info
    command_desc='python setup.py egg_info')
  File "C:\Python34\lib\site-packages\pip\util.py", line 697, in call_subprocess
    % (command_desc, proc.returncode, cwd))
pip.exceptions.InstallationError: Command python setup.py egg_info failed with error code 1 in C:\Users\XXXX\AppData\Local\Temp\pip_build_XXXX\svn

Feature Request: RemoteClient.checkout() could be returning a LocalClient

It would be convenient if the checkout-method from the RemoteClient would be returning a LocalClient ready for use.

This would change code like:

remote_client = svn.remote.RemoteClient(url)
remote_client.checkout(local_path)
local_client = svn.local.LocalClient(local_path)

into

remote_client = svn.remote.RemoteClient(url)
local_client = remote_client.checkout(local_path)

cleanup

this svn do not support to clean up?

Question

If I use this library,
How can I pass the optional parameter like username, password for check out source.

r = svn.remote.RemoteClient("http://var.lge.com/tst/svn/Tracer")
r.checkout('\tmp]test6')

CommonClient.default_log fails with KeyError if LogEntry doesn't contain a 'msg' Child

The current implementation of 'CommonClient.default_log' assumes that each 'logentry' always contains 'msg', 'author', and 'date' Elements in the XML output of svn log command.

I do have access to an svn repository where some few revisions don't contain 'msg' Elements.
(Perhaps this repository is corrupted, but I don't have administrator access to the svn repositoty to check it.)

It would be helpfull to provide default value '' to all fields of 'entry_info' in order to prevent a KeyError in
common.py, line 203 in such situation.

Permission denied

warning: W000013: Can't open file '/root/.subversion/servers': Permission denied\n\n']

Releasing 0.3.43

Taking advantage of #40 requires a release of that code. It would be great if we can update it on pypi. 😄

How to update the svn for removed/deleted files

How to update the svn for removed/deleted files

I don't see any function or method to update svn for deleted files. For addition, we do add, commit.

For removal of files the commit seems to be not working..

Regards,
Ramesh G

Support for Python 3.6?

Is someone working on upgrading to have support for Python 3.6?
If not I can attempt to contribute.

UnicodeDecodeError when return is not ASCII

File "D:\dev\python3\lib\site-packages\svn\common.py", line 52, in run_command
stdout = stdout.decode('ASCII')
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc8 in position 0: ordinal not in range(128)

In some cases, there's no author node in commit_node

In some cases, there's no authority request for commit, in this case , the command 'list' 's result doesn't has an 'author' node in the 'commit' info .
So in this case the line 255 "author = commit_node.find('author').text" will report an "NoneType has no attribute text" error.

checkout fails: UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 28: ordinal not in range(128)

Hello gentlemen,

when I use this code:

import svn.remote

r = svn.remote.RemoteClient(<myUrl>)
r.checkout('/tmp/working')

Then it fails with this exception:

pydev debugger: starting (pid: 7264)
pydev debugger: warning: trying to add breakpoint to file that does not exist: /usr/local/lib/python2.7/dist-packages/svn-0.3.44-py2.7.egg/svn/remote.py (will have no effect)
Traceback (most recent call last):
  File "/home/robin/.eclipse/org.eclipse.platform_4.6.2_1747617930_linux_gtk_x86/plugins/org.python.pydev_5.1.2.201606231256/pysrc/pydevd.py", line 1530, in <module>
    globals = debugger.run(setup['file'], None, None, is_module)
  File "/home/robin/.eclipse/org.eclipse.platform_4.6.2_1747617930_linux_gtk_x86/plugins/org.python.pydev_5.1.2.201606231256/pysrc/pydevd.py", line 937, in run
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "/home/robin/subversion/appl/pyRfJobQueue/trunk/svntest.py", line 4, in <module>
    r.checkout('/tmp/working')
  File "/usr/local/lib/python2.7/dist-packages/svn/remote.py", line 20, in checkout
    self.run_command('checkout', cmd)
  File "/usr/local/lib/python2.7/dist-packages/svn/common.py", line 78, in run_command
    return stdout.decode().strip('\n').split('\n')
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 28: ordinal not in range(128)


Using Python 2.7.3 on Ubuntu 12.04 LTS, svn 1.8.8.

I noticed that in common.py the variable LANG is set to 'en_US.UTF-8'. But my svn command line client seems to ignore it and use LANGUAGE instead.

Please see this console output which is supposed to prove it (my language is usually german):

robin@P-CZC3084WSD:/tmp$ LANG=en_US.UTF-8 svn
Geben Sie »svn help« für weitere Hilfe ein.
robin@P-CZC3084WSD:/tmp$ LANGUAGE=en_US.UTF-8 svn
Type 'svn help' for usage.

So setting LANG to 'en_US.UTF-8' does not give me english svn outputs but setting LANGUAGE to 'en_US.UTF-8' does.

When I go to common.py change this line:
environment_variables['LANG'] = 'en_US.UTF-8'
to
environment_variables['LANGUAGE'] = 'en_US.UTF-8'
then it works (no more exceptions).

I don't know why my svn uses LANGUAGE while others apparently use LANG. Maybe one solution for python-svn would be to set both LANG and LANGUAGE?

Thank you!

list_recursive error with E200009

I've been trying to list all the subdirectories in a repository, but I hit a wall where it says some targets don't exist. This might be because some subdirectories were removed/deleted from the repository. However, I am unable to skip those directories via a loop because of how the generator is designed. Is there some alternate way of doing this?

Add possibility to have 2 repositories instead of 1 in diff/diff_summary functions

svn diff normally allows to have 2 urls or targets: an old one and a new one.

diff (di): Display local changes or differences between two revisions or paths.
usage: 1. diff
       2. diff [-c M | -r N[:M]] [TARGET[@REV]...]
       3. diff [-r N[:M]] --old=OLD-TGT[@OLDREV] [--new=NEW-TGT[@NEWREV]] \
               [PATH...]
       4. diff OLD-URL[@OLDREV] NEW-URL[@NEWREV]
       5. diff OLD-URL[@OLDREV] NEW-PATH[@NEWREV]
       6. diff OLD-PATH[@OLDREV] NEW-URL[@NEWREV]

It would be nice to have an optional arguments in functions diff and diff_summary to have a new target.

Exception message is mixed by string and bytes.

Following codes in CommonBase Class of common_base.py

p = subprocess.Popen(
    cmd,
    stdout=subprocess.PIPE,
    stderr=subprocess.STDOUT,
    cwd=wd,
    env=env)

stdout = p.stdout.read()
r = p.wait()
p.stdout.close()

if r != success_code:
    raise svn.exception.SvnException(
        "Command failed with ({}): {}\n{}".format(
        p.returncode, cmd, stdout))

stdout is read from p.stdout. This is open with rb mode by default. So stdout is bytes

My env is python3.6. I handler the exception below

try:
    diff_list = remote_client.diff_summary(start_revision, end_revision)
except svn.exception.SvnException as e:
    print(e)

It will print it:

Command failed with (1): ['svn', '--non-interactive', '--username', 'test', '--password', 'test', '--no-auth-cache', 'diff', '--old', 'svn://localhost/proj1/trunk@0', '--new', 'svn://localhost/proj1/trunk@6', '--summarize', '--xml']
b'<?xml version="1.0" encoding="UTF-8"?>\n<diff>\n<paths>\nsvn: E170013: Unable to connect to a repository at URL \'svn://localhost/proj1/trunk\'\nsvn: E170001: Authentication error from server: Username not found\n'

svn import functionality?

Any interest in svn import functionality? I'm going to try and implement this if it hasn't been implemented somewhere already.

DNS resolution not working

When I checkout using this library then this code in common.py returns an error:

p = subprocess.Popen(cmd,
                             stdout=subprocess.PIPE,
                             stderr=subprocess.STDOUT,
                             env={'LANG': 'en_US.UTF-8'})

 stdout = p.stdout.read()
     r = p.wait()
      if r != success_code:
         raise SvnException("Command failed with (%s): %s\n%s".format(
              (p.returncode, cmd, stdout)))

stdout contains:
svn: E731001: Unable to connect to a repository at URL 'svn://dummydomain.corp/repos/testing/robot- framework-test/trunk' svn: E731001: Unknown hostname 'dummydomain.corp'

Invoking the very same command specified by 'cmd' manually in a shell works.

I think the problem is that the Popen call is using the parameter env and therefore effectively completely replacing the environment with the single variable 'LANG'.
I could fix the problem by just not using the env parameter:
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)

As a sidenote:
This does not produce a valid error string:
raise SvnException("Command failed with (%s): %s\n%s".format( (p.returncode, cmd, stdout)))
I think you cannot mix %s-syntax with format.

suggestions: --force as an option to export

export with --force is not possible
changed common.py:296 to

    def export(self, to_path, revision=None, force= False):
        cmd = []

        if revision is not None:
            cmd += ['-r', str(revision)]

        cmd += [self.__url_or_path, to_path]
        cmd.append('--force') if force else None
        self.run_command('export', cmd)

type str doesn't support the buffered api split('\n')

I'm using python 3.3, when I use a RemoteClient to list entries in a repository via file protocol , It reports the error "type str doesn't support the buffered api split('\n')"

It seems that in this case , the stdout object in run_command function turns to be an bytes object, so it should be decode to an str object. So I add " stdout = stdout.decode('utf-8') ", it seems works fine in my case . But I'm not sure does the 'utf-8' suit for all cases.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.