def apply_patch(self, patch_file, base_path=None, base_dir=None, p=None,
                    revert=False):
        """Apply the given patch to index.

        This will take the given patch file and apply it to the index,
        scheduling all changes for commit.
        """
        cmd = ['git', 'apply', '-3']

        if revert:
            cmd.append('-R')

        if p:
            cmd += ['-p', p]

        cmd.append(patch_file)

        rc, data = self._execute(cmd, with_errors=True, return_error_code=True)

        if rc == 0:
            return PatchResult(applied=True, patch_output=data)
        elif data in 'with conflicts':
            return PatchResult(
                applied=True,
                has_conflicts=True,
                conflicting_files=[
                    line.split(' ', 1)[1]
                    for line in data.splitlines()
                    if line.startswith('U')
                ],
                patch_output=data)
        else:
            return PatchResult(applied=False, patch_output=data)
dataset/ETHPy150Open reviewboard/rbtools/rbtools/clients/git.py/GitClient.apply_patch/swapped operands of `in`