Skip to content

Commit

Permalink
Merge ludovicchabant/buildbot:mswinsteps (PR #1129)
Browse files Browse the repository at this point in the history
+autopep8, pyflakes
  • Loading branch information
djmitche committed Apr 9, 2014
2 parents 271c1df + f154ad1 commit d3364bf
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 5 deletions.
20 changes: 16 additions & 4 deletions master/buildbot/steps/mswin.py
Expand Up @@ -29,7 +29,7 @@ class Robocopy(ShellCommand):
This is just a wrapper around the standard shell command that
will handle arguments and return codes accordingly for Robocopy.
"""
renderables = ['source', 'destination', 'files', 'exclude']
renderables = ['source', 'destination', 'files', 'exclude_files', 'exclude_dirs', 'custom_opts']

# Robocopy exit flags (they are combined to make up the exit code)
# See: http://ss64.com/nt/robocopy-exit.html
Expand All @@ -45,6 +45,9 @@ def __init__(self, source, destination,
mirror=False,
move=False,
exclude=None,
exclude_files=None,
exclude_dirs=None,
custom_opts=None,
verbose=False,
**kwargs):
self.source = source
Expand All @@ -53,7 +56,11 @@ def __init__(self, source, destination,
self.recursive = recursive
self.mirror = mirror
self.move = move
self.exclude = exclude
self.exclude_files = exclude_files
if exclude and not exclude_files:
self.exclude_files = exclude
self.exclude_dirs = exclude_dirs
self.custom_opts = custom_opts
self.verbose = verbose
ShellCommand.__init__(self, **kwargs)

Expand All @@ -67,11 +74,16 @@ def start(self):
command.append('/MIR')
if self.move:
command.append('/MOVE')
if self.exclude:
if self.exclude_files:
command.append('/XF')
command += self.exclude
command += self.exclude_files
if self.exclude_dirs:
command.append('/XD')
command += self.exclude_dirs
if self.verbose:
command.append('/V /TS /FP')
if self.custom_opts:
command += self.custom_opts
command += ['/TEE', '/NP']
self.setCommand(command)
ShellCommand.start(self)
Expand Down
14 changes: 14 additions & 0 deletions master/buildbot/test/unit/test_steps_mswin.py
Expand Up @@ -98,6 +98,20 @@ def test_exclude(self):
expected_args=['blah*', '/XF', '*.foo', '*.bar']
)

def test_exclude_files(self):
return self._run_simple_test(
r'D:\source', r'E:\dest', files=['blah*'],
exclude_files=['*.foo', '*.bar'],
expected_args=['blah*', '/XF', '*.foo', '*.bar']
)

def test_exclude_dirs(self):
return self._run_simple_test(
r'D:\source', r'E:\dest', files=['blah*'],
exclude_dirs=['foo', 'bar'],
expected_args=['blah*', '/XD', 'foo', 'bar']
)

@defer.inlineCallbacks
def test_codes(self):
# Codes that mean uneventful copies (including no copy at all).
Expand Down
8 changes: 7 additions & 1 deletion master/docs/manual/cfg-buildsteps.rst
Expand Up @@ -2226,9 +2226,15 @@ Available constructor arguments are:
``move``
Delete the source directory after the copy is complete (``/MOVE`` parameter).

``exclude``
``exclude_files``
An array of file names or patterns to exclude from the copy (``/XF`` parameter).

``exclude_dirs``
An array of directory names or patterns to exclude from the copy (``/XD`` parameter).

``custom_opts``
An array of custom parameters to pass directly to the ``robocopy`` command.

``verbose``
Whether to output verbose information (``/V /TS /TP`` parameters).

Expand Down

0 comments on commit d3364bf

Please sign in to comment.