

def apply(self, strategy, interactive=False):
    'Apply list of commits given onto latest import of upstream'
    commit_list = list(strategy.filtered_iter())
    if (len(commit_list) == 0):
        self.log.notice('There are no local changes to be applied!')
        return False
    self.log.debug('\n            Should apply the following list of commits\n                %s\n            ', '\n    '.join([c.hexsha for c in commit_list]))
    base = (self.import_branch + '-base')
    self._set_branch(self.import_branch, self.branch, force=True)
    self.log.info("\n            Creating import branch '%s' from specified commit '%s' in prep to\n            linearize the local changes before transposing to the new upstream:\n                git branch --force %s %s\n            ", self.import_branch, self.branch, self.import_branch, self.branch)
    self.log.notice('Attempting to linearise previous changes')
    try:
        self._linearise(self.import_branch, strategy, strategy.searcher.commit)
    except Exception:
        self.log.warning('\n\n                Exception occurred during linearisation of local changes on to\n                previous import to simplify behaviour should user need to abort\n                the rebase that applies these changes to the latest import\n                point. Attempting to tidy up state.\n\n                Do not Ctrl+C unless you wish to need to clean up your git\n                repository by hand.\n\n                ')
        self._set_branch(self.import_branch, self.branch, force=True)
    rebase = RebaseEditor(interactive, repo=self.repo)
    if len(commit_list):
        first = commit_list[0]
        self.log.info('\n                Rebase changes, dropping merges through editor:\n                    git rebase --onto %s \\\n                        %s %s\n                ', base, first.parents[0].hexsha, self.import_branch)
        (status, out, err) = rebase.run(commit_list, first.parents[0].hexsha, self.import_branch, onto=base)
        if status:
            if (err and err.startswith('Nothing to do')):
                self.log.notice('Cancelled by user')
                return False
            self.log.error('Rebase failed, will need user intervention to resolve.')
            if out:
                self.log.notice(out)
            if err:
                self.log.notice(err)
            return False
        self.log.notice('Successfully applied all locally carried changes')
    else:
        self.log.warning((('Warning, nothing to do: locally carried ' + 'changes already rebased onto ') + self.upstream))
    return True

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