commit
31a56e23f2
1 changed files with 15 additions and 7 deletions
|
@ -123,7 +123,12 @@ class Subversion(object):
|
||||||
|
|
||||||
def export(self, force=False):
|
def export(self, force=False):
|
||||||
'''Export svn repo to directory'''
|
'''Export svn repo to directory'''
|
||||||
self._exec(["export", "-r", self.revision, self.repo, self.dest])
|
cmd = ["export"]
|
||||||
|
if force:
|
||||||
|
cmd.append("--force")
|
||||||
|
cmd.extend(["-r", self.revision, self.repo, self.dest])
|
||||||
|
|
||||||
|
self._exec(cmd)
|
||||||
|
|
||||||
def switch(self):
|
def switch(self):
|
||||||
'''Change working directory's repo.'''
|
'''Change working directory's repo.'''
|
||||||
|
@ -173,7 +178,7 @@ def main():
|
||||||
dest=dict(required=True),
|
dest=dict(required=True),
|
||||||
repo=dict(required=True, aliases=['name', 'repository']),
|
repo=dict(required=True, aliases=['name', 'repository']),
|
||||||
revision=dict(default='HEAD', aliases=['rev', 'version']),
|
revision=dict(default='HEAD', aliases=['rev', 'version']),
|
||||||
force=dict(default='yes', type='bool'),
|
force=dict(default='no', type='bool'),
|
||||||
username=dict(required=False),
|
username=dict(required=False),
|
||||||
password=dict(required=False),
|
password=dict(required=False),
|
||||||
executable=dict(default=None),
|
executable=dict(default=None),
|
||||||
|
@ -194,7 +199,7 @@ def main():
|
||||||
os.environ['LANG'] = 'C'
|
os.environ['LANG'] = 'C'
|
||||||
svn = Subversion(module, dest, repo, revision, username, password, svn_path)
|
svn = Subversion(module, dest, repo, revision, username, password, svn_path)
|
||||||
|
|
||||||
if not os.path.exists(dest):
|
if export or not os.path.exists(dest):
|
||||||
before = None
|
before = None
|
||||||
local_mods = False
|
local_mods = False
|
||||||
if module.check_mode:
|
if module.check_mode:
|
||||||
|
@ -202,7 +207,7 @@ def main():
|
||||||
if not export:
|
if not export:
|
||||||
svn.checkout()
|
svn.checkout()
|
||||||
else:
|
else:
|
||||||
svn.export()
|
svn.export(force=force)
|
||||||
elif os.path.exists("%s/.svn" % (dest, )):
|
elif os.path.exists("%s/.svn" % (dest, )):
|
||||||
# Order matters. Need to get local mods before switch to avoid false
|
# Order matters. Need to get local mods before switch to avoid false
|
||||||
# positives. Need to switch before revert to ensure we are reverting to
|
# positives. Need to switch before revert to ensure we are reverting to
|
||||||
|
@ -222,6 +227,9 @@ def main():
|
||||||
else:
|
else:
|
||||||
module.fail_json(msg="ERROR: %s folder already exists, but its not a subversion repository." % (dest, ))
|
module.fail_json(msg="ERROR: %s folder already exists, but its not a subversion repository." % (dest, ))
|
||||||
|
|
||||||
|
if export:
|
||||||
|
module.exit_json(changed=True)
|
||||||
|
else:
|
||||||
after = svn.get_revision()
|
after = svn.get_revision()
|
||||||
changed = before != after or local_mods
|
changed = before != after or local_mods
|
||||||
module.exit_json(changed=changed, before=before, after=after)
|
module.exit_json(changed=changed, before=before, after=after)
|
||||||
|
|
Loading…
Reference in a new issue