コード例 #1
0
  @Override
  protected void doOKAction() {
    VirtualFile root = getGitRoot();
    GitLineHandler h = handler();
    final AtomicBoolean conflict = new AtomicBoolean();

    h.addLineListener(
        new GitLineHandlerAdapter() {
          public void onLineAvailable(String line, Key outputType) {
            if (line.contains("Merge conflict")) {
              conflict.set(true);
            }
          }
        });
    int rc =
        GitHandlerUtil.doSynchronously(
            h, GitBundle.getString("unstash.unstashing"), h.printableCommandLine(), false);
    root.refresh(true, true);

    if (conflict.get()) {
      boolean conflictsResolved =
          new UnstashConflictResolver(myProject, root, getSelectedStash()).merge();
      LOG.info("loadRoot " + root + ", conflictsResolved: " + conflictsResolved);
    } else if (rc != 0) {
      GitUIUtil.showOperationErrors(myProject, h.errors(), h.printableCommandLine());
    }
    super.doOKAction();
  }
コード例 #2
0
  private boolean stash() {
    if (!mySyncResult.hasLocalRepository()) {
      LOG.error("unexpected null local repro in call to stash");
      return false;
    }

    final ChangeListManager changeListManager = ChangeListManager.getInstance(myProject);
    if (changeListManager.isFreezedWithNotification("Can not stash changes now")) return false;

    final GitLineHandler handler =
        new GitLineHandler(myProject, mySourceRepository.getRoot(), GitCommand.STASH);
    handler.addParameters("save");
    handler.addParameters("--keep-index");
    String date =
        DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT).format(new Date());
    myStashMessage =
        "Cloud Debugger saved changes from branch " + myOriginalBranchName + " at " + date;
    handler.addParameters(myStashMessage);
    AccessToken token = DvcsUtil.workingTreeChangeStarted(myProject);
    try {
      GitHandlerUtil.doSynchronously(
          handler, GitBundle.getString("stashing.title"), handler.printableCommandLine());
    } finally {
      DvcsUtil.workingTreeChangeFinished(myProject, token);
    }
    return true;
  }