Danijel
Danijel

Reputation: 8606

pysvn: How to find out if local dir is under version control?

Using pysvn to check some SVN working copy properties.

What is the easy way of finding out if a local directory c:\SVN\dir1 is under version control or not?

Upvotes: 1

Views: 745

Answers (1)

falsetru
falsetru

Reputation: 369064

pysvn.Client.info will raise pysvn.ClientError if you pass non working copy directory:

>>> import pysvn
>>> client = pysvn.Client()
>>> client.info('/tmp')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
pysvn._pysvn_2_7.ClientError: '/tmp' is not a working copy

You can use that behavior. By catching the exception:

>>> try:
...     client.info('/tmp')
... except pysvn.ClientError:
...     print('not working copy')
... else:
...     print('working copy')
...
not working copy

Upvotes: 1

Related Questions