def WaitForRealCommit(remote, pushed_commit, local_base_ref, real_ref):
    print()
    print(('Waiting for commit to be landed on %s...' % real_ref))
    print('(If you are impatient, you may Ctrl-C once without harm)')
    target_tree = RunGit(['rev-parse', ('%s:' % pushed_commit)]).strip()
    current_rev = RunGit(['rev-parse', local_base_ref]).strip()
    mirror = settings.GetGitMirror(remote)
    loop = 0
    while True:
        sys.stdout.write(('fetching (%d)...        \r' % loop))
        sys.stdout.flush()
        loop += 1
        if mirror:
            mirror.populate()
        RunGit(['retry', 'fetch', remote, real_ref], stderr=subprocess2.VOID)
        to_rev = RunGit(['rev-parse', 'FETCH_HEAD']).strip()
        commits = RunGit(['rev-list', ('%s..%s' % (current_rev, to_rev))])
        for commit in commits.splitlines():
            if (RunGit(['rev-parse', ('%s:' % commit)]).strip() == target_tree):
                print(('Found commit on %s' % real_ref))
                return commit
        current_rev = to_rev
def WaitForRealCommit(remote, pushed_commit, local_base_ref, real_ref):
    print()
    print(('Waiting for commit to be landed on %s...' % real_ref))
    print('(If you are impatient, you may Ctrl-C once without harm)')
    target_tree = RunGit(['rev-parse', ('%s:' % pushed_commit)]).strip()
    current_rev = RunGit(['rev-parse', local_base_ref]).strip()
    mirror = settings.GetGitMirror(remote)
    loop = 0
    while True:
        sys.stdout.write(('fetching (%d)...        \r' % loop))
        sys.stdout.flush()
        loop += 1
        if mirror:
            mirror.populate()
        RunGit(['retry', 'fetch', remote, real_ref], stderr=subprocess2.VOID)
        to_rev = RunGit(['rev-parse', 'FETCH_HEAD']).strip()
        commits = RunGit(['rev-list', ('%s..%s' % (current_rev, to_rev))])
        for commit in commits.splitlines():
            if (RunGit(['rev-parse', ('%s:' % commit)]).strip() == target_tree):
                print(('Found commit on %s' % real_ref))
                return commit
        current_rev = to_rev