Repository: buildbot/buildbot

Issue:
Use urlparse from future module for Python 3



Discussion:

Resolving patch:
diff --git a/master/buildbot/steps/source/git.py b/master/buildbot/steps/source/git.py
--- a/master/buildbot/steps/source/git.py
+++ b/master/buildbot/steps/source/git.py
@@ -225,7 +225,7 @@ def incremental(self):
                 yield self._dovccmd(['branch', '-M', self.branch],
                                     abandonOnFailure=False)
         else:
-            yield self._fetchOrFallback(None)
+            yield self._fetchOrFallback()
 
         yield self._updateSubmodule(None)
 
@@ -242,13 +242,17 @@ def clobber(self):
         d.addCallback(lambda _: self._fullClone(shallowClone=self.shallow))
         return d
 
+    @defer.inlineCallbacks
     def fresh(self):
-        command = ['clean', '-f', '-f', '-d', '-x']
-        d = self._dovccmd(command)
-        d.addCallback(self._fetchOrFallback)
-        d.addCallback(self._updateSubmodule)
-        d.addCallback(self._cleanSubmodule)
-        return d
+        res = yield self._dovccmd(['clean', '-f', '-f', '-d', '-x'],
+                                  abandonOnFailure=False)
+        if res == 0:
+            yield self._fetchOrFallback()
+        else:
+            yield self._doClobber()
+            yield self._fullCloneOrFallback()
+        yield self._updateSubmodule()
+        yield self._cleanSubmodule()
 
     def copy(self):
         cmd = buildstep.RemoteCommand('rmdir', {'dir': self.workdir,
@@ -388,7 +392,7 @@ def renameBranch(res):
         return d
 
     @defer.inlineCallbacks
-    def _fetchOrFallback(self, _):
+    def _fetchOrFallback(self, _=None):
         """
         Handles fallbacks for failure of fetch,
         wrapper for self._fetch
@@ -500,14 +504,14 @@ def computeSourceRevision(self, changes):
             return None
         return changes[-1].revision
 
-    def _updateSubmodule(self, _):
+    def _updateSubmodule(self, _=None):
         if self.submodules:
             return self._dovccmd(['submodule', 'update',
                                   '--init', '--recursive'])
         else:
             return defer.succeed(0)
 
-    def _cleanSubmodule(self, _):
+    def _cleanSubmodule(self, _=None):
         if self.submodules:
             command = ['submodule', 'foreach', 'git', 'clean', '-f', '-f', '-d']
             if self.mode == 'full' and self.method == 'fresh':


Test patch:
diff --git a/master/buildbot/test/unit/test_steps_source_git.py b/master/buildbot/test/unit/test_steps_source_git.py
--- a/master/buildbot/test/unit/test_steps_source_git.py
+++ b/master/buildbot/test/unit/test_steps_source_git.py
@@ -794,6 +794,45 @@ def test_mode_full_fresh(self):
         self.expectProperty('got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', 'Git')
         return self.runStep()
 
+    def test_mode_full_fresh_clean_fails(self):
+        self.setupStep(
+            git.Git(repourl='http://github.com/buildbot/buildbot.git',
+                    mode='full', method='fresh'))
+        self.expectCommands(
+            ExpectShell(workdir='wkdir',
+                        command=['git', '--version'])
+            + ExpectShell.log('stdio',
+                              stdout='git version 1.7.5')
+            + 0,
+            Expect('stat', dict(file='wkdir/.buildbot-patched',
+                                logEnviron=True))
+            + 1,
+            Expect('listdir', {'dir': 'wkdir', 'logEnviron': True,
+                               'timeout': 1200})
+            + Expect.update('files', ['.git'])
+            + 0,
+            ExpectShell(workdir='wkdir',
+                        command=['git', 'clean', '-f', '-f', '-d', '-x'])
+            + 1,  # clean fails -> clobber
+            Expect('rmdir', dict(dir='wkdir',
+                                 logEnviron=True,
+                                 timeout=1200))
+            + 0,
+            ExpectShell(workdir='wkdir',
+                        command=['git', 'clone',
+                                 'http://github.com/buildbot/buildbot.git',
+                                 '.'])
+            + 0,
+            ExpectShell(workdir='wkdir',
+                        command=['git', 'rev-parse', 'HEAD'])
+            + ExpectShell.log('stdio',
+                              stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
+            + 0,
+        )
+        self.expectOutcome(result=SUCCESS, status_text=["update"])
+        self.expectProperty('got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', 'Git')
+        return self.runStep()
+
     def test_mode_incremental_given_revision(self):
         self.setupStep(
             git.Git(repourl='http://github.com/buildbot/buildbot.git',