Separate automatic schedulers for builders depending on is_legacy_mode. 

Changes from SVN should be scheduled for builders which checkout from SVN, changes from github should be scheduled for builders which checkout from github. For a transition period we need the both types of schedulers.

Patch by Andrei Lebedev.

Differential Revision: https://reviews.llvm.org/D69159

git-svn-id: https://llvm.org/svn/llvm-project/zorg/trunk@375204 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/buildbot/osuosl/master/config/schedulers.py b/buildbot/osuosl/master/config/schedulers.py
index 07b9b2e..0bcae8b 100644
--- a/buildbot/osuosl/master/config/schedulers.py
+++ b/buildbot/osuosl/master/config/schedulers.py
@@ -23,17 +23,40 @@
     }
 
     builders_with_automatic_schedulers = []
+    legacy_builders_with_automatic_schedulers = []
     for builder in builders:
         # Only for the builders created with LLVMBuildFactory or similar.
         if getattr(builder['factory'], 'depends_on_projects', None):
-            # And only if this builder is in the legacy mode and
-            # does not yet have an assigned scheduler.
-            if getattr(builder['factory'], 'is_legacy_mode', True) and \
-               builder['name'] not in builders_with_schedulers:
-                # This builder is a candidate for an automatic scheduler.
+            if getattr(builder['factory'], 'is_legacy_mode', True):
+                # Only if this builder is in the legacy mode and
+                # does not yet have an assigned scheduler.
+                if builder['name'] not in builders_with_schedulers:
+                    legacy_builders_with_automatic_schedulers.append(builder)
+            else:
+                # There are no manually assigned schedulers in this case.
                 builders_with_automatic_schedulers.append(builder)
 
     automatic_schedulers = []
+    automatic_schedulers.extend(
+         _getSingleBranchAutomaticSchedulers(
+            builders_with_automatic_schedulers,
+            filter_branch='master',     # git monorepo branch.
+            treeStableTimer=kwargs.get('treeStableTimer', 2*60)))
+    automatic_schedulers.extend(
+        _getSingleBranchAutomaticSchedulers(
+            legacy_builders_with_automatic_schedulers,
+            filter_branch='trunk',      # svn repo branch.
+            treeStableTimer=kwargs.get('treeStableTimer', 2*60)))
+
+    return automatic_schedulers
+
+def _getSingleBranchAutomaticSchedulers(
+        builders_with_automatic_schedulers,
+        filter_branch,
+        treeStableTimer):
+
+    automatic_schedulers = []
+
     # Do we have any to take care of?
     if builders_with_automatic_schedulers:
         # Let's reconsile first to get a unique set of dependencies.
@@ -43,8 +66,6 @@
             for b in builders_with_automatic_schedulers
         ])
 
-        treeStableTimer = kwargs.get('treeStableTimer', 2*60)
-        automatic_schedulers = []
         for projects in set_of_dependencies:
             sch_builders = [
                 b['name']
@@ -52,7 +73,7 @@
                 if frozenset(getattr(b['factory'], 'depends_on_projects')) == projects
             ]
 
-            automatic_scheduler_name = ",".join(sorted(projects))
+            automatic_scheduler_name =  filter_branch + ":" + ",".join(sorted(projects))
             projects_to_filter = getProjectsToFilter(projects)
 
             automatic_schedulers.append(
@@ -60,13 +81,13 @@
                     name=automatic_scheduler_name,
                     treeStableTimer=treeStableTimer,
                     builderNames=sch_builders,
-                    change_filter=ChangeFilter(project=projects_to_filter)
+                    change_filter=ChangeFilter(project=projects_to_filter, branch=filter_branch)
                 )
             )
 
             log.msg(
                 "Generated SingleBranchScheduler: { name='%s'" % automatic_scheduler_name,
                 ", builderNames=", sch_builders,
-                ", change_filter=", projects_to_filter,
+                ", change_filter=", projects_to_filter, " (branch: %s)" % filter_branch,
                 "}")
     return automatic_schedulers