private Collection<VirtualFile> promptAboutAddition(
     SvnVcs vcs,
     List<VirtualFile> addedVFiles,
     VcsShowConfirmationOption.Value value,
     AbstractVcsHelper vcsHelper) {
   Collection<VirtualFile> filesToProcess;
   if (value == VcsShowConfirmationOption.Value.DO_ACTION_SILENTLY) {
     filesToProcess = addedVFiles;
   } else {
     final String singleFilePrompt;
     if (addedVFiles.size() == 1 && addedVFiles.get(0).isDirectory()) {
       singleFilePrompt = SvnBundle.getString("confirmation.text.add.dir");
     } else {
       singleFilePrompt = SvnBundle.getString("confirmation.text.add.file");
     }
     filesToProcess =
         vcsHelper.selectFilesToProcess(
             addedVFiles,
             SvnBundle.message("confirmation.title.add.multiple.files"),
             null,
             SvnBundle.message("confirmation.title.add.file"),
             singleFilePrompt,
             vcs.getAddConfirmation());
   }
   return filesToProcess;
 }
 @Override
 public void update(final AnActionEvent e) {
   super.update(e);
   final Presentation presentation = e.getPresentation();
   presentation.setIcon(SvnIcons.ShowIntegratedFrom);
   presentation.setText(SvnBundle.message("committed.changes.action.enable.merge.highlighting"));
   presentation.setDescription(
       SvnBundle.message("committed.changes.action.enable.merge.highlighting.description.text"));
 }
  public void loadCommittedChanges(
      ChangeBrowserSettings settings,
      RepositoryLocation location,
      int maxCount,
      final AsynchConsumer<CommittedChangeList> consumer)
      throws VcsException {
    try {
      final SvnRepositoryLocation svnLocation = (SvnRepositoryLocation) location;
      final ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
      if (progress != null) {
        progress.setText(SvnBundle.message("progress.text.changes.collecting.changes"));
        progress.setText2(
            SvnBundle.message("progress.text2.changes.establishing.connection", location));
      }

      final String repositoryRoot;
      SVNRepository repository = null;
      try {
        repository = myVcs.createRepository(svnLocation.getURL());
        repositoryRoot = repository.getRepositoryRoot(true).toString();
      } catch (SVNException e) {
        throw new VcsException(e);
      } finally {
        if (repository != null) {
          repository.closeSession();
        }
      }

      final ChangeBrowserSettings.Filter filter = settings.createFilter();

      getCommittedChangesImpl(
          settings,
          svnLocation.getURL(),
          new String[] {""},
          maxCount,
          new Consumer<SVNLogEntry>() {
            public void consume(final SVNLogEntry svnLogEntry) {
              final SvnChangeList cl =
                  new SvnChangeList(myVcs, svnLocation, svnLogEntry, repositoryRoot);
              if (filter.accepts(cl)) {
                consumer.consume(cl);
              }
            }
          },
          false,
          true);
    } finally {
      consumer.finished();
    }
  }
  private static class ErrorsFoundNotification extends Notification {

    private static final String FIX_ACTION = "FIX";
    private static final String TITLE = "";
    private static final String DESCRIPTION =
        SvnBundle.message("subversion.roots.detection.errors.found.description");

    private ErrorsFoundNotification(@NotNull final Project project) {
      super(
          NOTIFICATION_GROUP.getDisplayId(),
          TITLE,
          DESCRIPTION,
          NotificationType.ERROR,
          createListener(project));
    }

    private static NotificationListener.Adapter createListener(@NotNull final Project project) {
      return new NotificationListener.Adapter() {
        @Override
        protected void hyperlinkActivated(
            @NotNull Notification notification, @NotNull HyperlinkEvent event) {
          if (FIX_ACTION.equals(event.getDescription())) {
            WorkingCopiesContent.show(project);
          }
        }
      };
    }
  }
  public void execute() {
    int ok =
        Messages.showOkCancelDialog(
            myVcs.getProject(),
            (myChange.isMoved()
                ? SvnBundle.message(
                    "confirmation.resolve.tree.conflict.merge.moved",
                    myOldPresentation,
                    myNewPresentation)
                : SvnBundle.message(
                    "confirmation.resolve.tree.conflict.merge.renamed",
                    myOldPresentation,
                    myNewPresentation)),
            TreeConflictRefreshablePanel.TITLE,
            Messages.getQuestionIcon());
    if (Messages.OK != ok) return;

    FileDocumentManager.getInstance().saveAllDocuments();
    // final String name = "Merge changes from theirs for: " + myOldPresentation;

    final Continuation fragmented = Continuation.createFragmented(myVcs.getProject(), false);
    fragmented.addExceptionHandler(
        VcsException.class,
        new Consumer<VcsException>() {
          @Override
          public void consume(VcsException e) {
            myWarnings.add(e);
            if (e.isWarning()) {
              return;
            }
            AbstractVcsHelper.getInstance(myVcs.getProject())
                .showErrors(myWarnings, TreeConflictRefreshablePanel.TITLE);
          }
        });

    final List<TaskDescriptor> tasks = new SmartList<TaskDescriptor>();
    tasks.add(
        myDescription.isDirectory()
            ? new PreloadChangesContentsForDir()
            : new PreloadChangesContentsForFile());
    tasks.add(new ConvertTextPaths());
    tasks.add(new PatchCreator());
    tasks.add(new SelectPatchesInApplyPatchDialog());
    tasks.add(new SelectBinaryFiles());

    fragmented.run(tasks);
  }
 public ChangeListColumn[] getColumns() {
   return new ChangeListColumn[] {
     new ChangeListColumn.ChangeListNumberColumn(SvnBundle.message("revision.title")),
     ChangeListColumn.NAME,
     ChangeListColumn.DATE,
     ChangeListColumn.DESCRIPTION
   };
 }
  private void processDeletedFiles(Project project) {
    final List<Pair<FilePath, WorkingCopyFormat>> deletedFiles =
        new ArrayList<Pair<FilePath, WorkingCopyFormat>>();
    final Collection<FilePath> filesToProcess = new ArrayList<FilePath>();
    List<VcsException> exceptions = new ArrayList<VcsException>();
    final AbstractVcsHelper vcsHelper = AbstractVcsHelper.getInstance(project);

    try {
      fillDeletedFiles(project, deletedFiles, filesToProcess);
      if (deletedFiles.isEmpty() && filesToProcess.isEmpty() || myUndoingMove) return;
      SvnVcs vcs = SvnVcs.getInstance(project);
      final VcsShowConfirmationOption.Value value = vcs.getDeleteConfirmation().getValue();
      if (value != VcsShowConfirmationOption.Value.DO_NOTHING_SILENTLY) {
        if (!deletedFiles.isEmpty()) {
          final Collection<FilePath> confirmed =
              promptAboutDeletion(deletedFiles, vcs, value, vcsHelper);
          if (confirmed != null) {
            filesToProcess.addAll(confirmed);
          }
        }
        if (filesToProcess != null && !filesToProcess.isEmpty()) {
          runInBackground(
              project,
              "Deleting files from Subversion",
              createDeleteRunnable(project, vcs, filesToProcess, exceptions));
        }
        final List<FilePath> deletedFilesFiles =
            ObjectsConvertor.convert(
                deletedFiles,
                new Convertor<Pair<FilePath, WorkingCopyFormat>, FilePath>() {
                  @Override
                  public FilePath convert(Pair<FilePath, WorkingCopyFormat> o) {
                    return o.getFirst();
                  }
                });
        for (FilePath file : deletedFilesFiles) {
          final FilePath parent = file.getParentPath();
          if (parent != null) {
            myFilesToRefresh.add(parent.getVirtualFile());
          }
        }
        if (filesToProcess != null) {
          deletedFilesFiles.removeAll(filesToProcess);
        }
        for (FilePath file : deletedFilesFiles) {
          FileUtil.delete(file.getIOFile());
        }
      }
    } catch (SVNException e) {
      exceptions.add(new VcsException(e));
    }
    if (!exceptions.isEmpty()) {
      vcsHelper.showErrors(exceptions, SvnBundle.message("delete.files.errors.title"));
    }
  }
  public List<SvnChangeList> getCommittedChanges(
      ChangeBrowserSettings settings, final RepositoryLocation location, final int maxCount)
      throws VcsException {
    final SvnRepositoryLocation svnLocation = (SvnRepositoryLocation) location;
    final ArrayList<SvnChangeList> result = new ArrayList<SvnChangeList>();
    final ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
    if (progress != null) {
      progress.setText(SvnBundle.message("progress.text.changes.collecting.changes"));
      progress.setText2(
          SvnBundle.message("progress.text2.changes.establishing.connection", location));
    }

    final String repositoryRoot;
    SVNRepository repository = null;
    try {
      repository = myVcs.createRepository(svnLocation.getURL());
      repositoryRoot = repository.getRepositoryRoot(true).toString();
      repository.closeSession();
    } catch (SVNException e) {
      throw new VcsException(e);
    } finally {
      if (repository != null) {
        repository.closeSession();
      }
    }

    getCommittedChangesImpl(
        settings,
        svnLocation.getURL(),
        new String[] {""},
        maxCount,
        new Consumer<SVNLogEntry>() {
          public void consume(final SVNLogEntry svnLogEntry) {
            result.add(new SvnChangeList(myVcs, svnLocation, svnLogEntry, repositoryRoot));
          }
        },
        false,
        true);
    settings.filterChanges(result);
    return result;
  }
  private Collection<FilePath> promptAboutDeletion(
      List<Pair<FilePath, WorkingCopyFormat>> deletedFiles,
      SvnVcs vcs,
      VcsShowConfirmationOption.Value value,
      AbstractVcsHelper vcsHelper) {
    final Convertor<Pair<FilePath, WorkingCopyFormat>, FilePath> convertor =
        new Convertor<Pair<FilePath, WorkingCopyFormat>, FilePath>() {
          @Override
          public FilePath convert(Pair<FilePath, WorkingCopyFormat> o) {
            return o.getFirst();
          }
        };
    Collection<FilePath> filesToProcess;
    if (value == VcsShowConfirmationOption.Value.DO_ACTION_SILENTLY) {
      filesToProcess = ObjectsConvertor.convert(deletedFiles, convertor);
    } else {

      final String singleFilePrompt;
      if (deletedFiles.size() == 1 && deletedFiles.get(0).getFirst().isDirectory()) {
        singleFilePrompt =
            WorkingCopyFormat.ONE_DOT_SEVEN.equals(deletedFiles.get(0).getSecond())
                ? SvnBundle.getString("confirmation.text.delete.dir.17")
                : SvnBundle.getString("confirmation.text.delete.dir");
      } else {
        singleFilePrompt = SvnBundle.getString("confirmation.text.delete.file");
      }
      final Collection<FilePath> files =
          vcsHelper.selectFilePathsToProcess(
              ObjectsConvertor.convert(deletedFiles, convertor),
              SvnBundle.message("confirmation.title.delete.multiple.files"),
              null,
              SvnBundle.message("confirmation.title.delete.file"),
              singleFilePrompt,
              vcs.getDeleteConfirmation());
      filesToProcess = files == null ? null : new ArrayList<FilePath>(files);
    }
    return filesToProcess;
  }
  void commandFinished(final Project project) {
    checkOverwrites(project);
    if (myAddedFiles.containsKey(project)) {
      processAddedFiles(project);
    }
    processMovedFiles(project);
    if (myDeletedFiles.containsKey(project)) {
      processDeletedFiles(project);
    }

    final List<VcsException> exceptionList = myMoveExceptions.get(project);
    if (exceptionList != null && !exceptionList.isEmpty()) {
      AbstractVcsHelper.getInstance(project)
          .showErrors(exceptionList, SvnBundle.message("move.files.errors.title"));
    }

    if (!myFilesToRefresh.isEmpty()) {
      refreshFiles(project);
    }
  }
Exemplo n.º 11
0
 public void invokeRefreshSvnRoots(final boolean asynchronous) {
   REFRESH_LOG.debug("refresh: ", new Throwable());
   if (myCopiesRefreshManager != null) {
     if (asynchronous) {
       myCopiesRefreshManager.getCopiesRefresh().asynchRequest();
     } else {
       if (ApplicationManager.getApplication().isDispatchThread()) {
         ProgressManager.getInstance()
             .runProcessWithProgressSynchronously(
                 new Runnable() {
                   @Override
                   public void run() {
                     myCopiesRefreshManager.getCopiesRefresh().synchRequest();
                   }
                 },
                 SvnBundle.message("refreshing.working.copies.roots.progress.text"),
                 true,
                 myProject);
       } else {
         myCopiesRefreshManager.getCopiesRefresh().synchRequest();
       }
     }
   }
 }
 private void processAddedFiles(Project project) {
   SvnVcs vcs = SvnVcs.getInstance(project);
   List<VirtualFile> addedVFiles = new ArrayList<VirtualFile>();
   Map<VirtualFile, File> copyFromMap = new HashMap<VirtualFile, File>();
   final Set<VirtualFile> recursiveItems = new HashSet<VirtualFile>();
   fillAddedFiles(project, vcs, addedVFiles, copyFromMap, recursiveItems);
   if (addedVFiles.isEmpty()) return;
   final VcsShowConfirmationOption.Value value = vcs.getAddConfirmation().getValue();
   if (value != VcsShowConfirmationOption.Value.DO_NOTHING_SILENTLY) {
     final AbstractVcsHelper vcsHelper = AbstractVcsHelper.getInstance(project);
     final Collection<VirtualFile> filesToProcess =
         promptAboutAddition(vcs, addedVFiles, value, vcsHelper);
     if (filesToProcess != null && !filesToProcess.isEmpty()) {
       final List<VcsException> exceptions = new ArrayList<VcsException>();
       runInBackground(
           project,
           "Adding files to Subversion",
           createAdditionRunnable(project, vcs, copyFromMap, filesToProcess, exceptions));
       if (!exceptions.isEmpty()) {
         vcsHelper.showErrors(exceptions, SvnBundle.message("add.files.errors.title"));
       }
     }
   }
 }
 public String getChangelistTitle() {
   return SvnBundle.message("changes.browser.revision.term");
 }
  private void getCommittedChangesImpl(
      ChangeBrowserSettings settings,
      final String url,
      final String[] filterUrls,
      final int maxCount,
      final Consumer<SVNLogEntry> resultConsumer,
      final boolean includeMergedRevisions,
      final boolean filterOutByDate)
      throws VcsException {
    final ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
    if (progress != null) {
      progress.setText(SvnBundle.message("progress.text.changes.collecting.changes"));
      progress.setText2(SvnBundle.message("progress.text2.changes.establishing.connection", url));
    }
    try {
      SVNLogClient logger = myVcs.createLogClient();

      final String author = settings.getUserFilter();
      final Date dateFrom = settings.getDateAfterFilter();
      final Long changeFrom = settings.getChangeAfterFilter();
      final Date dateTo = settings.getDateBeforeFilter();
      final Long changeTo = settings.getChangeBeforeFilter();

      final SVNRevision revisionBefore;
      if (dateTo != null) {
        revisionBefore = SVNRevision.create(dateTo);
      } else if (changeTo != null) {
        revisionBefore = SVNRevision.create(changeTo.longValue());
      } else {
        SVNRepository repository = null;
        final long revision;
        try {
          repository = myVcs.createRepository(url);
          revision = repository.getLatestRevision();
        } finally {
          if (repository != null) {
            repository.closeSession();
          }
        }
        revisionBefore = SVNRevision.create(revision);
      }
      final SVNRevision revisionAfter;
      if (dateFrom != null) {
        revisionAfter = SVNRevision.create(dateFrom);
      } else if (changeFrom != null) {
        revisionAfter = SVNRevision.create(changeFrom.longValue());
      } else {
        revisionAfter = SVNRevision.create(1);
      }

      logger.doLog(
          SVNURL.parseURIEncoded(url),
          filterUrls,
          revisionBefore,
          revisionBefore,
          revisionAfter,
          settings.STOP_ON_COPY,
          true,
          includeMergedRevisions,
          maxCount,
          null,
          new ISVNLogEntryHandler() {
            public void handleLogEntry(SVNLogEntry logEntry) {
              if (myProject.isDisposed()) throw new ProcessCanceledException();
              if (progress != null) {
                progress.setText2(
                    SvnBundle.message(
                        "progress.text2.processing.revision", logEntry.getRevision()));
                progress.checkCanceled();
              }
              if (filterOutByDate && logEntry.getDate() == null) {
                // do not add lists without info - this situation is possible for lists where there
                // are paths that user has no rights to observe
                return;
              }
              if (author == null || author.equalsIgnoreCase(logEntry.getAuthor())) {
                resultConsumer.consume(logEntry);
              }
            }
          });
    } catch (SVNException e) {
      throw new VcsException(e);
    }
  }
  public void getCommittedChangesWithMergedRevisons(
      final ChangeBrowserSettings settings,
      final RepositoryLocation location,
      final int maxCount,
      final PairConsumer<SvnChangeList, TreeStructureNode<SVNLogEntry>> finalConsumer)
      throws VcsException {
    final SvnRepositoryLocation svnLocation = (SvnRepositoryLocation) location;
    final ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
    if (progress != null) {
      progress.setText(SvnBundle.message("progress.text.changes.collecting.changes"));
      progress.setText2(
          SvnBundle.message("progress.text2.changes.establishing.connection", location));
    }

    final String repositoryRoot;
    SVNRepository repository = null;
    try {
      repository = myVcs.createRepository(svnLocation.getURL());
      repositoryRoot = repository.getRepositoryRoot(true).toString();
    } catch (SVNException e) {
      throw new VcsException(e);
    } finally {
      if (repository != null) {
        repository.closeSession();
      }
    }

    final MergeTrackerProxy proxy =
        new MergeTrackerProxy(
            new Consumer<TreeStructureNode<SVNLogEntry>>() {
              public void consume(TreeStructureNode<SVNLogEntry> node) {
                finalConsumer.consume(
                    new SvnChangeList(myVcs, svnLocation, node.getMe(), repositoryRoot), node);
              }
            });
    final SvnMergeSourceTracker mergeSourceTracker =
        new SvnMergeSourceTracker(
            new ThrowableConsumer<Pair<SVNLogEntry, Integer>, SVNException>() {
              public void consume(Pair<SVNLogEntry, Integer> svnLogEntryIntegerPair)
                  throws SVNException {
                proxy.consume(svnLogEntryIntegerPair);
              }
            });

    getCommittedChangesImpl(
        settings,
        svnLocation.getURL(),
        new String[] {""},
        maxCount,
        new Consumer<SVNLogEntry>() {
          public void consume(final SVNLogEntry svnLogEntry) {
            try {
              mergeSourceTracker.consume(svnLogEntry);
            } catch (SVNException e) {
              throw new RuntimeException(e);
              // will not occur actually but anyway never eat them
            }
          }
        },
        true,
        false);

    proxy.finish();
  }