Repository: buildbot/buildbot

Issue:
HgPoller._stopOnFailure() missing 1 required positional argument: 'f'
Looking at updating a BuildBot instance from 2.10.1 (on Debian 11) to
3.7.0 and encountered this error in the logs:

```
2024-03-28 16:12:32+0000 [-] <buildbot.changes.hgpoller.HgPoller object at 0x7f7e3c580750>: while polling for changes
	Traceback (most recent call last):
	  File "/usr/lib/python3/dist-packages/twisted/internet/defer.py", line 700, in errback
	    self._startRunCallbacks(fail)
	  File "/usr/lib/python3/dist-packages/twisted/internet/defer.py", line 763, in _startRunCallbacks
	    self._runCallbacks()
	  File "/usr/lib/python3/dist-packages/twisted/internet/defer.py", line 857, in _runCallbacks
	    current.result = callback(  # type: ignore[misc]
	  File "/usr/lib/python3/dist-packages/twisted/internet/defer.py", line 1750, in gotResult
	    current_context.run(_inlineCallbacks, r, gen, status)
	--- <exception caught here> ---
	  File "/usr/lib/python3/dist-packages/twisted/internet/defer.py", line 1656, in _inlineCallbacks
	    result = current_context.run(
	  File "/usr/lib/python3/dist-packages/twisted/python/failure.py", line 517, in throwExceptionIntoGenerator
	    return g.throw(self.type, self.value, self.tb)
	  File "/usr/lib/python3/dist-packages/buildbot/changes/hgpoller.py", line 145, in poll
	    yield self._getChanges()
	  File "/usr/lib/python3/dist-packages/twisted/internet/defer.py", line 1656, in _inlineCallbacks
	    result = current_context.run(
	  File "/usr/lib/python3/dist-packages/twisted/python/failure.py", line 517, in throwExceptionIntoGenerator
	    return g.throw(self.type, self.value, self.tb)
	  File "/usr/lib/python3/dist-packages/buildbot/changes/hgpoller.py", line 219, in _getChanges
	    yield self._initRepository()
	  File "/usr/lib/python3/dist-packages/twisted/internet/defer.py", line 1660, in _inlineCallbacks
	    result = current_context.run(gen.send, result)
	  File "/usr/lib/python3/dist-packages/buildbot/changes/hgpoller.py", line 210, in _initRepository
	    self._stopOnFailure()
	builtins.TypeError: HgPoller._stopOnFailure() missing 1 required positional argument: 'f'
```

Which seems to point here:

https://github.com/buildbot/buildbot/blob/0e497e2ada00899848d77c45b5aa4f5e2a2ab2e0/master/buildbot/changes/hgpoller.py#L209-L211

And it looks like this has not changed in `main`.

Configuration snippet:

```python
c["change_source"].append(
    changes.HgPoller(
        "https://hg.prosody.im/trunk/",
        workdir="hgpoller-prosody-trunk",
        revlink=lambda branch, revision: "https://hg.prosody.im/trunk/rev/{}".format(revision[:12]),
        pollAtLaunch=True,
        pollInterval=257,
        pollRandomDelayMax=31,
        pollRandomDelayMin=0,
    )
)
```

- Buildbot 3.7.0 in Debian 12
- Python 3.11.2



Discussion:

Resolving patch:
diff --git a/master/buildbot/changes/hgpoller.py b/master/buildbot/changes/hgpoller.py
--- a/master/buildbot/changes/hgpoller.py
+++ b/master/buildbot/changes/hgpoller.py
@@ -357,9 +357,8 @@ def _processBranchChanges(self, new_rev, branch):
             # but at once to avoid impact from later errors
             yield self._setCurrentRev(new_rev, branch)
 
-    def _stopOnFailure(self, f):
+    def _stopOnFailure(self):
         "utility method to stop the service when a failure occurs"
         if self.running:
             d = defer.maybeDeferred(self.stopService)
             d.addErrback(log.err, 'while stopping broken HgPoller service')
-        return f


Test patch: