saltstack/salt — pull request #2438 by twinshadow (2012-11-04 07:53:58+00:00)
Title: Add a module for SVN

The Salt state for SVN will be done soon. I went a little pedantic with handling shell strings since `cmdmod.py` uses `shell=True` for all commands, so I figured I would see how well my little stunt in `_run_svn()` goes down.

This is part of #2430

Committing files from the working-directory

% salt 'brynhilde' svn.commit /root/tshdw-svn-test targets="test foobar" msg="I don't know what I'm doing" username="accornehl@gmail.com"

{'brynhilde': 'Adding foobar\nTransmitting file data .\nCommitted revision 3.'}

Info on multiple files and URLs

% salt 'brynhilde' svn.info /root/tshdw-svn-test targets="test foobar . http://tshdw-svn-test.googlecode.com/svn/trunk" fmt="dict"

{'brynhilde': [{'Checksum': 'da39a3ee5e6b4b0d3255bfef95601890afd80709',
'Last Changed Author': 'accornehl@gmail.com',
'Last Changed Date': '2012-11-04 05:05:32 +0000 (Sun, 04 Nov 2012)',
'Last Changed Rev': '2',
'Name': 'test',
'Node Kind': 'file',
'Path': 'test',
'Repository Root': 'https://tshdw-svn-test.googlecode.com/svn',
'Repository UUID': '68e35d6d-ba10-8cfd-e90d-990ce18119f9',
'Revision': '2',
'Schedule': 'normal',
'Text Last Updated': '2012-11-03 20:53:57 +0000 (Sat, 03 Nov 2012)',
'URL': 'https://tshdw-svn-test.googlecode.com/svn/trunk/test',
'Working Copy Root Path': '/root/tshdw-svn-test'},
{'Checksum': 'da39a3ee5e6b4b0d3255bfef95601890afd80709',
'Last Changed Author': 'accornehl@gmail.com',
'Last Changed Date': '2012-11-04 06:12:53 +0000 (Sun, 04 Nov 2012)',
'Last Changed Rev': '3',
'Name': 'foobar',
'Node Kind': 'file',
'Path': 'foobar',
'Repository Root': 'https://tshdw-svn-test.googlecode.com/svn',
'Repository UUID': '68e35d6d-ba10-8cfd-e90d-990ce18119f9',
'Revision': '3',
'Schedule': 'normal',
'Text Last Updated': '2012-11-03 20:59:50 +0000 (Sat, 03 Nov 2012)',
'URL': 'https://tshdw-svn-test.googlecode.com/svn/trunk/foobar',
'Working Copy Root Path': '/root/tshdw-svn-test'},
{'Last Changed Author': 'accornehl@gmail.com',
'Last Changed Date': '2012-11-04 05:05:32 +0000 (Sun, 04 Nov 2012)',
'Last Changed Rev': '2',
'Node Kind': 'directory',
'Path': '.',
'Repository Root': 'https://tshdw-svn-test.googlecode.com/svn',
'Repository UUID': '68e35d6d-ba10-8cfd-e90d-990ce18119f9',
'Revision': '2',
'Schedule': 'normal',
'URL': 'https://tshdw-svn-test.googlecode.com/svn/trunk',
'Working Copy Root Path': '/root/tshdw-svn-test'},
{'Last Changed Author': 'accornehl@gmail.com',
'Last Changed Date': '2012-11-04 06:12:53 +0000 (Sun, 04 Nov 2012)',
'Last Changed Rev': '3',
'Node Kind': 'directory',
'Path': 'trunk',
'Repository Root': 'http://tshdw-svn-test.googlecode.com/svn',
'Repository UUID': '68e35d6d-ba10-8cfd-e90d-990ce18119f9',
'Revision': '3',
'URL': 'http://tshdw-svn-test.googlecode.com/svn/trunk'}]}

Checkout of a SVN repository. You don't expect me to evaluate newlines in strings, right?

salt 'brynhilde' svn.checkout /home/root http://dpkt.googlecode.com/svn/trunk/ target=dpkt

{'brynhilde': 'A dpkt/LICENSE\nA dpkt/dpkt\nA dpkt/dpkt/udp.py\nA dpkt/dpkt/rx.py\nA dpkt/dpkt/loopback.py\nA dpkt/dpkt/ip6.py\nA dpkt/dpkt/__init__.py\nA dpkt/dpkt/ipx.py\nA dpkt/dpkt/mrt.py\nA dpkt/dpkt/asn1.py\nA dpkt/dpkt/netbios.py\nA
dpkt/dpkt/ieee80211.py\nA dpkt/dpkt/tns.py\nA dpkt/dpkt/bgp.py\nA dpkt/dpkt/gre.py\nA dpkt/dpkt/tftp.py\nA dpkt/dpkt/crc32c.py\nA dpkt/dpkt/pppoe.py\nA dpkt/dpkt/pcap.py\nA dpkt/dpkt/vrrp.py\nA dpkt/dpkt/rip.py\nA dpkt/dpkt/ntp.py\nA dpkt/
dpkt/radiotap.py\nA dpkt/dpkt/rtp.py\nA dpkt/dpkt/cdp.py\nA dpkt/dpkt/ospf.py\nA dpkt/dpkt/hsrp.py\nA dpkt/dpkt/dhcp.py\nA dpkt/dpkt/h225.py\nA dpkt/dpkt/rpc.py\nA dpkt/dpkt/pim.py\nA dpkt/dpkt/radius.py\nA dpkt/dpkt/ssl_ciphersuites.py\nA d
pkt/dpkt/sll.py\nA dpkt/dpkt/telnet.py\nA dpkt/dpkt/sip.py\nA dpkt/dpkt/snoop.py\nA dpkt/dpkt/ssl.py\nA dpkt/dpkt/dpkt.py\nA dpkt/dpkt/aim.py\nA dpkt/dpkt/stp.py\nA dpkt/dpkt/gzip.py\nA dpkt/dpkt/rfb.py\nA dpkt/dpkt/ethernet.py\nA dpkt/dpkt/
http.py\nA dpkt/dpkt/qq.py\nA dpkt/dpkt/tpkt.py\nA dpkt/dpkt/tcp.py\nA dpkt/dpkt/dtp.py\nA dpkt/dpkt/ah.py\nA dpkt/dpkt/sccp.py\nA dpkt/dpkt/icmp.py\nA dpkt/dpkt/stun.py\nA dpkt/dpkt/diameter.py\nA dpkt/dpkt/igmp.py\nA dpkt/dpkt/pmap.py\nA
dpkt/dpkt/ppp.py\nA dpkt/dpkt/ip.py\nA dpkt/dpkt/sctp.py\nA dpkt/dpkt/llc.py\nA dpkt/dpkt/icmp6.py\nA dpkt/dpkt/netflow.py\nA dpkt/dpkt/yahoo.py\nA dpkt/dpkt/smb.py\nA dpkt/dpkt/arp.py\nA dpkt/dpkt/dns.py\nA dpkt/dpkt/esp.py\nA dpkt/tests\
nA dpkt/tests/test-perf.py\nA dpkt/tests/test-perf2.py\nA dpkt/HACKING\nA dpkt/AUTHORS\nA dpkt/setup.py\nA dpkt/CHANGES\nA dpkt/README\nA dpkt/Makefile\nA dpkt/examples\nA dpkt/examples/ping.py\nA dpkt/examples/nbtping.py\nA dpkt/examples
/dnsping.py\nA dpkt/examples/dhcprequest.py\nChecked out revision 84.'}

Removing a remote file and updating the working-directory

% salt 'brynhilde' svn.remove . https://tshdw-svn-test.googlecode.com/svn/trunk/test username="accornehl@gmail.com" msg="Don't pick up wooden nickels"
{'brynhilde': '\nCommitted revision 4.'}

% salt 'brynhilde' svn.update /root/tshdw-svn-test
{'brynhilde': "Updating '.':\nD test\nUpdated to revision 4."}