Exemplo n.º 1
0
 // todo can be a very base class!
 @CalledInAny
 private void finishWithError(
     final ContinuationContext context, final String message, final boolean isError) {
   context.cancelEverything();
   context.next(
       new TaskDescriptor(message, Where.AWT) {
         @Override
         public void run(ContinuationContext context) {
           VcsBalloonProblemNotifier.showOverChangesView(
               myProject, message, isError ? MessageType.ERROR : MessageType.WARNING);
         }
       });
 }
Exemplo n.º 2
0
 @CalledInAny
 private void finishWithError(
     final ContinuationContext context,
     final String message,
     final List<VcsException> exceptions) {
   context.cancelEverything();
   context.next(
       new TaskDescriptor(message, Where.AWT) {
         @Override
         public void run(ContinuationContext context) {
           AbstractVcsHelper.getInstance(myProject).showErrors(exceptions, message);
         }
       });
 }
Exemplo n.º 3
0
    @Override
    public void run(ContinuationContext context) {
      final SVNURL sourceUrlUrl;
      try {
        sourceUrlUrl = SVNURL.parseURIEncoded(mySourceUrl);
      } catch (SVNException e) {
        finishWithError(context, "Cannot merge: " + e.getMessage(), true);
        return;
      }

      context.next(
          new TaskDescriptor(getName(), Where.POOLED) {
            @Override
            public void run(ContinuationContext context) {
              final SvnIntegrateChangesTask task =
                  new SvnIntegrateChangesTask(
                      SvnVcs.getInstance(myProject),
                      new WorkingCopyInfo(myWcInfo.getPath(), true),
                      myFactory,
                      sourceUrlUrl,
                      getName(),
                      false,
                      myBranchName);
              RunBackgroundable.run(task);
            }
          });
      createChangelist(context);
    }
Exemplo n.º 4
0
    @Override
    public void run(final ContinuationContext context) {
      final int result =
          Messages.showYesNoCancelDialog(
              myProject,
              "Merge all?",
              myTitle,
              "Merge &all",
              "&Select revisions to merge",
              "Cancel",
              Messages.getQuestionIcon());
      if (result == 2) return;
      if (result == 0) {
        insertMergeAll(context);
        return;
      }

      final MergeCalculator calculator;
      try {
        calculator = new MergeCalculator(myWcInfo, mySourceUrl, myBranchName);
      } catch (SVNException e) {
        finishWithError(context, e.getMessage(), true);
        return;
      }
      context.next(
          myVcs
              .getSvnBranchPointsCalculator()
              .getFirstCopyPointTask(
                  myWcInfo.getRepositoryRoot(), myWcInfo.getRootUrl(), mySourceUrl, calculator),
          calculator);
    }
Exemplo n.º 5
0
    @Override
    public void run(ContinuationContext continuationContext) {
      if (SVNPathUtil.isAncestor(mySourceUrl, myWcInfo.getRootUrl())
          || SVNPathUtil.isAncestor(myWcInfo.getRootUrl(), mySourceUrl)) {
        finishWithError(continuationContext, "Cannot merge from self", true);
        return;
      }

      if (!checkForSwitchedRoots()) {
        continuationContext.cancelEverything();
      }
    }
Exemplo n.º 6
0
 @Override
 public void run(ContinuationContext context) {
   final ToBeMergedDialog dialog =
       new ToBeMergedDialog(myProject, myNotMerged, myMergeTitle, myMergeChecker);
   dialog.show();
   if (dialog.getExitCode() == DialogWrapper.CANCEL_EXIT_CODE) {
     context.cancelEverything();
     return;
   }
   if (dialog.getExitCode() == ToBeMergedDialog.MERGE_ALL_CODE) {
     insertMergeAll(context);
   } else {
     final List<CommittedChangeList> lists = dialog.getSelected();
     if (lists.isEmpty()) return;
     final MergerFactory factory =
         new ChangeListsMergerFactory(lists) {
           @Override
           public IMerger createMerger(
               SvnVcs vcs,
               File target,
               UpdateEventHandler handler,
               SVNURL currentBranchUrl,
               String branchName) {
             return new GroupMerger(
                 vcs,
                 lists,
                 target,
                 handler,
                 currentBranchUrl,
                 branchName,
                 false,
                 false,
                 false);
           }
         };
     context.next(
         new LocalChangesPrompt(false, lists, myCopyPoint),
         new MergeTask(factory, myMergeTitle));
   }
 }
Exemplo n.º 7
0
    @Override
    public void run(ContinuationContext context) {
      if (myData == null) {
        finishWithError(context, "Merge start wasn't found", true);
        return;
      }
      final boolean reintegrate = myData.isInvertedSense();
      if (reintegrate
          && (!prompt(
              "<html><body>You are going to reintegrate changes.<br><br>This will make branch '"
                  + mySourceUrl
                  + "' <b>no longer usable for further work</b>."
                  + "<br>It will not be able to correctly absorb new trunk ("
                  + myData.inverted().getTarget()
                  + ") changes,<br>nor can this branch be properly reintegrated to trunk again.<br><br>Are you sure?</body></html>"))) {
        context.cancelEverything();
        return;
      }
      final MergerFactory mergerFactory = createBranchMergerFactory(reintegrate);

      final String title =
          "Merging all from " + myBranchName + (reintegrate ? " (reintegrate)" : "");
      context.next(new MergeTask(mergerFactory, title));
    }
Exemplo n.º 8
0
 @Override
 public void run(ContinuationContext context) {
   try {
     final List<TaskDescriptor> tasks = new LinkedList<TaskDescriptor>();
     final boolean supportsMergeinfo =
         myWcInfo.getFormat().supportsMergeInfo()
             && SvnUtil.doesRepositorySupportMergeinfo(
                 myVcs, SVNURL.parseURIEncoded(mySourceUrl));
     if (!supportsMergeinfo) {
       insertMergeAll(tasks);
     } else {
       tasks.add(new MergeAllOrSelectedChooser());
     }
     context.next(tasks);
   } catch (SVNException e) {
     finishWithError(context, e.getMessage(), true);
   }
 }
Exemplo n.º 9
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();
    }
Exemplo n.º 10
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:
      }
    }
Exemplo n.º 11
0
    // "Calculating not merged revisions"
    @Override
    public void run(ContinuationContext context) {
      if (myCopyData == null) {
        finishWithError(context, "Merge start wasn't found", true);
        return;
      }

      final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
      myIsReintegrate = myCopyData.isInvertedSense();
      if (!myWcInfo.getFormat().supportsMergeInfo()) return;
      final SvnBranchPointsCalculator.BranchCopyData data = myCopyData.getTrue();
      final long sourceLatest = data.getTargetRevision();

      final SvnCommittedChangesProvider committedChangesProvider =
          (SvnCommittedChangesProvider) myVcs.getCommittedChangesProvider();
      final ChangeBrowserSettings settings = new ChangeBrowserSettings();
      settings.CHANGE_AFTER = Long.toString(sourceLatest);
      settings.USE_CHANGE_AFTER_FILTER = true;

      String local =
          SVNPathUtil.getRelativePath(myWcInfo.getRepositoryRoot(), myWcInfo.getRootUrl());
      final String relativeLocal = (local.startsWith("/") ? local : "/" + local);

      final LinkedList<Pair<SvnChangeList, TreeStructureNode<SVNLogEntry>>> list =
          new LinkedList<Pair<SvnChangeList, TreeStructureNode<SVNLogEntry>>>();
      try {
        committedChangesProvider.getCommittedChangesWithMergedRevisons(
            settings,
            new SvnRepositoryLocation(mySourceUrl),
            0,
            new PairConsumer<SvnChangeList, TreeStructureNode<SVNLogEntry>>() {
              public void consume(SvnChangeList svnList, TreeStructureNode<SVNLogEntry> tree) {
                indicator.checkCanceled();
                if (sourceLatest >= svnList.getNumber()) return;
                list.add(new Pair<SvnChangeList, TreeStructureNode<SVNLogEntry>>(svnList, tree));
              }
            });
      } catch (VcsException e) {
        finishWithError(
            context, "Checking revisions for merge fault", Collections.singletonList(e));
      }

      indicator.setText("Checking merge information...");
      // to do not go into file system while asking something on the net
      for (Pair<SvnChangeList, TreeStructureNode<SVNLogEntry>> pair : list) {
        final SvnChangeList svnList = pair.getFirst();
        final SvnMergeInfoCache.MergeCheckResult checkResult = myMergeChecker.checkList(svnList);
        indicator.setText2("Processing revision " + svnList.getNumber());

        if (SvnMergeInfoCache.MergeCheckResult.NOT_MERGED.equals(checkResult)) {
          // additionally check for being 'local'
          final List<TreeStructureNode<SVNLogEntry>> children = pair.getSecond().getChildren();
          boolean localChange = false;
          for (TreeStructureNode<SVNLogEntry> child : children) {
            if (isLocalRevisionMergeIteration(child, relativeLocal, indicator)) {
              localChange = true;
              break;
            }
          }

          if (!localChange) {
            myNotMerged.add(svnList);
          }
        }
      }

      if (myNotMerged.isEmpty()) {
        finishWithError(context, "Everything is up-to-date", false);
        return;
      }
      context.next(new ShowRevisionSelector(myCopyData));
    }
Exemplo n.º 12
0
 private void insertMergeAll(final ContinuationContext context) {
   final List<TaskDescriptor> queue = new LinkedList<TaskDescriptor>();
   insertMergeAll(queue);
   context.next(queue);
 }
  @AsynchronousExecution
  public void scheduleUnshelveChangeList(
      final ShelvedChangeList changeList,
      @Nullable final List<ShelvedChange> changes,
      @Nullable final List<ShelvedBinaryFile> binaryFiles,
      @Nullable final LocalChangeList targetChangeList,
      final boolean showSuccessNotification,
      final ContinuationContext context,
      final boolean silentAddDelete) {
    context.next(
        new TaskDescriptor("", Where.AWT) {
          @Override
          public void run(ContinuationContext contextInner) {
            final List<FilePatch> remainingPatches = new ArrayList<FilePatch>();

            final CommitContext commitContext = new CommitContext();
            final List<TextFilePatch> textFilePatches;
            try {
              textFilePatches =
                  loadTextPatches(myProject, changeList, changes, remainingPatches, commitContext);
            } catch (IOException e) {
              LOG.info(e);
              PatchApplier.showError(myProject, "Cannot load patch(es): " + e.getMessage(), true);
              return;
            } catch (PatchSyntaxException e) {
              PatchApplier.showError(myProject, "Cannot load patch(es): " + e.getMessage(), true);
              LOG.info(e);
              return;
            }

            final List<FilePatch> patches = new ArrayList<FilePatch>(textFilePatches);

            final List<ShelvedBinaryFile> remainingBinaries = new ArrayList<ShelvedBinaryFile>();
            final List<ShelvedBinaryFile> binaryFilesToUnshelve =
                getBinaryFilesToUnshelve(changeList, binaryFiles, remainingBinaries);

            for (final ShelvedBinaryFile shelvedBinaryFile : binaryFilesToUnshelve) {
              patches.add(new ShelvedBinaryFilePatch(shelvedBinaryFile));
            }

            final BinaryPatchApplier binaryPatchApplier =
                new BinaryPatchApplier(binaryFilesToUnshelve.size());
            final PatchApplier<ShelvedBinaryFilePatch> patchApplier =
                new PatchApplier<ShelvedBinaryFilePatch>(
                    myProject,
                    myProject.getBaseDir(),
                    patches,
                    targetChangeList,
                    binaryPatchApplier,
                    commitContext);

            // after patch applier part
            contextInner.next(
                new TaskDescriptor("", Where.AWT) {
                  @Override
                  public void run(ContinuationContext context) {
                    remainingPatches.addAll(patchApplier.getRemainingPatches());

                    if ((remainingPatches.size() == 0) && remainingBinaries.isEmpty()) {
                      recycleChangeList(changeList);
                    } else {
                      saveRemainingPatches(
                          changeList, remainingPatches, remainingBinaries, commitContext);
                    }
                  }
                });

            patchApplier.scheduleSelf(showSuccessNotification, contextInner, silentAddDelete);
          }
        });
  }