

def create_import(self, commit=None, import_branch=None, checkout=False, force=False):
    "Create the import branch from the specified commit.\n\n        If the branch already exists abort if force is false\n            If current branch, reset the head to the specified commit\n            If checkout is true, switch and reset the branch to the commit\n            Otherwise just reset the branch to the specified commit\n        If the branch doesn't exist, create it and switch to it\n        automatically if checkout is true.\n        "
    if (not commit):
        commit = self.upstream
    try:
        self.git.show_ref(commit, quiet=True, heads=True)
    except GitCommandError as e:
        msg = "Invalid commit '%s' specified to import from"
        self.log.error(msg, commit)
        raise ImportUpstreamError((msg + ': %s'), commit, e)
    if (not import_branch):
        import_branch = self.import_branch
    describe_commit = self.git.describe(commit, tags=True, with_exceptions=False)
    if (not describe_commit):
        self.log.warning('No tag describes the upstream branch')
        describe_commit = self.git.describe(commit, always=True, tags=True)
    self.log.info("\n                    Using '%s' to describe:\n                        %s\n                    ", describe_commit, commit)
    describe_branches = [describe_commit]
    describe_branches.extend([self.git.rev_parse(b, short=True) for b in self.extra_branches])
    import_describe = '-'.join(describe_branches)
    self._import_branch = self.import_branch.format(describe=import_describe)
    self._import_branch = import_branch.format(describe=import_describe)
    base = (self._import_branch + '-base')
    self.log.debug("Creating and switching to import branch base '%s' created from '%s' (%s)", base, self.upstream, commit)
    self.log.info("\n            Checking if import branch '%s' already exists:\n                git branch --list %s\n            ", base, base)
    if (self.git.show_ref(('refs/heads/' + base), verify=True, with_exceptions=False) and (not b)):
        msg = "Import branch '%s' already exists, set 'force' to replace"
        self.log.error(msg, self.import_branch)
        raise ImportUpstreamError((msg % self.import_branch))
    self._set_branch(base, commit, checkout, force)
    if self.extra_branches:
        self.log.info("\n                Merging additional branch(es) '%s' into import branch '%s'\n                    git checkout %s\n                    git merge %s\n                ", ', '.join(self.extra_branches), base, base, ' '.join(self.extra_branches))
        self.git.checkout(base)
        self.git.merge(*self.extra_branches)

dataset/ETHPy150Open openstack/git-upstream/git_upstream/lib/importupstream.py ImportUpstream.create_import/VarMisuse@320/668 `force`->`b`