

def __init__(self, branch=None, upstream=None, import_branch=None, extra_branches=None, *args, **kwargs):
    if (not extra_branches):
        extra_branches = []
    self._branch = branch
    self._upstream = upstream
    self._import_branch = import_branch
    self._extra_branches = extra_branches
    super(ImportUpstream, self).__init__(*args, **kwargs)
    if self.is_detached():
        raise ImportUpstreamError("In 'detached HEAD' state")
    if self.repo.bare:
        raise ImportUpstreamError('Cannot perform imports in bare repos')
    if (self.branch == 'HEAD'):
        self._branch = str(self.repo.active_branch)
    branches = [self.branch, self.upstream]
    branches.extend(self.extra_branches)
    invalid_ref = False
    for branch in branches:
        if (not any((head for head in self.repo.heads if (head.name == branch)))):
            msg = "Specified ref does not exist: '%s'"
            self.log.error(msg, branch)
            invalid_ref = True
    if invalid_ref:
        raise ImportUpstreamError('Invalid ref')

dataset/ETHPy150Open openstack/git-upstream/git_upstream/lib/importupstream.py ImportUpstream.__init__/original