

@inbranch('bloom')
def convert_old_bloom_conf(prefix=None):
    prefix = (prefix if (prefix is not None) else 'convert')
    tracks_dict = get_tracks_dict_raw()
    track = prefix
    track_count = 0
    while (track in tracks_dict['tracks']):
        track_count += 1
        track = (prefix + str(track_count))
    track_dict = copy.copy(DEFAULT_TEMPLATE)
    cmd = 'git config -f bloom.conf bloom.upstream'
    upstream_repo = check_output(cmd, shell=True).strip()
    cmd = 'git config -f bloom.conf bloom.upstreamtype'
    upstream_type = check_output(cmd, shell=True).strip()
    try:
        cmd = 'git config -f bloom.conf bloom.upstreambranch'
        upstream_branch = check_output(cmd, shell=True).strip()
    except subprocess.CalledProcessError:
        upstream_branch = ''
    for key in template_entry_order:
        if (key == 'vcs_uri'):
            track_dict[key] = upstream_repo
            continue
        if (key == 'vcs_type'):
            track_dict[key] = upstream_type
            continue
        if (key == 'vcs_uri'):
            track_dict[key] = (upstream_branch or None)
            continue
        track_dict[key] = track_dict[key].default
    debug('Converted bloom.conf:')
    with open('bloom.conf', 'r') as f:
        debug(f.read())
    debug('To this track:')
    debug(str({
        track: track_dict,
    }))
    tracks_dict['tracks'][track] = track_dict
    write_tracks_dict_raw(tracks_dict)
    execute_command('git rm bloom.conf', shell=True)
    execute_command('git commit -m "Removed bloom.conf"', shell=True)
    upconvert_bloom_to_config_branch()

dataset/ETHPy150Open ros-infrastructure/bloom/bloom/commands/git/config.py convert_old_bloom_conf/original