Ejemplo n.º 1
0
    @Override
    public void run(final ContinuationContext context) {
      final MultiMap<String, Change> map = myIntersection.getChangesSubset();

      final RefreshSessionImpl session =
          new RefreshSessionImpl(
              true,
              false,
              new Runnable() {
                public void run() {
                  context.ping();
                }
              });

      for (String name : map.keySet()) {
        try {
          final Collection<Change> changes = map.get(name);
          ApplicationManager.getApplication()
              .invokeAndWait(
                  new Runnable() {
                    @Override
                    public void run() {
                      FileDocumentManager.getInstance().saveAllDocuments();
                    }
                  },
                  ModalityState.NON_MODAL);
          ShelveChangesManager.getInstance(myProject)
              .shelveChanges(
                  changes, myIntersection.getComment(name) + " (auto shelve before merge)", true);
          session.addAllFiles(ChangesUtil.getFilesFromChanges(changes));
        } catch (IOException e) {
          finishWithError(context, e.getMessage(), true);
        } catch (VcsException e) {
          finishWithError(context, e.getMessage(), true);
        }
      }
      // first suspend to guarantee stop->then start back sequence
      context.suspend();
      session.launch();
    }
Ejemplo n.º 2
0
    @Override
    public void run(ContinuationContext context) {
      final String message;
      final Intersection intersection;
      final ChangeListManager listManager = ChangeListManager.getInstance(myProject);
      final List<LocalChangeList> localChangeLists = listManager.getChangeListsCopy();

      if (myMergeAll) {
        intersection = getMergeAllIntersection(localChangeLists);
        message =
            "There are local changes that can potentially intersect with merge changes.\nDo you want to continue?";
      } else {
        intersection = checkIntersection(myLists, localChangeLists);
        message =
            "There are local changes that will intersect with merge changes.\nDo you want to continue?";
      }
      if (intersection == null || intersection.getChangesSubset().isEmpty()) return;

      final LocalChangesAction action;
      if (!myMergeAll) {
        final LocalChangesAction[] possibleResults = {
          LocalChangesAction.shelve,
          LocalChangesAction.inspect,
          LocalChangesAction.continueMerge,
          LocalChangesAction.cancel
        };
        final int result =
            Messages.showDialog(
                message,
                myTitle,
                new String[] {
                  "Shelve local changes", "Inspect changes", "Continue merge", "Cancel"
                },
                0,
                Messages.getQuestionIcon());
        action = possibleResults[result];
      } else {
        final LocalChangesAction[] possibleResults = {
          LocalChangesAction.shelve, LocalChangesAction.continueMerge, LocalChangesAction.cancel
        };
        final int result =
            Messages.showDialog(
                message,
                myTitle,
                new String[] {"Shelve local changes", "Continue merge", "Cancel"},
                0,
                Messages.getQuestionIcon());
        action = possibleResults[result];
      }
      switch (action) {
          // shelve
        case shelve:
          context.next(new ShelveLocalChanges(intersection));
          return;
          // cancel
        case cancel:
          context.cancelEverything();
          return;
          // continue
        case continueMerge:
          return;
          // inspect
        case inspect:
          final Collection<Change> changes =
              (Collection<Change>) intersection.getChangesSubset().values();
          final List<FilePath> paths = ChangesUtil.getPaths(changes);
          Collections.sort(paths, FilePathByPathComparator.getInstance());
          // todo rework message
          IntersectingLocalChangesPanel.showInVersionControlToolWindow(
              myProject,
              myTitle + ", local changes intersection",
              paths,
              "The following file(s) have local changes that will intersect with merge changes:");
          context.cancelEverything();
          return;
        default:
      }
    }