def LoadCodereviewSettingsFromFile(fileobj):
    'Parse a codereview.settings file and updates hooks.'
    keyvals = gclient_utils.ParseCodereviewSettingsContent(fileobj.read())

    def SetProperty(name, setting, unset_error_ok=False):
        fullname = ('rietveld.' + name)
        if (setting in keyvals):
            RunGit(['config', fullname, keyvals[setting]])
        else:
            RunGit(['config', '--unset-all', fullname], error_ok=unset_error_ok)
    SetProperty('server', 'CODE_REVIEW_SERVER')
    SetProperty('cc', 'CC_LIST', unset_error_ok=True)
    SetProperty('private', 'PRIVATE', unset_error_ok=True)
    SetProperty('tree-status-url', 'STATUS', unset_error_ok=True)
    SetProperty('viewvc-url', 'VIEW_VC', unset_error_ok=True)
    SetProperty('bug-prefix', 'BUG_PREFIX', unset_error_ok=True)
    SetProperty('cpplint-regex', 'LINT_REGEX', unset_error_ok=True)
    SetProperty('force-https-commit-url', 'FORCE_HTTPS_COMMIT_URL', unset_error_ok=True)
    SetProperty('cpplint-ignore-regex', 'LINT_IGNORE_REGEX', unset_error_ok=True)
    SetProperty('project', 'PROJECT', unset_error_ok=True)
    SetProperty('pending-ref-prefix', 'PENDING_REF_PREFIX', unset_error_ok=True)
    SetProperty('run-post-upload-hook', 'RUN_POST_UPLOAD_HOOK', unset_error_ok=True)
    if ('GERRIT_HOST' in keyvals):
        RunGit(['config', 'gerrit.host', keyvals['GERRIT_HOST']])
    if ('GERRIT_SQUASH_UPLOADS' in keyvals):
        RunGit(['config', 'gerrit.squash-uploads', keyvals['GERRIT_SQUASH_UPLOADS']])
    if ('GERRIT_SKIP_ENSURE_AUTHENTICATED' in keyvals):
        RunGit(['config', 'gerrit.skip-ensure-authenticated', keyvals['GERRIT_SKIP_ENSURE_AUTHENTICATED']])
    if (('PUSH_URL_CONFIG' in keyvals) and ('ORIGIN_URL_CONFIG' in keyvals)):
        RunGit(['config', keyvals['PUSH_URL_CONFIG'], keyvals['ORIGIN_URL_CONFIG']])
Parse a codereview.settings file and updates hooks.
def LoadCodereviewSettingsFromFile(fileobj):
    
    keyvals = gclient_utils.ParseCodereviewSettingsContent(fileobj.read())

    def SetProperty(name, setting, unset_error_ok=False):
        fullname = ('rietveld.' + name)
        if (setting in keyvals):
            RunGit(['config', fullname, keyvals[setting]])
        else:
            RunGit(['config', '--unset-all', fullname], error_ok=unset_error_ok)
    SetProperty('server', 'CODE_REVIEW_SERVER')
    SetProperty('cc', 'CC_LIST', unset_error_ok=True)
    SetProperty('private', 'PRIVATE', unset_error_ok=True)
    SetProperty('tree-status-url', 'STATUS', unset_error_ok=True)
    SetProperty('viewvc-url', 'VIEW_VC', unset_error_ok=True)
    SetProperty('bug-prefix', 'BUG_PREFIX', unset_error_ok=True)
    SetProperty('cpplint-regex', 'LINT_REGEX', unset_error_ok=True)
    SetProperty('force-https-commit-url', 'FORCE_HTTPS_COMMIT_URL', unset_error_ok=True)
    SetProperty('cpplint-ignore-regex', 'LINT_IGNORE_REGEX', unset_error_ok=True)
    SetProperty('project', 'PROJECT', unset_error_ok=True)
    SetProperty('pending-ref-prefix', 'PENDING_REF_PREFIX', unset_error_ok=True)
    SetProperty('run-post-upload-hook', 'RUN_POST_UPLOAD_HOOK', unset_error_ok=True)
    if ('GERRIT_HOST' in keyvals):
        RunGit(['config', 'gerrit.host', keyvals['GERRIT_HOST']])
    if ('GERRIT_SQUASH_UPLOADS' in keyvals):
        RunGit(['config', 'gerrit.squash-uploads', keyvals['GERRIT_SQUASH_UPLOADS']])
    if ('GERRIT_SKIP_ENSURE_AUTHENTICATED' in keyvals):
        RunGit(['config', 'gerrit.skip-ensure-authenticated', keyvals['GERRIT_SKIP_ENSURE_AUTHENTICATED']])
    if (('PUSH_URL_CONFIG' in keyvals) and ('ORIGIN_URL_CONFIG' in keyvals)):
        RunGit(['config', keyvals['PUSH_URL_CONFIG'], keyvals['ORIGIN_URL_CONFIG']])