Repository: buildbot/buildbot

Issue:
Slightly decoupled ForceScheduler
The main aim of this change was to allow me to subclass ForceScheduler and run additional "smarts" before a build was queued. This accomplishes that and takes a step towards a more decoupled ForcedScheduler based on discussion in IRC.

For me, I can subclass and extend gatherPropertiesAndChanges or I can use a Parameter class (now that they can use deferreds).

For every one else, the scheduler no longer requires a request object. The IRC bot could now be refactored to do something like:

```
sched.force("Jc2k", "builder_name", someprop="hello", somepro="woo", ...)
```

And the defaults and validation set on the ForceScheduler would be used.

Ideally I would change the builder_name and owner params around - they are only that way round to match current implementation.

The logic for owner is wrong too - thoughts on that would be appreciated.

Tests pass, however.



Discussion:
Thanks for working on this.

It looks like the first two commits could be squashed or refactored, so that the first isn't adding dead code.

Have squished as requested.

Squish went wrong - fixed.

Pick a name for the schedule function and i'll move it :)

The reason property: I would dearly like to kill the "User press a button on a form" reason and just use whatever the user specified directly.

Rebased as conflicting changes had landed in master.

Fixed most things.

Reason text is now not web specific. I tried to break it out into the parameter but there are actually 2 reasons, one reason string might be "force build", the other would be "The force build button was pressed by freddy: force build".

I have not renamed the helper function as a suitable name has not been suggested.

How's `addBuildSetForSourceStampDetails` sound?  Is the rename of that function (and move to base.py) the last step here?


Resolving patch:
diff --git a/master/buildbot/changes/svnpoller.py b/master/buildbot/changes/svnpoller.py
--- a/master/buildbot/changes/svnpoller.py
+++ b/master/buildbot/changes/svnpoller.py
@@ -210,9 +210,11 @@ def determine_prefix(output):
             rootnode = rootnodes[0]
             root = "".join([c.data for c in rootnode.childNodes])
             # root will be a unicode string
-            assert self.svnurl.startswith(root), \
-                    ("svnurl='%s' doesn't start with <root>='%s'" %
-                    (self.svnurl, root))
+            if not self.svnurl.startswith(root):
+                log.msg(format="svnurl='%(svnurl)s' doesn't start with <root>='%(root)s'",
+                        svnurl=self.svnurl, root=root)
+                raise RuntimeError("Can't handle redirected svn connections!? "
+                        "This shouldn't happen.")
             prefix = self.svnurl[len(root):]
             if prefix.startswith("/"):
                 prefix = prefix[1:]
@@ -288,9 +290,11 @@ def _get_text(self, element, tag_name):
         return text
 
     def _transform_path(self, path):
-        assert path.startswith(self._prefix), \
-                ("filepath '%s' should start with prefix '%s'" %
-                (path, self._prefix))
+        if not path.startswith(self._prefix):
+            log.msg(format="SVNPoller: ignoring path '%(path)s' which doesn't"
+                    "start with prefix '%(prefix)s'",
+                    path=path, prefix=self._prefix)
+            return
         relative_path = path[len(self._prefix):]
         if relative_path.startswith("/"):
             relative_path = relative_path[1:]


Test patch: