autoland: ensure repository directory exists (bug 1180818) r=mdoglio
authorDan Minor <dminor@mozilla.com>
Thu, 30 Jul 2015 22:17:05 -0400
changeset 2856 0482431406ba118b8c2c5ffc2022018b8c0a864b
parent 2855 86b9275db32ab9a61f3f42140873ec75344f9c60
child 2857 750e446144349a502196d80e2a759756b16217d2
push id1021
push userdminor@mozilla.com
push dateThu, 06 Aug 2015 13:10:25 +0000
treeherderversion-control-tools@750e44614434 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmdoglio
bugs1180818
autoland: ensure repository directory exists (bug 1180818) r=mdoglio I noticed this while fixing up the Autoland selenium tests. If the directory path does not exist, subprocess will throw an uncaught OSError after the new bugzilla bug has been filed, causing new bugs to be filed several times a second when Autoland retries the failed request. This isn't something that's likely to happen in production, but better safe than sorry.
autoland/autoland/transplant.py
--- a/autoland/autoland/transplant.py
+++ b/autoland/autoland/transplant.py
@@ -28,28 +28,30 @@ def transplant_to_mozreview(gh, tree, us
        keep things simple, we fold the git commits into a single commit
        prior to pushing."""
 
     landed = False
     result = ''
 
     repo_path = get_repo_path(tree)
     if repo_path is None:
-        return False, 'unknown tree: ' % tree
+        return False, 'unknown tree: %s' % tree
+
+    if not os.path.isdir(repo_path):
+        return False, 'bad repository path: %s for tree: %s' % (repo_path,
+                                                                tree)
 
     # first purge any untracked files
     subprocess.call(['hg', 'purge', '--all'], cwd=repo_path)
 
     cmds = [['hg', 'update', '--clean'],
             ['hg', 'strip', '--no-backup', '-r', 'draft()'],
             ['hg', 'pull', 'upstream'],
             ['hg', 'update', 'upstream']]
 
-    repo_path = get_repo_path(tree)
-
     commits = github.retrieve_commits(gh, user, repo, pullrequest, repo_path)
     if not commits:
         return False, 'no commits found!'
 
     for commit in commits:
         cmds.append(['hg', 'import', commit])
         cmds.append(['rm', commit])