Commit 18ca30ca authored by vadimsh's avatar vadimsh Committed by Commit bot

Teach bot_update to remove partially deleted git repos.

Also add logging to 'remove', helps to debug issues with 'build.dead' filling
up with crap.

R=iannucci@chromium.org, hinoka@chromium.org
BUG=647046

Review-Url: https://codereview.chromium.org/2342973002
parent adcd4b78
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
import cStringIO import cStringIO
import codecs import codecs
import collections
import copy import copy
import ctypes import ctypes
import json import json
...@@ -16,7 +15,6 @@ import os ...@@ -16,7 +15,6 @@ import os
import pprint import pprint
import random import random
import re import re
import socket
import subprocess import subprocess
import sys import sys
import tempfile import tempfile
...@@ -299,7 +297,9 @@ def remove(target): ...@@ -299,7 +297,9 @@ def remove(target):
dead_folder = path.join(BUILDER_DIR, 'build.dead') dead_folder = path.join(BUILDER_DIR, 'build.dead')
if not path.exists(dead_folder): if not path.exists(dead_folder):
os.makedirs(dead_folder) os.makedirs(dead_folder)
os.rename(target, path.join(dead_folder, uuid.uuid4().hex)) dest = path.join(dead_folder, uuid.uuid4().hex)
print 'Marking for removal %s => %s' % (target, dest)
os.rename(target, dest)
def ensure_no_checkout(dir_names): def ensure_no_checkout(dir_names):
...@@ -458,6 +458,11 @@ def force_revision(folder_name, revision): ...@@ -458,6 +458,11 @@ def force_revision(folder_name, revision):
git('checkout', '--force', ref, cwd=folder_name) git('checkout', '--force', ref, cwd=folder_name)
def is_broken_repo_dir(repo_dir):
# Treat absence of 'config' as a signal of a partially deleted repo.
return not path.exists(os.path.join(repo_dir, '.git', 'config'))
def git_checkout(solutions, revisions, shallow, refs, git_cache_dir): def git_checkout(solutions, revisions, shallow, refs, git_cache_dir):
build_dir = os.getcwd() build_dir = os.getcwd()
# Before we do anything, break all git_cache locks. # Before we do anything, break all git_cache locks.
...@@ -496,6 +501,12 @@ def git_checkout(solutions, revisions, shallow, refs, git_cache_dir): ...@@ -496,6 +501,12 @@ def git_checkout(solutions, revisions, shallow, refs, git_cache_dir):
'clone', '--no-checkout', '--local', '--shared', mirror_dir, sln_dir) 'clone', '--no-checkout', '--local', '--shared', mirror_dir, sln_dir)
try: try:
# If repo deletion was aborted midway, it may have left .git in broken
# state.
if path.exists(sln_dir) and is_broken_repo_dir(sln_dir):
print 'Git repo %s appears to be broken, removing it' % sln_dir
remove(sln_dir)
if not path.isdir(sln_dir): if not path.isdir(sln_dir):
git(*clone_cmd) git(*clone_cmd)
else: else:
...@@ -1044,7 +1055,7 @@ def main(): ...@@ -1044,7 +1055,7 @@ def main():
# Print a helpful message to tell developers whats going on with this step. # Print a helpful message to tell developers whats going on with this step.
print_debug_info() print_debug_info()
# Parse, munipulate, and print the gclient solutions. # Parse, manipulate, and print the gclient solutions.
specs = {} specs = {}
exec(options.specs, specs) exec(options.specs, specs)
orig_solutions = specs.get('solutions', []) orig_solutions = specs.get('solutions', [])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment