コード例 #1
0
  private boolean getAddedFilesPlaceOption() {
    final SvnConfiguration configuration = SvnConfiguration.getInstance(myVcs.getProject());
    boolean add = Boolean.TRUE.equals(configuration.isKeepNewFilesAsIsForTreeConflictMerge());
    if (configuration.isKeepNewFilesAsIsForTreeConflictMerge() != null) {
      return add;
    }
    if (!containAdditions(myTheirsChanges) && !containAdditions(myTheirsBinaryChanges)) {
      return false;
    }
    return Messages.YES
        == MessageDialogBuilder.yesNo(
                TreeConflictRefreshablePanel.TITLE,
                "Keep newly created file(s) in their original place?")
            .yesText("Keep")
            .noText("Move")
            .doNotAsk(
                new DialogWrapper.DoNotAskOption() {
                  @Override
                  public boolean isToBeShown() {
                    return true;
                  }

                  @Override
                  public void setToBeShown(boolean value, int exitCode) {
                    if (!value) {
                      if (exitCode == 0) {
                        // yes
                        configuration.setKeepNewFilesAsIsForTreeConflictMerge(true);
                      } else {
                        configuration.setKeepNewFilesAsIsForTreeConflictMerge(false);
                      }
                    }
                  }

                  @Override
                  public boolean canBeHidden() {
                    return true;
                  }

                  @Override
                  public boolean shouldSaveOptionsOnCancel() {
                    return true;
                  }

                  @NotNull
                  @Override
                  public String getDoNotShowMessage() {
                    return CommonBundle.message("dialog.options.do.not.ask");
                  }
                })
            .show();
  }
コード例 #2
0
  private static boolean performImpl(
      final Project project, final SvnVcs activeVcs, final VirtualFile file) throws VcsException {
    final ShareDialog shareDialog = new ShareDialog(project, file.getName());
    shareDialog.show();

    final String parent = shareDialog.getSelectedURL();
    if (shareDialog.isOK() && parent != null) {
      final Ref<Boolean> actionStarted = new Ref<Boolean>(Boolean.TRUE);
      final SVNException[] error = new SVNException[1];

      final ShareDialog.ShareTarget shareTarget = shareDialog.getShareTarget();
      final ProgressManager progressManager = ProgressManager.getInstance();

      if (ShareDialog.ShareTarget.useSelected.equals(shareTarget)) {
        final boolean folderEmpty = checkRemoteFolder(project, activeVcs, parent, progressManager);

        if (!folderEmpty) {
          final int promptAnswer =
              Messages.showYesNoDialog(
                  project,
                  "Remote folder \""
                      + parent
                      + "\" is not empty.\nDo you want to continue sharing?",
                  "Share directory",
                  Messages.getWarningIcon());
          if (DialogWrapper.OK_EXIT_CODE != promptAnswer) return false;
        }
      }

      ExclusiveBackgroundVcsAction.run(
          project,
          new Runnable() {
            public void run() {
              progressManager.runProcessWithProgressSynchronously(
                  new Runnable() {
                    public void run() {
                      try {
                        final ProgressIndicator indicator =
                            ProgressManager.getInstance().getProgressIndicator();

                        final File path = new File(file.getPath());
                        if (!SvnCheckoutProvider.promptForWCFormatAndSelect(path, project)) {
                          // action cancelled
                          actionStarted.set(Boolean.FALSE);
                          return;
                        }
                        final SVNURL parenUrl = SVNURL.parseURIEncoded(parent);
                        final SVNURL checkoutUrl;
                        final SVNRevision revision;

                        if (ShareDialog.ShareTarget.useSelected.equals(shareTarget)) {
                          checkoutUrl = parenUrl;
                          revision = SVNRevision.HEAD;
                        } else if (ShareDialog.ShareTarget.useProjectName.equals(shareTarget)) {
                          final Pair<SVNRevision, SVNURL> pair =
                              createRemoteFolder(activeVcs, parenUrl, file.getName());
                          revision = pair.getFirst();
                          checkoutUrl = pair.getSecond();
                        } else {
                          final Pair<SVNRevision, SVNURL> pair =
                              createRemoteFolder(activeVcs, parenUrl, file.getName());
                          final Pair<SVNRevision, SVNURL> trunkPair =
                              createRemoteFolder(activeVcs, pair.getSecond(), "trunk");
                          checkoutUrl = trunkPair.getSecond();
                          revision = trunkPair.getFirst();

                          if (shareDialog.createStandardStructure()) {
                            createRemoteFolder(activeVcs, pair.getSecond(), "branches");
                            createRemoteFolder(activeVcs, pair.getSecond(), "tags");
                          }
                        }

                        if (indicator != null) {
                          indicator.checkCanceled();
                          indicator.setText(
                              SvnBundle.message(
                                  "share.directory.checkout.back.progress.text",
                                  checkoutUrl.toString()));
                        }
                        final SVNUpdateClient client = activeVcs.createUpdateClient();
                        if (!WorkingCopyFormat.ONE_DOT_SEVEN.equals(
                            SvnWorkingCopyFormatHolder.getPresetFormat())) {
                          client.getOperationsFactory().setPrimaryWcGeneration(SvnWcGeneration.V16);
                        }
                        client.doCheckout(
                            checkoutUrl,
                            path,
                            SVNRevision.UNDEFINED,
                            revision,
                            SVNDepth.INFINITY,
                            false);
                        SvnWorkingCopyFormatHolder.setPresetFormat(null);

                        addRecursively(activeVcs, file);
                      } catch (SVNException e) {
                        error[0] = e;
                      } finally {
                        activeVcs.invokeRefreshSvnRoots(true);
                        SvnWorkingCopyFormatHolder.setPresetFormat(null);
                      }
                    }
                  },
                  SvnBundle.message("share.directory.title"),
                  true,
                  project);
            }
          });

      if (Boolean.TRUE.equals(actionStarted.get())) {
        if (error[0] != null) {
          throw new VcsException(error[0].getMessage());
        }
        Messages.showInfoMessage(
            project,
            SvnBundle.message("share.directory.info.message", file.getName()),
            SvnBundle.message("share.directory.title"));
      }
      return true;
    }
    return false;
  }
コード例 #3
0
  public void reportAppendableHistory(
      FilePath path,
      final VcsAppendableHistorySessionPartner partner,
      @Nullable final SVNRevision from,
      @Nullable final SVNRevision to,
      final int limit,
      SVNRevision peg,
      final boolean forceBackwards)
      throws VcsException {
    FilePath committedPath = path;
    Change change = ChangeListManager.getInstance(myVcs.getProject()).getChange(path);
    if (change != null) {
      final ContentRevision beforeRevision = change.getBeforeRevision();
      final ContentRevision afterRevision = change.getAfterRevision();
      if (beforeRevision != null
          && afterRevision != null
          && !beforeRevision.getFile().equals(afterRevision.getFile())
          && afterRevision.getFile().equals(path)) {
        committedPath = beforeRevision.getFile();
      }
      // revision can be VcsRevisionNumber.NULL
      if (peg == null
          && change.getBeforeRevision() != null
          && change.getBeforeRevision().getRevisionNumber() instanceof SvnRevisionNumber) {
        peg = ((SvnRevisionNumber) change.getBeforeRevision().getRevisionNumber()).getRevision();
      }
    }

    final boolean showMergeSources =
        SvnConfiguration.getInstance(myVcs.getProject()).isShowMergeSourcesInAnnotate();
    final LogLoader logLoader;
    if (path.isNonLocal()) {
      logLoader =
          new RepositoryLoader(
              myVcs, committedPath, from, to, limit, peg, forceBackwards, showMergeSources);
    } else {
      logLoader = new LocalLoader(myVcs, committedPath, from, to, limit, peg, showMergeSources);
    }

    try {
      logLoader.preliminary();
    } catch (SVNCancelException e) {
      throw new VcsException(e);
    } catch (SVNException e) {
      throw new VcsException(e);
    }
    logLoader.check();
    if (showMergeSources) {
      logLoader.initSupports15();
    }

    final SvnHistorySession historySession =
        new SvnHistorySession(
            myVcs,
            Collections.<VcsFileRevision>emptyList(),
            committedPath,
            showMergeSources && Boolean.TRUE.equals(logLoader.mySupport15),
            null,
            false,
            !path.isNonLocal());

    final Ref<Boolean> sessionReported = new Ref<Boolean>();
    final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
    if (indicator != null) {
      indicator.setText(SvnBundle.message("progress.text2.collecting.history", path.getName()));
    }
    final Consumer<VcsFileRevision> consumer =
        new Consumer<VcsFileRevision>() {
          @Override
          public void consume(VcsFileRevision vcsFileRevision) {
            if (!Boolean.TRUE.equals(sessionReported.get())) {
              partner.reportCreatedEmptySession(historySession);
              sessionReported.set(true);
            }
            partner.acceptRevision(vcsFileRevision);
          }
        };

    logLoader.setConsumer(consumer);
    logLoader.load();
    logLoader.check();
  }