{"action":"created","comment":{"url":"https://api.github.com/repos/buildbot/buildbot/pulls/comments/48102754","id":48102754,"diff_hunk":"@@ -174,32 +174,19 @@ def _clone(self, abandonOnFailure=False):\n         return d\n \n     def _checkout(self):\n+        @defer.inlineCallbacks\n+        def action(tryCount, totalTries):\n+            # Clean up after a prior attempt.\n+            if tryCount:\n+                yield self.runRmdir(self.workdir)\n \n-        if self.retry:\n-            abandonOnFailure = (self.retry[1] <= 0)\n-        else:\n-            abandonOnFailure = True\n-\n-        d = self._clone(abandonOnFailure)\n-\n-        def _retry(res):\n-            if self.stopped or res == 0:\n-                return res\n-            delay, repeats = self.retry\n-            if repeats > 0:\n-                log.msg(\"Checkout failed, trying %d more times after %d seconds\"\n-                        % (repeats, delay))\n-                self.retry = (delay, repeats - 1)\n-                df = defer.Deferred()\n-                df.addCallback(lambda _: self.runRmdir(self.workdir))\n-                df.addCallback(lambda _: self._checkout())\n-                reactor.callLater(delay, df.callback, None)\n-                return df\n-            return res\n-\n-        if self.retry:\n-            d.addCallback(_retry)\n-        return d\n+            abandonOnFailure = (tryCount >= totalTries)\n+            res = yield self._clone(abandonOnFailure)\n+\n+            needRetry = res != 0\n+            defer.returnValue((needRetry, res))\n+\n+        return self.doWithRetry(action, 'checkout')","path":"master/buildbot/steps/source/darcs.py","position":41,"original_position":41,"commit_id":"505f78d7f4b23ba766cb40fb52b9949f9d0a2661","original_commit_id":"505f78d7f4b23ba766cb40fb52b9949f9d0a2661","user":{"login":"tardyp","id":109859,"avatar_url":"https://avatars.githubusercontent.com/u/109859?v=3","gravatar_id":"","url":"https://api.github.com/users/tardyp","html_url":"https://github.com/tardyp","followers_url":"https://api.github.com/users/tardyp/followers","following_url":"https://api.github.com/users/tardyp/following{/other_user}","gists_url":"https://api.github.com/users/tardyp/gists{/gist_id}","starred_url":"https://api.github.com/users/tardyp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tardyp/subscriptions","organizations_url":"https://api.github.com/users/tardyp/orgs","repos_url":"https://api.github.com/users/tardyp/repos","events_url":"https://api.github.com/users/tardyp/events{/privacy}","received_events_url":"https://api.github.com/users/tardyp/received_events","type":"User","site_admin":false},"body":"util/debounce.py is a good example. It actually does very similar stuff excepts it debounces..","created_at":"2015-12-20T12:09:18Z","updated_at":"2015-12-20T12:09:18Z","html_url":"https://github.com/buildbot/buildbot/pull/1935#discussion_r48102754","pull_request_url":"https://api.github.com/repos/buildbot/buildbot/pulls/1935","_links":{"self":{"href":"https://api.github.com/repos/buildbot/buildbot/pulls/comments/48102754"},"html":{"href":"https://github.com/buildbot/buildbot/pull/1935#discussion_r48102754"},"pull_request":{"href":"https://api.github.com/repos/buildbot/buildbot/pulls/1935"}}},"pull_request":{"url":"https://api.github.com/repos/buildbot/buildbot/pulls/1935","id":54146120,"html_url":"https://github.com/buildbot/buildbot/pull/1935","diff_url":"https://github.com/buildbot/buildbot/pull/1935.diff","patch_url":"https://github.com/buildbot/buildbot/pull/1935.patch","issue_url":"https://api.github.com/repos/buildbot/buildbot/issues/1935","number":1935,"state":"open","locked":false,"title":"Source Base: add a 'do with retry' function","user":{"login":"jaredgrubb","id":1256381,"avatar_url":"https://avatars.githubusercontent.com/u/1256381?v=3","gravatar_id":"","url":"https://api.github.com/users/jaredgrubb","html_url":"https://github.com/jaredgrubb","followers_url":"https://api.github.com/users/jaredgrubb/followers","following_url":"https://api.github.com/users/jaredgrubb/following{/other_user}","gists_url":"https://api.github.com/users/jaredgrubb/gists{/gist_id}","starred_url":"https://api.github.com/users/jaredgrubb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jaredgrubb/subscriptions","organizations_url":"https://api.github.com/users/jaredgrubb/orgs","repos_url":"https://api.github.com/users/jaredgrubb/repos","events_url":"https://api.github.com/users/jaredgrubb/events{/privacy}","received_events_url":"https://api.github.com/users/jaredgrubb/received_events","type":"User","site_admin":false},"body":"There's a lot of duplicated 'retry' code across the source classes. I moved that logic into the Source base class and adjusted the derived classes to use it. (This is all preliminary to me making Git-fetch more retry-happy).","created_at":"2015-12-18T20:25:10Z","updated_at":"2015-12-20T12:09:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4d7683344ac028c26aa68c4e1e11a14baea640e3","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/buildbot/buildbot/pulls/1935/commits","review_comments_url":"https://api.github.com/repos/buildbot/buildbot/pulls/1935/comments","review_comment_url":"https://api.github.com/repos/buildbot/buildbot/pulls/comments{/number}","comments_url":"https://api.github.com/repos/buildbot/buildbot/issues/1935/comments","statuses_url":"https://api.github.com/repos/buildbot/buildbot/statuses/505f78d7f4b23ba766cb40fb52b9949f9d0a2661","head":{"label":"jaredgrubb:jgrubb-source-retry","ref":"jgrubb-source-retry","sha":"505f78d7f4b23ba766cb40fb52b9949f9d0a2661","user":{"login":"jaredgrubb","id":1256381,"avatar_url":"https://avatars.githubusercontent.com/u/1256381?v=3","gravatar_id":"","url":"https://api.github.com/users/jaredgrubb","html_url":"https://github.com/jaredgrubb","followers_url":"https://api.github.com/users/jaredgrubb/followers","following_url":"https://api.github.com/users/jaredgrubb/following{/other_user}","gists_url":"https://api.github.com/users/jaredgrubb/gists{/gist_id}","starred_url":"https://api.github.com/users/jaredgrubb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jaredgrubb/subscriptions","organizations_url":"https://api.github.com/users/jaredgrubb/orgs","repos_url":"https://api.github.com/users/jaredgrubb/repos","events_url":"https://api.github.com/users/jaredgrubb/events{/privacy}","received_events_url":"https://api.github.com/users/jaredgrubb/received_events","type":"User","site_admin":false},"repo":{"id":3125564,"name":"buildbot","full_name":"jaredgrubb/buildbot","owner":{"login":"jaredgrubb","id":1256381,"avatar_url":"https://avatars.githubusercontent.com/u/1256381?v=3","gravatar_id":"","url":"https://api.github.com/users/jaredgrubb","html_url":"https://github.com/jaredgrubb","followers_url":"https://api.github.com/users/jaredgrubb/followers","following_url":"https://api.github.com/users/jaredgrubb/following{/other_user}","gists_url":"https://api.github.com/users/jaredgrubb/gists{/gist_id}","starred_url":"https://api.github.com/users/jaredgrubb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jaredgrubb/subscriptions","organizations_url":"https://api.github.com/users/jaredgrubb/orgs","repos_url":"https://api.github.com/users/jaredgrubb/repos","events_url":"https://api.github.com/users/jaredgrubb/events{/privacy}","received_events_url":"https://api.github.com/users/jaredgrubb/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jaredgrubb/buildbot","description":"Python-based continuous integration testing framework; send pull requests for your patches!","fork":true,"url":"https://api.github.com/repos/jaredgrubb/buildbot","forks_url":"https://api.github.com/repos/jaredgrubb/buildbot/forks","keys_url":"https://api.github.com/repos/jaredgrubb/buildbot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jaredgrubb/buildbot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jaredgrubb/buildbot/teams","hooks_url":"https://api.github.com/repos/jaredgrubb/buildbot/hooks","issue_events_url":"https://api.github.com/repos/jaredgrubb/buildbot/issues/events{/number}","events_url":"https://api.github.com/repos/jaredgrubb/buildbot/events","assignees_url":"https://api.github.com/repos/jaredgrubb/buildbot/assignees{/user}","branches_url":"https://api.github.com/repos/jaredgrubb/buildbot/branches{/branch}","tags_url":"https://api.github.com/repos/jaredgrubb/buildbot/tags","blobs_url":"https://api.github.com/repos/jaredgrubb/buildbot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jaredgrubb/buildbot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jaredgrubb/buildbot/git/refs{/sha}","trees_url":"https://api.github.com/repos/jaredgrubb/buildbot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jaredgrubb/buildbot/statuses/{sha}","languages_url":"https://api.github.com/repos/jaredgrubb/buildbot/languages","stargazers_url":"https://api.github.com/repos/jaredgrubb/buildbot/stargazers","contributors_url":"https://api.github.com/repos/jaredgrubb/buildbot/contributors","subscribers_url":"https://api.github.com/repos/jaredgrubb/buildbot/subscribers","subscription_url":"https://api.github.com/repos/jaredgrubb/buildbot/subscription","commits_url":"https://api.github.com/repos/jaredgrubb/buildbot/commits{/sha}","git_commits_url":"https://api.github.com/repos/jaredgrubb/buildbot/git/commits{/sha}","comments_url":"https://api.github.com/repos/jaredgrubb/buildbot/comments{/number}","issue_comment_url":"https://api.github.com/repos/jaredgrubb/buildbot/issues/comments{/number}","contents_url":"https://api.github.com/repos/jaredgrubb/buildbot/contents/{+path}","compare_url":"https://api.github.com/repos/jaredgrubb/buildbot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jaredgrubb/buildbot/merges","archive_url":"https://api.github.com/repos/jaredgrubb/buildbot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jaredgrubb/buildbot/downloads","issues_url":"https://api.github.com/repos/jaredgrubb/buildbot/issues{/number}","pulls_url":"https://api.github.com/repos/jaredgrubb/buildbot/pulls{/number}","milestones_url":"https://api.github.com/repos/jaredgrubb/buildbot/milestones{/number}","notifications_url":"https://api.github.com/repos/jaredgrubb/buildbot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jaredgrubb/buildbot/labels{/name}","releases_url":"https://api.github.com/repos/jaredgrubb/buildbot/releases{/id}","created_at":"2012-01-07T17:27:31Z","updated_at":"2014-05-13T17:10:43Z","pushed_at":"2015-12-18T20:21:16Z","git_url":"git://github.com/jaredgrubb/buildbot.git","ssh_url":"git@github.com:jaredgrubb/buildbot.git","clone_url":"https://github.com/jaredgrubb/buildbot.git","svn_url":"https://github.com/jaredgrubb/buildbot","homepage":"http://buildbot.net","size":37432,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":1,"default_branch":"master"}},"base":{"label":"buildbot:eight","ref":"eight","sha":"1e72918e8f0e69e9630debf77b9d9915af1d9919","user":{"login":"buildbot","id":324515,"avatar_url":"https://avatars.githubusercontent.com/u/324515?v=3","gravatar_id":"","url":"https://api.github.com/users/buildbot","html_url":"https://github.com/buildbot","followers_url":"https://api.github.com/users/buildbot/followers","following_url":"https://api.github.com/users/buildbot/following{/other_user}","gists_url":"https://api.github.com/users/buildbot/gists{/gist_id}","starred_url":"https://api.github.com/users/buildbot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/buildbot/subscriptions","organizations_url":"https://api.github.com/users/buildbot/orgs","repos_url":"https://api.github.com/users/buildbot/repos","events_url":"https://api.github.com/users/buildbot/events{/privacy}","received_events_url":"https://api.github.com/users/buildbot/received_events","type":"Organization","site_admin":false},"repo":{"id":760165,"name":"buildbot","full_name":"buildbot/buildbot","owner":{"login":"buildbot","id":324515,"avatar_url":"https://avatars.githubusercontent.com/u/324515?v=3","gravatar_id":"","url":"https://api.github.com/users/buildbot","html_url":"https://github.com/buildbot","followers_url":"https://api.github.com/users/buildbot/followers","following_url":"https://api.github.com/users/buildbot/following{/other_user}","gists_url":"https://api.github.com/users/buildbot/gists{/gist_id}","starred_url":"https://api.github.com/users/buildbot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/buildbot/subscriptions","organizations_url":"https://api.github.com/users/buildbot/orgs","repos_url":"https://api.github.com/users/buildbot/repos","events_url":"https://api.github.com/users/buildbot/events{/privacy}","received_events_url":"https://api.github.com/users/buildbot/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/buildbot/buildbot","description":"Python-based continuous integration testing framework; your pull requests are more than welcome!","fork":false,"url":"https://api.github.com/repos/buildbot/buildbot","forks_url":"https://api.github.com/repos/buildbot/buildbot/forks","keys_url":"https://api.github.com/repos/buildbot/buildbot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/buildbot/buildbot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/buildbot/buildbot/teams","hooks_url":"https://api.github.com/repos/buildbot/buildbot/hooks","issue_events_url":"https://api.github.com/repos/buildbot/buildbot/issues/events{/number}","events_url":"https://api.github.com/repos/buildbot/buildbot/events","assignees_url":"https://api.github.com/repos/buildbot/buildbot/assignees{/user}","branches_url":"https://api.github.com/repos/buildbot/buildbot/branches{/branch}","tags_url":"https://api.github.com/repos/buildbot/buildbot/tags","blobs_url":"https://api.github.com/repos/buildbot/buildbot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/buildbot/buildbot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/buildbot/buildbot/git/refs{/sha}","trees_url":"https://api.github.com/repos/buildbot/buildbot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/buildbot/buildbot/statuses/{sha}","languages_url":"https://api.github.com/repos/buildbot/buildbot/languages","stargazers_url":"https://api.github.com/repos/buildbot/buildbot/stargazers","contributors_url":"https://api.github.com/repos/buildbot/buildbot/contributors","subscribers_url":"https://api.github.com/repos/buildbot/buildbot/subscribers","subscription_url":"https://api.github.com/repos/buildbot/buildbot/subscription","commits_url":"https://api.github.com/repos/buildbot/buildbot/commits{/sha}","git_commits_url":"https://api.github.com/repos/buildbot/buildbot/git/commits{/sha}","comments_url":"https://api.github.com/repos/buildbot/buildbot/comments{/number}","issue_comment_url":"https://api.github.com/repos/buildbot/buildbot/issues/comments{/number}","contents_url":"https://api.github.com/repos/buildbot/buildbot/contents/{+path}","compare_url":"https://api.github.com/repos/buildbot/buildbot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/buildbot/buildbot/merges","archive_url":"https://api.github.com/repos/buildbot/buildbot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/buildbot/buildbot/downloads","issues_url":"https://api.github.com/repos/buildbot/buildbot/issues{/number}","pulls_url":"https://api.github.com/repos/buildbot/buildbot/pulls{/number}","milestones_url":"https://api.github.com/repos/buildbot/buildbot/milestones{/number}","notifications_url":"https://api.github.com/repos/buildbot/buildbot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/buildbot/buildbot/labels{/name}","releases_url":"https://api.github.com/repos/buildbot/buildbot/releases{/id}","created_at":"2010-07-06T17:56:53Z","updated_at":"2015-12-19T22:21:03Z","pushed_at":"2015-12-18T20:25:11Z","git_url":"git://github.com/buildbot/buildbot.git","ssh_url":"git@github.com:buildbot/buildbot.git","clone_url":"https://github.com/buildbot/buildbot.git","svn_url":"https://github.com/buildbot/buildbot","homepage":"http://buildbot.net","size":76176,"stargazers_count":1909,"watchers_count":1909,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":812,"mirror_url":null,"open_issues_count":28,"forks":812,"open_issues":28,"watchers":1909,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/buildbot/buildbot/pulls/1935"},"html":{"href":"https://github.com/buildbot/buildbot/pull/1935"},"issue":{"href":"https://api.github.com/repos/buildbot/buildbot/issues/1935"},"comments":{"href":"https://api.github.com/repos/buildbot/buildbot/issues/1935/comments"},"review_comments":{"href":"https://api.github.com/repos/buildbot/buildbot/pulls/1935/comments"},"review_comment":{"href":"https://api.github.com/repos/buildbot/buildbot/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/buildbot/buildbot/pulls/1935/commits"},"statuses":{"href":"https://api.github.com/repos/buildbot/buildbot/statuses/505f78d7f4b23ba766cb40fb52b9949f9d0a2661"}}}}