@Override
  public void copyChangesFromBranch(@NotNull List<? extends Change> changes,
                                    boolean swapSides) throws VcsException {

    MultiMap<VirtualFile, FilePath> toCheckout = MultiMap.createSet();
    MultiMap<VirtualFile, FilePath> toDelete = MultiMap.createSet();

    for (Change change : changes) {
      FilePath currentPath = swapSides ? ChangesUtil.getAfterPath(change) : ChangesUtil.getBeforePath(change);
      FilePath branchPath = !swapSides ? ChangesUtil.getAfterPath(change) : ChangesUtil.getBeforePath(change);
      assert currentPath != null || branchPath != null;
      VirtualFile root = GitUtil.getRootForFile(myProject, ObjectUtils.chooseNotNull(currentPath, branchPath));
      if (currentPath != null && branchPath != null) {
        if (!Comparing.equal(currentPath, branchPath)) {
          toDelete.putValue(root, currentPath);
        }
        toCheckout.putValue(root, branchPath);
      }
      else if (currentPath != null) {
        toDelete.putValue(root, currentPath);
      }
      else {
        toCheckout.putValue(root, branchPath);
      }
    }

    for (Map.Entry<VirtualFile, Collection<FilePath>> entry : toDelete.entrySet()) {
      VirtualFile root = entry.getKey();
      Collection<FilePath> rootPaths = entry.getValue();

      GitFileUtils.deletePaths(myProject, root, rootPaths);
    }

    for (Map.Entry<VirtualFile, Collection<FilePath>> entry : toCheckout.entrySet()) {
      VirtualFile root = entry.getKey();
      Collection<FilePath> rootPaths = entry.getValue();

      for (List<String> paths : VcsFileUtil.chunkPaths(root, rootPaths)) {
        GitLineHandler handler = new GitLineHandler(myProject, root, GitCommand.CHECKOUT);
        handler.addParameters(myBranchName);
        handler.endOptions();
        handler.addParameters(paths);
        GitCommandResult result = Git.getInstance().runCommand(handler);
        result.throwOnError();
      }

      GitFileUtils.addPaths(myProject, root, rootPaths);
    }

    RefreshVFsSynchronously.updateChanges(changes);
    VcsDirtyScopeManager.getInstance(myProject).filePathsDirty(ChangesUtil.getPaths(changes), null);

    reloadTotalDiff();
  }
@Override
  public void copyChangesFromBranch(@NotNull List<? extends Change> changes,
                                    boolean swapSides)