Sat May  3 22:25:20 BST 2008  Neil Hemingway <neil.hemingway@greyhavens.org.uk>
  * #261: Recognise branch deletions
diff -rN -u old-buildbot_pristine/buildbot/changes/svnpoller.py new-buildbot_pristine/buildbot/changes/svnpoller.py
--- old-buildbot_pristine/buildbot/changes/svnpoller.py	2008-05-03 22:26:05.000000000 +0100
+++ new-buildbot_pristine/buildbot/changes/svnpoller.py	2008-05-03 22:26:05.000000000 +0100
@@ -402,6 +402,7 @@
             branches = {}
             pathlist = el.getElementsByTagName("paths")[0]
             for p in pathlist.getElementsByTagName("path"):
+                action = p.getAttribute("action")
                 path = "".join([t.data for t in p.childNodes])
                 # the rest of buildbot is certaily not yet ready to handle
                 # unicode filenames, because they get put in RemoteCommands
@@ -411,21 +412,32 @@
                 if path.startswith("/"):
                     path = path[1:]
                 where = self._transform_path(path)
+
                 # if 'where' is None, the file was outside any project that
                 # we care about and we should ignore it
                 if where:
                     branch, filename = where
                     if not branch in branches:
-                        branches[branch] = []
-                    branches[branch].append(filename)
+                        branches[branch] = { 'files': []}
+                    branches[branch]['files'].append(filename)
+
+                    if not branches[branch].has_key('action'):
+                        branches[branch]['action'] = action
+
+            for branch in branches.keys():
+                action = branches[branch]['action']
+                files  = branches[branch]['files']
+                number_of_files_changed = len(files)
 
-            for branch in branches:
-                c = Change(who=author,
-                           files=branches[branch],
-                           comments=comments,
-                           revision=revision,
-                           branch=branch)
-                changes.append(c)
+                if action == u'D' and number_of_files_changed == 1 and files[0] == '':
+                    log.msg("Ignoring deletion of branch '%s'" % branch)
+                else:
+                    c = Change(who=author,
+                               files=files,
+                               comments=comments,
+                               revision=revision,
+                               branch=branch)
+                    changes.append(c)
 
         return changes
 
diff -rN -u old-buildbot_pristine/buildbot/test/test_svnpoller.py new-buildbot_pristine/buildbot/test/test_svnpoller.py
--- old-buildbot_pristine/buildbot/test/test_svnpoller.py	2008-05-03 22:26:05.000000000 +0100
+++ new-buildbot_pristine/buildbot/test/test_svnpoller.py	2008-05-03 22:26:05.000000000 +0100
@@ -117,7 +117,33 @@
 # output from svn log on .../SVN-Repository/sample
 # (so it includes trunk and branches)
 sample_base = "file:///usr/home/warner/stuff/Projects/BuildBot/trees/misc/_trial_temp/test_vc/repositories/SVN-Repository/sample"
-sample_logentries = [None] * 4
+sample_logentries = [None] * 6
+
+sample_logentries[5] = """\
+<logentry
+   revision="6">
+<author>warner</author>
+<date>2006-10-01T19:35:16.165664Z</date>
+<paths>
+<path
+   action="D">/sample/branch/version.c</path>
+</paths>
+<msg>revised_to_2</msg>
+</logentry>
+"""
+
+sample_logentries[4] = """\
+<logentry
+   revision="5">
+<author>warner</author>
+<date>2006-10-01T19:35:16.165664Z</date>
+<paths>
+<path
+   action="D">/sample/branch</path>
+</paths>
+<msg>revised_to_2</msg>
+</logentry>
+"""
 
 sample_logentries[3] = """\
 <logentry
@@ -293,6 +319,27 @@
         self.failUnlessEqual(changes[0].revision, '4')
         self.failUnlessEqual(changes[0].files, ["version.c"])
 
+        # and now pull in r5 (should *not* create a change as it's a
+        # branch deletion
+        doc = s.parse_logs(make_changes_output(5))
+        newlast, logentries = s._filter_new_logentries(doc, newlast)
+        self.failUnlessEqual(newlast, 5)
+        # so we see revision 5 as being new
+        changes = s.create_changes(logentries)
+        self.failUnlessEqual(len(changes), 0)
+
+        # and now pull in r6 (should create a change as it's not
+        # deleting an entire branch
+        doc = s.parse_logs(make_changes_output(6))
+        newlast, logentries = s._filter_new_logentries(doc, newlast)
+        self.failUnlessEqual(newlast, 6)
+        # so we see revision 6 as being new
+        changes = s.create_changes(logentries)
+        self.failUnlessEqual(len(changes), 1)
+        self.failUnlessEqual(changes[0].branch, 'branch')
+        self.failUnlessEqual(changes[0].revision, '6')
+        self.failUnlessEqual(changes[0].files, ["version.c"])
+
     def testFirstTime(self):
         base = "file:///home/warner/stuff/Projects/BuildBot/trees/svnpoller/_trial_temp/test_vc/repositories/SVN-Repository/sample"
         s = SVNPoller(base, split_file=split_file)


