saltstack/salt — pull request #2445 by twinshadow (2012-11-05 03:16:10+00:00)
Title: Add the state file for Subversion

This adds the "latest" state for Subversion, mimicking the git and hg states. More to follow, as shown by the stubbed-out `dirty()` definition, for determining the cleanliness of a working directory, in `states/svn.py`.

Given the state file, svn_test.sls:

https://tshdw-svn-test.googlecode.com/svn/trunk:
svn.latest:
- target: /root/tshdw-svn-test
- username: accornehl@gmail.com
- force: True

https://tshdw-svn-test.googlecode.com/svn/trunk/nofun:
svn.latest:
- target: /root/nofun
- username: accornehl@gmail.com

Useful errors:

----------
State: - svn
Name: https://tshdw-svn-test.googlecode.com/svn/trunk/nofun
Function: latest
Result: False
Comment: An exception occured in this state: Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/salt/state.py", line 885, in call
ret = self.states[cdata['full']](*cdata['args'])
File "/var/cache/salt/extmods/states/svn.py", line 77, in latest
out = __salt__[svn_cmd](cwd, name, basename, user, username, *opts)
File "/usr/lib/python2.7/site-packages/salt/modules/svn.py", line 121, in checkout
return _run_svn("checkout", cwd, user, username, opts)
File "/usr/lib/python2.7/site-packages/salt/modules/svn.py", line 54, in _run_svn
raise exceptions.CommandExecutionError(result['stderr'] + '\n\n' + cmd)
CommandExecutionError: svn: E170000: URL 'https://tshdw-svn-test.googlecode.com/svn/trunk/nofun' doesn't exist

svn --non-interactive checkout "https://tshdw-svn-test.googlecode.com/svn/trunk/nofun" "nofun" "--username" "accornehl@gmail.com"

After creating the directory, checkouts and updates also provide userful tidbits:

----------
State: - svn
Name: https://tshdw-svn-test.googlecode.com/svn/trunk/nofun
Function: latest
Result: True
Comment: Checked out revision 6.
Changes:
----------
State: - svn
Name: https://tshdw-svn-test.googlecode.com/svn/trunk
Function: latest
Result: True
Comment: Updating 'tshdw-svn-test':
D tshdw-svn-test/test
A tshdw-svn-test/the flash
Updated to revision 5.
Changes: