Exemplo n.º 1
0
  /**
   * Replace the old repository location with the new one assuming that they are the same location
   * with different authentication informations
   *
   * @param location
   * @param newLocation
   */
  public void replaceRepositoryLocation(
      final ICVSRepositoryLocation oldLocation, final CVSRepositoryLocation newLocation) {

    try {
      run(
          new IRunnableWithProgress() {
            public void run(IProgressMonitor monitor)
                throws InvocationTargetException, InterruptedException {
              RepositoryRoot root = getRepositoryRootFor(oldLocation);
              // Disposing of the old location will result in the deletion of the
              // cached root through a listener callback
              KnownRepositories.getInstance().disposeRepository(oldLocation);

              // Get the new location from the CVS plugin to ensure we use the
              // instance that will be returned by future calls to getRepository()
              boolean isNew =
                  !KnownRepositories.getInstance().isKnownRepository(newLocation.getLocation());
              root.setRepositoryLocation(
                  KnownRepositories.getInstance()
                      .addRepository(newLocation, isNew /* broadcast */));
              add(root);
            }
          },
          Policy.monitorFor(null));
    } catch (InvocationTargetException e) {
      CVSException.wrapException(e);
    } catch (InterruptedException e) {
    }
  }
 /**
  * Ensure that the sync info for all the provided resources has been loaded. If an out-of-sync
  * resource is found, prompt to refresh all the projects involved.
  */
 protected boolean ensureSyncInfoLoaded(IResource[] resources) throws CVSException {
   boolean keepTrying = true;
   while (keepTrying) {
     try {
       EclipseSynchronizer.getInstance().ensureSyncInfoLoaded(resources, getActionDepth());
       keepTrying = false;
     } catch (CVSException e) {
       if (e.getStatus().getCode() == IResourceStatus.OUT_OF_SYNC_LOCAL) {
         // determine the projects of the resources involved
         Set projects = new HashSet();
         for (int i = 0; i < resources.length; i++) {
           IResource resource = resources[i];
           projects.add(resource.getProject());
         }
         // prompt to refresh
         if (promptToRefresh(
             getShell(),
             (IResource[]) projects.toArray(new IResource[projects.size()]),
             e.getStatus())) {
           for (Iterator iter = projects.iterator(); iter.hasNext(); ) {
             IProject project = (IProject) iter.next();
             try {
               project.refreshLocal(IResource.DEPTH_INFINITE, null);
             } catch (CoreException coreException) {
               throw CVSException.wrapException(coreException);
             }
           }
         } else {
           return false;
         }
       } else {
         throw e;
       }
     }
   }
   return true;
 }