Skip to content

Commit

Permalink
Make SVN's purgeAndUpdate correctly not delete svn:external directories.
Browse files Browse the repository at this point in the history
  • Loading branch information
TimothyFitz committed Jul 28, 2010
1 parent d5081cc commit 780a6bc
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
16 changes: 12 additions & 4 deletions slave/buildslave/commands/svn.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,23 @@ def _purgeAndUpdate(self):
return self._dovccmd('status', args, keepStdout=True, sendStdout=False,
cb=self._purgeAndUpdate2)

def _purgeAndUpdate2(self, res):
@staticmethod
def getUnversionedFiles(stdout, keep_on_purge):
"""Delete everything that shown up on status."""
result_xml = parseString(self.command.stdout)
result_xml = parseString(stdout)
for entry in result_xml.getElementsByTagName('entry'):
(wc_status,) = entry.getElementsByTagName('wc-status')
if wc_status.getAttribute('item') == 'external':
continue
filename = entry.getAttribute('path')
if filename in self.keep_on_purge:
if filename in keep_on_purge:
continue
yield filename

def _purgeAndUpdate2(self, res):
for filename in self.getUnversionedFiles(self.command.stdout, self.keep_on_purge):
filepath = os.path.join(self.builder.basedir, self.workdir,
filename)
filename)
self.sendStatus({'stdout': "%s\n" % filepath})
if os.path.isfile(filepath):
os.chmod(filepath, 0700)
Expand Down
21 changes: 21 additions & 0 deletions slave/buildslave/test/unit/test_commands_svn.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,24 @@ def test_simple(self):
d = self.run_command()
d.addCallback(self.check_sourcedata, "http://svn.local/app/trunk\n")
return d


class TestGetUnversionedFiles(unittest.TestCase):
def test_getUnversionedFIles_does_not_list_externals(self):
svn_st_xml = """<?xml version="1.0"?>
<status>
<target path=".">
<entry path="svn_external_path">
<wc-status props="none" item="external">
</wc-status>
</entry>
<entry path="svn_external_path/unversioned_file">
<wc-status props="none" item="unversioned">
</wc-status>
</entry>
</target>
</status>
"""
unversioned_files = list(svn.SVN.getUnversionedFiles(svn_st_xml, []))
self.assertEquals(["svn_external_path/unversioned_file"], unversioned_files)

0 comments on commit 780a6bc

Please sign in to comment.