/**
   * Checks if update is possible, saves local changes and updates all roots. In case of error shows
   * notification and returns false. If update completes without errors, returns true.
   *
   * <p>Perform update on all roots. 0. Blocks reloading project on external change, saving/syncing
   * on frame deactivation. 1. Checks if update is possible (rebase/merge in progress, no tracked
   * branches...) and provides merge dialog to solve problems. 2. Finds updaters to use (merge or
   * rebase). 3. Preserves local changes if needed (not needed for merge sometimes). 4. Updates via
   * 'git pull' or equivalent. 5. Restores local changes if update completed or failed with error.
   * If update is incomplete, i.e. some unmerged files remain, local changes are not restored.
   */
  @NotNull
  public GitUpdateResult update(final UpdateMethod updateMethod) {
    LOG.info("update started|" + updateMethod);
    String oldText = myProgressIndicator.getText();
    myProgressIndicator.setText("Updating...");

    for (GitRepository repository : myRepositories) {
      repository.update();
    }

    // check if update is possible
    if (checkRebaseInProgress()
        || isMergeInProgress()
        || areUnmergedFiles()
        || !checkTrackedBranchesConfigured()) {
      return GitUpdateResult.NOT_READY;
    }

    if (!fetchAndNotify()) {
      return GitUpdateResult.NOT_READY;
    }

    AccessToken token = DvcsUtil.workingTreeChangeStarted(myProject);
    GitUpdateResult result;
    try {
      result = updateImpl(updateMethod);
    } finally {
      DvcsUtil.workingTreeChangeFinished(myProject, token);
    }
    myProgressIndicator.setText(oldText);
    return result;
  }
 protected void showProgressMessage(final ProgressIndicator progress, final File root) {
   if (SvnConfiguration.getInstance(myVcs.getProject()).MERGE_DRY_RUN) {
     progress.setText(
         SvnBundle.message("progress.text.merging.dry.run.changes", root.getAbsolutePath()));
   } else {
     progress.setText(
         SvnBundle.message("progress.text.merging.changes", root.getAbsolutePath()));
   }
 }
  public static void writeFileImpl(String folder, @NonNls String fileName, CharSequence buf)
      throws IOException {
    ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
    final String fullPath = folder + File.separator + fileName;

    if (indicator != null) {
      ProgressManager.checkCanceled();
      indicator.setText(
          InspectionsBundle.message("inspection.export.generating.html.for", fullPath));
    }

    FileWriter writer = null;
    try {
      File folderFile = new File(folder);
      folderFile.mkdirs();
      new File(fullPath).getParentFile().mkdirs();
      writer = new FileWriter(fullPath);
      writer.write(buf.toString().toCharArray());
    } finally {
      if (writer != null) {
        try {
          writer.close();
        } catch (IOException e) {
          // Cannot do anything in case of exception
        }
      }
    }
  }
 @Override
 public synchronized void setText(String text) {
   super.setText(text);
   if (myOriginal.isRunning()) {
     myOriginal.setText(text);
   }
 }
 private void updateIndicatorText(@NotNull String upperLabel, @NotNull String downLabel) {
   ProgressIndicator indicator = myCompositeTask.getIndicator();
   if (indicator != null) {
     indicator.setText(upperLabel);
     indicator.setText2(downLabel);
   }
 }
  private void perform(final ProgressIndicator indicator) {
    indicator.setText("Downloading OSGi framework");
    indicator.setIndeterminate(true);

    try {
      myProcessHandler =
          new DefaultJavaProcessHandler(createJavaParameters()) {
            public void notifyTextAvailable(String text, Key outputType) {
              updateProgress(indicator, text);
            }
          };
    } catch (ExecutionException e) {
      myIsSuccessful = false;
      myErrorMessage = "Error when starting pax runner: " + e.getMessage();
      return;
    }

    start();
    readProcessOutput();
    stop();
    int i = myProcessHandler.getProcess().exitValue();
    if (i != 0) {
      myIsSuccessful = false;
    } else {
      myIsSuccessful = true;
    }
  }
 private void doIndexing(
     @NotNull final VirtualFile virtualFile, @NotNull final ProgressIndicator indicator) {
   final int fileId = FileBasedIndex.getFileId(virtualFile);
   indicator.setText("IntelliJence Advisor plugin indexing...");
   indicator.setText2(virtualFile.getCanonicalPath());
   final Long timestamp = getTimestamp(fileId);
   ProgressManager.checkCanceled();
   final long currentTimeStamp = virtualFile.getModificationStamp();
   if (timestamp == null || timestamp != currentTimeStamp) {
     putTimestamp(fileId, currentTimeStamp);
     final ClassReader reader;
     try {
       reader = new ClassReader(virtualFile.contentsToByteArray());
     } catch (IOException e) {
       removeTimestamp(fileId);
       return;
     }
     try {
       for (final AdvisorBaseIndex index : indexes) {
         index.update(fileId, reader);
       }
     } catch (RuntimeException e) {
       log.error(String.format("can't index file: %s", virtualFile.getCanonicalPath()));
       // TODO delete it
       e.printStackTrace();
       throw e;
     }
   }
 }
  private void initProject(@NotNull ProjectImpl project, @Nullable ProjectImpl template)
      throws IOException {
    final ProgressIndicator indicator = myProgressManager.getProgressIndicator();
    if (indicator != null && !project.isDefault()) {
      indicator.setText(ProjectBundle.message("loading.components.for", project.getName()));
      indicator.setIndeterminate(true);
    }

    ApplicationManager.getApplication()
        .getMessageBus()
        .syncPublisher(ProjectLifecycleListener.TOPIC)
        .beforeProjectLoaded(project);

    try {
      if (template != null) {
        project.getStateStore().loadProjectFromTemplate(template);
      } else {
        project.getStateStore().load();
      }
      project.loadProjectComponents();
      project.init();
    } catch (IOException e) {
      scheduleDispose(project);
      throw e;
    } catch (ProcessCanceledException e) {
      scheduleDispose(project);
      throw e;
    }
  }
예제 #9
0
  public static boolean prepareToInstall(
      List<PluginNode> pluginsToInstall, List<IdeaPluginDescriptor> allPlugins) {
    ProgressIndicator pi = ProgressManager.getInstance().getProgressIndicator();

    final List<PluginId> pluginIds = new ArrayList<PluginId>();
    for (PluginNode pluginNode : pluginsToInstall) {
      pluginIds.add(pluginNode.getPluginId());
    }

    boolean result = false;

    for (final PluginNode pluginNode : pluginsToInstall) {
      if (pi != null) pi.setText(pluginNode.getName());

      try {
        result |= prepareToInstall(pluginNode, pluginIds, allPlugins);
      } catch (final IOException e) {
        SwingUtilities.invokeLater(
            new Runnable() {
              public void run() {
                Messages.showErrorDialog(
                    pluginNode.getName() + ": " + e.getMessage(),
                    CommonBundle.message("title.error"));
              }
            });
      }
    }
    return result;
  }
  @Nullable
  static String configureUpstreamRemote(
      @NotNull Project project,
      @NotNull GitRepository gitRepository,
      @NotNull ProgressIndicator indicator) {
    GithubRepoDetailed repositoryInfo = loadRepositoryInfo(project, gitRepository, indicator);
    if (repositoryInfo == null) {
      return null;
    }

    if (!repositoryInfo.isFork() || repositoryInfo.getParent() == null) {
      GithubNotifications.showWarningURL(
          project,
          CANNOT_PERFORM_GITHUB_REBASE,
          "GitHub repository ",
          "'" + repositoryInfo.getName() + "'",
          " is not a forked one",
          repositoryInfo.getHtmlUrl());
      return null;
    }

    final String parentRepoUrl =
        GithubUrlUtil.getCloneUrl(repositoryInfo.getParent().getFullPath());

    LOG.info("Adding GitHub parent as a remote host");
    indicator.setText("Adding GitHub parent as a remote host...");

    if (GithubUtil.addGithubRemote(project, gitRepository, "upstream", parentRepoUrl)) {
      return parentRepoUrl;
    } else {
      return null;
    }
  }
 private static void runIndeterminateProgress(ProgressIndicator indicator) {
   indicator.setIndeterminate(true);
   indicator.setText("Indeterminate");
   for (int i = 0; i < 200; i++) {
     TimeoutUtil.sleep(10);
     indicator.checkCanceled();
   }
 }
  private void updateUnindexedFiles(ProgressIndicator indicator) {
    PerformanceWatcher.Snapshot snapshot = PerformanceWatcher.takeSnapshot();
    PushedFilePropertiesUpdater.getInstance(myProject).pushAllPropertiesNow();
    boolean trackResponsiveness = !ApplicationManager.getApplication().isUnitTestMode();

    if (trackResponsiveness) snapshot.logResponsivenessSinceCreation("Pushing properties");

    indicator.setIndeterminate(true);
    indicator.setText(IdeBundle.message("progress.indexing.scanning"));

    myIndex.clearIndicesIfNecessary();

    CollectingContentIterator finder = myIndex.createContentIterator(indicator);
    snapshot = PerformanceWatcher.takeSnapshot();

    myIndex.iterateIndexableFilesConcurrently(finder, myProject, indicator);

    myIndex.filesUpdateEnumerationFinished();

    if (trackResponsiveness) snapshot.logResponsivenessSinceCreation("Indexable file iteration");

    List<VirtualFile> files = finder.getFiles();

    if (myOnStartup && !ApplicationManager.getApplication().isUnitTestMode()) {
      // full VFS refresh makes sense only after it's loaded, i.e. after scanning files to index is
      // finished
      ((StartupManagerImpl) StartupManager.getInstance(myProject)).scheduleInitialVfsRefresh();
    }

    if (files.isEmpty()) {
      return;
    }

    snapshot = PerformanceWatcher.takeSnapshot();

    if (trackResponsiveness)
      LOG.info("Unindexed files update started: " + files.size() + " files to update");

    indicator.setIndeterminate(false);
    indicator.setText(IdeBundle.message("progress.indexing.updating"));

    indexFiles(indicator, files);

    if (trackResponsiveness) snapshot.logResponsivenessSinceCreation("Unindexed files update");
  }
 private static void runDeterminateProgress(ProgressIndicator indicator) {
   int iterations = 3000;
   for (int i = 0; i < iterations; i++) {
     TimeoutUtil.sleep(1);
     indicator.setFraction(((double) i + 1) / ((double) iterations));
     indicator.setText(String.valueOf(i));
     ProgressManager.checkCanceled();
   }
 }
  public void findUsages(
      @NotNull final Processor<UsageInfo> consumer,
      @NotNull FindUsagesProcessPresentation processPresentation) {
    try {
      myProgress.setIndeterminate(true);
      myProgress.setText("Scanning indexed files...");
      final Set<PsiFile> filesForFastWordSearch =
          ApplicationManager.getApplication()
              .runReadAction(
                  new Computable<Set<PsiFile>>() {
                    @Override
                    public Set<PsiFile> compute() {
                      return getFilesForFastWordSearch();
                    }
                  });
      myProgress.setIndeterminate(false);

      searchInFiles(filesForFastWordSearch, processPresentation, consumer);

      myProgress.setIndeterminate(true);
      myProgress.setText("Scanning non-indexed files...");
      boolean skipIndexed = canRelyOnIndices();
      final Collection<PsiFile> otherFiles =
          collectFilesInScope(filesForFastWordSearch, skipIndexed);
      myProgress.setIndeterminate(false);

      long start = System.currentTimeMillis();
      searchInFiles(otherFiles, processPresentation, consumer);
      if (skipIndexed && otherFiles.size() > 1000) {
        logStats(otherFiles, start);
      }
    } catch (ProcessCanceledException e) {
      // fine
    }

    if (!myLargeFiles.isEmpty()) {
      processPresentation.setLargeFilesWereNotScanned(myLargeFiles);
    }

    if (!myProgress.isCanceled()) {
      myProgress.setText(FindBundle.message("find.progress.search.completed"));
    }
  }
예제 #15
0
 void displayProgress() {
   final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
   if (indicator != null) {
     indicator.setText(
         MessageFormat.format(
             "{0} {1}",
             myAction != null ? myAction : RunnerBundle.message("maven.running"),
             myParameters.getWorkingDirPath()));
     indicator.setText2(myParameters.getGoals().toString());
   }
 }
  @Nullable
  private String fetchOneFile(
      final ProgressIndicator indicator,
      final String resourceUrl,
      final Project project,
      String extResourcesPath,
      @Nullable String refname)
      throws IOException {
    SwingUtilities.invokeLater(
        () -> indicator.setText(XmlBundle.message("fetching.progress.indicator", resourceUrl)));

    FetchResult result = fetchData(project, resourceUrl, indicator);
    if (result == null) return null;

    if (!resultIsValid(project, indicator, resourceUrl, result)) {
      return null;
    }

    int slashIndex = resourceUrl.lastIndexOf('/');
    String resPath = extResourcesPath + File.separatorChar;

    if (refname != null) { // resource is known under ref.name so need to save it
      resPath += refname;
      int refNameSlashIndex = resPath.lastIndexOf('/');
      if (refNameSlashIndex != -1) {
        final File parent = new File(resPath.substring(0, refNameSlashIndex));
        if (!parent.mkdirs() || !parent.exists()) {
          LOG.warn("Unable to create: " + parent);
        }
      }
    } else {
      resPath +=
          Integer.toHexString(resourceUrl.hashCode()) + "_" + resourceUrl.substring(slashIndex + 1);
    }

    final int lastDoPosInResourceUrl = resourceUrl.lastIndexOf('.', slashIndex);
    if (lastDoPosInResourceUrl == -1
        || FileTypeManager.getInstance()
                .getFileTypeByExtension(resourceUrl.substring(lastDoPosInResourceUrl + 1))
            == FileTypes.UNKNOWN) {
      // remote url does not contain file with extension
      final String extension =
          result.contentType != null && result.contentType.contains(HTML_MIME)
              ? StdFileTypes.HTML.getDefaultExtension()
              : StdFileTypes.XML.getDefaultExtension();
      resPath += "." + extension;
    }

    File res = new File(resPath);

    FileUtil.writeToFile(res, result.bytes);
    return resPath;
  }
 private static void updateIndicator(@NotNull final String text, final double progressFraction) {
   final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
   if (indicator != null) {
     final ProgressIndicator progressIndicator = ProgressWrapper.unwrap(indicator);
     progressIndicator.setText(text);
     if (progressFraction == -1) {
       progressIndicator.setIndeterminate(true);
     } else {
       progressIndicator.setIndeterminate(false);
       progressIndicator.setFraction(progressFraction);
     }
   }
 }
  @Override
  public void create(
      @NotNull Project project,
      @NotNull BuildSystem buildSystem,
      @NotNull ProgressIndicator indicator) {
    Util.runWriteTask(
        () -> {
          try {
            indicator.setText("Writing main class");
            VirtualFile file = buildSystem.getSourceDirectories().get(0);
            final String[] files = this.mainClass.split("\\.");
            final String className = files[files.length - 1];
            final String packageName =
                this.mainClass.substring(0, this.mainClass.length() - className.length() - 1);
            file = getMainClassDirectory(files, file);

            final VirtualFile mainClassFile = file.findOrCreateChildData(this, className + ".java");
            SpongeTemplate.applyMainClassTemplate(
                project,
                mainClassFile,
                packageName,
                className,
                hasDependencies(),
                generateDocumentedListeners);

            final PsiJavaFile mainClassPsi =
                (PsiJavaFile) PsiManager.getInstance(project).findFile(mainClassFile);
            if (mainClassPsi == null) {
              return;
            }
            final PsiClass psiClass = mainClassPsi.getClasses()[0];

            writeMainSpongeClass(
                project,
                mainClassPsi,
                psiClass,
                buildSystem,
                pluginName,
                description,
                website,
                hasAuthors(),
                authors,
                hasDependencies(),
                dependencies);

            EditorHelper.openInEditor(mainClassPsi);
          } catch (IOException e) {
            e.printStackTrace();
          }
        });
  }
  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();
    }
  }
예제 #20
0
        public void run() {
          synchronized (SmoothProgressAdapter.this) {
            if (!isRunning()) {
              return;
            }

            myOriginal.start();
            myOriginalStarted = true;

            myOriginal.setText(getText());
            myOriginal.setFraction(getFraction());
            myOriginal.setText2(getText2());
          }
        }
예제 #21
0
    private void doRun() {
      myIndicator = ProgressManager.getInstance().getProgressIndicator();

      final List<Change> changesToRefresh = new ArrayList<Change>();
      try {
        ChangesUtil.processChangesByVcs(
            myProject,
            myChanges,
            new ChangesUtil.PerVcsProcessor<Change>() {
              public void process(AbstractVcs vcs, List<Change> changes) {
                final RollbackEnvironment environment = vcs.getRollbackEnvironment();
                if (environment != null) {
                  changesToRefresh.addAll(changes);

                  if (myIndicator != null) {
                    myIndicator.setText(vcs.getDisplayName() + ": performing rollback...");
                    myIndicator.setIndeterminate(false);
                    myIndicator.checkCanceled();
                  }
                  environment.rollbackChanges(
                      changes,
                      myExceptions,
                      new RollbackProgressModifier(changes.size(), myIndicator));
                  if (myIndicator != null) {
                    myIndicator.setText2("");
                    myIndicator.checkCanceled();
                  }

                  if (myExceptions.isEmpty() && myDeleteLocallyAddedFiles) {
                    deleteAddedFilesLocally(changes);
                  }
                }
              }
            });
      } catch (ProcessCanceledException e) {
        // still do refresh
      }

      if (myIndicator != null) {
        myIndicator.startNonCancelableSection();
        myIndicator.setIndeterminate(true);
        myIndicator.setText2("");
        myIndicator.setText(VcsBundle.message("progress.text.synchronizing.files"));
      }

      doRefresh(myProject, changesToRefresh);

      AbstractVcsHelper.getInstance(myProject)
          .showErrors(myExceptions, VcsBundle.message("changes.action.rollback.text"));
    }
    public void run() {
      ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
      if (progress != null) {
        progress.setText(SvnBundle.message("progress.text.loading.contents", myURL));
        progress.setText2(SvnBundle.message("progress.text2.revision.information", myRevision));
      }

      try {
        myContents =
            SvnUtil.getFileContents(
                myVCS, SvnTarget.fromURL(SvnUtil.parseUrl(myURL)), myRevision, myPegRevision);
      } catch (VcsException e) {
        myException = e;
      }
    }
  public void reportAppendableHistory(
      FilePath path, final VcsAppendableHistorySessionPartner partner) throws VcsException {
    final FilePath committedPath = ChangesUtil.getCommittedPath(myVcs.getProject(), path);

    final LogLoader logLoader;
    if (path.isNonLocal()) {
      logLoader = new RepositoryLoader(myVcs, path);
    } else {
      logLoader = new LocalLoader(myVcs, path);
    }

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

    final MyHistorySession historySession =
        new MyHistorySession(
            Collections.<VcsFileRevision>emptyList(),
            committedPath,
            Boolean.TRUE.equals(logLoader.mySupport15),
            null);

    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>() {
          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();
  }
 private static Pair<SVNRevision, SVNURL> createRemoteFolder(
     final SvnVcs17 vcs, final SVNURL parent, final String folderName) throws SVNException {
   SVNURL url = parent.appendPath(folderName, false);
   final String urlText = url.toString();
   final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
   if (indicator != null) {
     indicator.checkCanceled();
     indicator.setText(SvnBundle.message("share.directory.create.dir.progress.text", urlText));
   }
   final SVNCommitInfo info =
       vcs.createCommitClient()
           .doMkDir(
               new SVNURL[] {url},
               SvnBundle.message(
                   "share.directory.commit.message",
                   folderName,
                   ApplicationNamesInfo.getInstance().getFullProductName()));
   return new Pair<SVNRevision, SVNURL>(SVNRevision.create(info.getNewRevision()), url);
 }
  private static void addClassesUsages(
      PsiPackage aPackage,
      final Processor<UsageInfo> results,
      final JavaPackageFindUsagesOptions options) {
    ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
    if (progress != null) {
      progress.pushState();
    }

    ArrayList<PsiClass> classes = new ArrayList<PsiClass>();
    addClassesInPackage(aPackage, options.isIncludeSubpackages, classes);
    for (final PsiClass aClass : classes) {
      if (progress != null) {
        progress.setText(
            FindBundle.message(
                "find.searching.for.references.to.class.progress",
                ApplicationManager.getApplication()
                    .runReadAction(
                        new Computable<String>() {
                          @Override
                          public String compute() {
                            return aClass.getName();
                          }
                        })));
        progress.checkCanceled();
      }
      ReferencesSearch.search(
              new ReferencesSearch.SearchParameters(
                  aClass, options.searchScope, false, options.fastTrack))
          .forEach(
              new ReadActionProcessor<PsiReference>() {
                @Override
                public boolean processInReadAction(final PsiReference psiReference) {
                  return addResult(results, psiReference, options);
                }
              });
    }

    if (progress != null) {
      progress.popState();
    }
  }
  private ListenableFuture<Pair<String, GitCommandResult>> doPushCommits(
      @NotNull final GitRepository gitRepository,
      @NotNull final GitLocalBranch localBranch,
      @NotNull final GitRemote gitRemote,
      @NotNull final ProgressIndicator indicator) {
    // just set the result without going off to another thread, we should already be in a background
    // task
    SettableFuture<Pair<String, GitCommandResult>> pushResult =
        SettableFuture.<Pair<String, GitCommandResult>>create();

    indicator.setText(TfPluginBundle.message(TfPluginBundle.KEY_CREATE_PR_PUSH_TITLE));
    final Git git = ServiceManager.getService(Git.class);

    final GitRemoteBranch trackingBranch = localBranch.findTrackedBranch(gitRepository);

    final String createdBranchNameOnServer;
    final StringBuilder pushSpec = new StringBuilder(localBranch.getName());
    if (trackingBranch != null && trackingBranch.getRemote().equals(gitRemote)) {
      // if the tracking branch is on the same remote, we should update that
      pushSpec.append(":").append(trackingBranch.getNameForRemoteOperations());
      createdBranchNameOnServer = trackingBranch.getNameForRemoteOperations();
    } else {
      createdBranchNameOnServer = localBranch.getName();
    }

    final String fetchUrl = getFetchUrl(gitRemote);
    final String pushSpecStr = pushSpec.toString();
    final String gitRemoteName = gitRemote.getName();
    logger.debug("Pushing {} to {}: {}", pushSpecStr, gitRemoteName, fetchUrl);
    final GitCommandResult result =
        git.push(gitRepository, gitRemoteName, fetchUrl, pushSpecStr, true);

    if (result.success()) {
      pushResult.set(Pair.create(createdBranchNameOnServer, result));
    } else {
      final String errMsg = result.getErrorOutputAsJoinedString();
      pushResult.setException(new GitExecutionException(errMsg, null));
    }

    return pushResult;
  }
  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;
  }
예제 #28
0
  @NotNull
  private File copyToMirror(@NotNull File original, @NotNull File mirror) {
    ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
    if (progress != null) {
      progress.pushState();
      progress.setText(VfsBundle.message("jar.copy.progress", original.getPath()));
      progress.setFraction(0);
    }

    try {
      FileUtil.copy(original, mirror);
    } catch (final IOException e) {
      reportIOErrorWithJars(original, mirror, e);
      return original;
    }

    if (progress != null) {
      progress.popState();
    }

    return mirror;
  }
  private static ISVNPropertyHandler createHandler(
      SVNRevision revision, final List<SVNPropertyData> lines) {
    final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
    if (indicator != null) {
      indicator.checkCanceled();
      indicator.setText(
          SvnBundle.message(
              "show.properties.diff.progress.text.revision.information", revision.toString()));
    }

    return new ISVNPropertyHandler() {
      public void handleProperty(final File path, final SVNPropertyData property)
          throws SVNException {
        if (indicator != null) {
          indicator.checkCanceled();
          indicator.setText2(
              SvnBundle.message(
                  "show.properties.diff.progress.text2.property.information", property.getName()));
        }
        lines.add(property);
      }

      public void handleProperty(final SVNURL url, final SVNPropertyData property)
          throws SVNException {
        if (indicator != null) {
          indicator.checkCanceled();
          indicator.setText2(
              SvnBundle.message(
                  "show.properties.diff.progress.text2.property.information", property.getName()));
        }
        lines.add(property);
      }

      public void handleProperty(final long revision, final SVNPropertyData property)
          throws SVNException {
        // revision properties here
      }
    };
  }
예제 #30
0
  @NotNull
  public static DataPack build(
      @NotNull List<? extends VcsCommit> commits,
      @NotNull Collection<VcsRef> allRefs,
      @NotNull ProgressIndicator indicator) {
    indicator.setText("Building graph...");

    MutableGraph graph = GraphBuilder.build(commits, allRefs);

    GraphModel graphModel = new GraphModelImpl(graph, allRefs);

    final GraphPrintCellModel printCellModel = new GraphPrintCellModelImpl(graphModel.getGraph());
    graphModel.addUpdateListener(
        new Consumer<UpdateRequest>() {
          @Override
          public void consume(UpdateRequest key) {
            printCellModel.recalculate(key);
          }
        });

    final RefsModel refsModel = new RefsModel(allRefs);
    graphModel
        .getFragmentManager()
        .setUnconcealedNodeFunction(
            new Function<Node, Boolean>() {
              @NotNull
              @Override
              public Boolean fun(@NotNull Node key) {
                if (key.getDownEdges().isEmpty()
                    || key.getUpEdges().isEmpty()
                    || refsModel.isBranchRef(key.getCommitHash())) {
                  return true;
                } else {
                  return false;
                }
              }
            });
    return new DataPack(graphModel, refsModel, printCellModel);
  }