version_added for switch Parameter changed to 2.0

Add comment to explain check_rc Parameter in _exec Function
Optimize code and clean up is_svn_repo Function
reviewable/pr18780/r1
Benjamin Baumer 9 years ago
parent 20f76d76a8
commit 8255657ac9

@ -82,7 +82,7 @@ options:
required: false required: false
default: "yes" default: "yes"
choices: [ "yes", "no" ] choices: [ "yes", "no" ]
version_added: "1.6" version_added: "2.0"
description: description:
- If C(no), do not call svn switch before update. - If C(no), do not call svn switch before update.
''' '''
@ -111,6 +111,7 @@ class Subversion(object):
self.svn_path = svn_path self.svn_path = svn_path
def _exec(self, args, check_rc=True): def _exec(self, args, check_rc=True):
'''Execute a subversion command, and return output. If check_rc is False, returns the return code instead of the output.'''
bits = [ bits = [
self.svn_path, self.svn_path,
'--non-interactive', '--non-interactive',
@ -122,20 +123,16 @@ class Subversion(object):
if self.password: if self.password:
bits.extend(["--password", self.password]) bits.extend(["--password", self.password])
bits.extend(args) bits.extend(args)
rc, out, err = self.module.run_command(bits, check_rc)
if check_rc: if check_rc:
rc, out, err = self.module.run_command(bits, check_rc)
return out.splitlines() return out.splitlines()
else: else:
rc, out, err = self.module.run_command(bits, check_rc)
return rc return rc
def is_svn_repo(self): def is_svn_repo(self):
'''Checks if path is a SVN Repo.''' '''Checks if path is a SVN Repo.'''
rc = self._exec(["info", self.dest], check_rc=False) rc = self._exec(["info", self.dest], check_rc=False)
if rc == 0: return rc == 0
return True
else:
return False
def checkout(self): def checkout(self):
'''Creates new svn working directory if it does not already exist.''' '''Creates new svn working directory if it does not already exist.'''

Loading…
Cancel
Save