Fill out svn state

single quotes
add a top doc string
use .format
add import comments
This commit is contained in:
Thomas S Hatch 2012-11-12 22:04:46 -07:00
parent 645889f05e
commit a01483463e

View File

@ -1,18 +1,36 @@
'''
Manage SVN repositories
=======================
Manage repositiry checkouts via the svn vcs system:
.. code-block:: yaml
http://unladen-swallow.googlecode.com/svn/trunk/:
svn.latest:
- target: /tmp/swallow
'''
# Import Python libs
import logging
import os
# Import Salt libs
from salt import exceptions
from salt.states.git import _fail, _neutral_test
log = logging.getLogger(__name__)
def __virtual__():
'''
Only load if svn is available
'''
if __salt__["cmd.has_exec"]("svn"):
return "svn"
if __salt__['cmd.has_exec']('svn'):
return 'svn'
return False
def latest(name,
target=None,
rev=None,
@ -20,7 +38,7 @@ def latest(name,
username=None,
force=None,
externals=True):
"""
'''
Checkout or update the working directory to the latest revision from the
remote repository.
@ -47,46 +65,46 @@ def latest(name,
externals : True
Change to False to not checkout or update externals
"""
'''
ret = {'name': name, 'result': True, 'comment': '', 'changes': {}}
if not target:
return _fail(ret, '"target option is required')
return _fail(ret, 'Target option is required')
svn_cmd = "svn.checkout"
svn_cmd = 'svn.checkout'
cwd, basename = os.path.split(target)
opts = tuple()
if os.path.exists(target) and not os.path.isdir(target):
return _fail(ret,
"The path, %s, exists and is not a directory." % target)
'The path "{0}" exists and is not a directory.'.format(target))
try:
__salt__["svn.info"](".", target, user=user)
svn_cmd = "svn.update"
__salt__['svn.info']('.', target, user=user)
svn_cmd = 'svn.update'
except exceptions.CommandExecutionError:
pass
if rev:
opts += ("-r", str(rev))
opts += ('-r', str(rev))
if force:
opts += ("--force",)
opts += ('--force',)
if externals is False:
opts += ("--ignore-externals",)
opts += ('--ignore-externals',)
if svn_cmd == "svn.update":
if svn_cmd == 'svn.update':
out = __salt__[svn_cmd](cwd, basename, user, *opts)
else:
out = __salt__[svn_cmd](cwd, name, basename, user, username, *opts)
ret["comment"] = out
ret['comment'] = out
return ret
def dirty(target,
user=None,
ignore_unversioned=False):
"""
'''
Determine if the working directory has been changed.
"""
'''
ret = {'name': name, 'result': True, 'comment': '', 'changes': {}}
return _fail(ret, "This function is not implemented yet.")
return _fail(ret, 'This function is not implemented yet.')