Package org.eclipse.egit.core.project

Examples of org.eclipse.egit.core.project.RepositoryMapping


    if ("isContainer".equals(property)) { //$NON-NLS-1$
      int type = res.getType();
      return type == IResource.FOLDER || type == IResource.PROJECT;
    }

    RepositoryMapping mapping = RepositoryMapping.getMapping(res
        .getProject());
    if (mapping != null) {
      Repository repository = mapping.getRepository();
      return testRepositoryState(repository, property);
    }
    return false;
  }
View Full Code Here


  private void assumeValid(final IResource resource) throws CoreException {
    final IProject proj = resource.getProject();
    final GitProjectData pd = GitProjectData.get(proj);
    if (pd == null)
      return;
    final RepositoryMapping rm = pd.getRepositoryMapping(resource);
    if (rm == null)
      return;
    final Repository db = rm.getRepository();

    DirCache cache = caches.get(db);
    if (cache == null) {
      try {
        cache = db.lockDirCache();
      } catch (IOException err) {
        throw new CoreException(Activator.error(CoreText.UntrackOperation_failed, err));
      }
      caches.put(db, cache);
      mappings.put(rm, rm);
    }

    final String path = rm.getRepoRelativePath(resource);
    if (resource instanceof IContainer) {
      for (final DirCacheEntry ent : cache.getEntriesWithin(path))
        ent.setAssumeValid(assumeUnchanged);
    } else {
      final DirCacheEntry ent = cache.getEntry(path);
View Full Code Here

                throws CoreException {
              final IResource resource = delta.getResource();
              IProject project = resource.getProject();
              if (project == null)
                return true;
              RepositoryMapping mapping = RepositoryMapping
                  .getMapping(resource);
              if (mapping == null)
                return true;
              if (mapping.getRepository() != repository)
                return false;
              GitResourceDeltaVisitor visitor = new GitResourceDeltaVisitor(
                  repository);
              try {
                event.getDelta().accept(visitor);
              } catch (CoreException e) {
                String msg = "Exception during accept of GitResourceDeltaVisitor for resource delta";
                throw new RuntimeException(msg, e);
              }
              IPath gitDirAbsolutePath = mapping
                  .getGitDirAbsolutePath();
              for (IResource res : visitor.getResourcesToUpdate()) {
                if (ignoreTeamPrivateMember
                    && (res.isTeamPrivateMember() || gitDirAbsolutePath
                        .isPrefixOf(res
View Full Code Here

      f.setFindInChildren(false);
      Collection<RepositoryMapping> mappings = f.find(new NullProgressMonitor());
      if (mappings.size() != 1)
        return false;

      RepositoryMapping m = mappings.iterator().next();
      IPath gitDirPath = m.getGitDirAbsolutePath();
      if (gitDirPath.segmentCount() == 0)
        return false;

      IPath workingDir = gitDirPath.removeLastSegments(1);
      // Don't connect "/" or "C:\"
View Full Code Here

   * @param path
   * @param project
   * @return path
   */
  public static IPath computeWorkspacePath(final IPath path, final IProject project) {
    RepositoryMapping rm = RepositoryMapping.getMapping(project);
    String repoRelativePath = rm.getRepoRelativePath(project);
    // the relative path cannot be determined, return unchanged
    if (repoRelativePath == null)
      return path;
    // repository and project at the same level
    if (repoRelativePath.equals("")) //$NON-NLS-1$
View Full Code Here

    final boolean force = (updateFlags & IResource.FORCE) == IResource.FORCE;
    if (!force && !tree.isSynchronized(file, IResource.DEPTH_ZERO))
      return false;

    final RepositoryMapping map = RepositoryMapping.getMapping(file);
    if (map == null)
      return false;

    String repoRelativePath = map.getRepoRelativePath(file);
    IndexDiffCache indexDiffCache = Activator.getDefault()
        .getIndexDiffCache();
    IndexDiffCacheEntry indexDiffCacheEntry = indexDiffCache
        .getIndexDiffCacheEntry(map.getRepository());
    IndexDiffData indexDiff = indexDiffCacheEntry.getIndexDiff();
    if (indexDiff != null) {
      if (indexDiff.getUntracked().contains(repoRelativePath))
        return false;
      if (indexDiff.getIgnoredNotInIndex().contains(repoRelativePath))
        return false;
    }
    if (!file.exists())
      return false;
    if (file.isDerived())
      return false;

    DirCache dirc = null;
    try {
      dirc = map.getRepository().lockDirCache();
      final int first = dirc.findEntry(repoRelativePath);
      if (first < 0) {
        dirc.unlock();
        return false;
      }
View Full Code Here

      final IProgressMonitor monitor) {
    final boolean force = (updateFlags & IResource.FORCE) == IResource.FORCE;
    if (!force && !tree.isSynchronized(srcf, IResource.DEPTH_ZERO))
      return false;

    final RepositoryMapping srcm = RepositoryMapping.getMapping(srcf);
    if (srcm == null)
      return false;
    final RepositoryMapping dstm = RepositoryMapping.getMapping(dstf);

    DirCache sCache = null;
    try {
      sCache = srcm.getRepository().lockDirCache();
      final String sPath = srcm.getRepoRelativePath(srcf);
      final DirCacheEntry sEnt = sCache.getEntry(sPath);
      if (sEnt == null)
        return FINISH_FOR_ME;

      if (!sEnt.isMerged()) {
        tree.failed(new Status(IStatus.WARNING, Activator.getPluginId(),
            CoreText.MoveDeleteHook_unmergedFileError));
        return I_AM_DONE;
      }

      final DirCacheEditor sEdit = sCache.editor();
      sEdit.add(new DirCacheEditor.DeletePath(sEnt));
      if (dstm != null && dstm.getRepository() == srcm.getRepository()) {
        final String dPath = srcm.getRepoRelativePath(dstf);
        sEdit.add(new DirCacheEditor.PathEdit(dPath) {
          @Override
          public void apply(final DirCacheEntry dEnt) {
            dEnt.copyMetaData(sEnt);
View Full Code Here

      final IProgressMonitor monitor) {
    final boolean force = (updateFlags & IResource.FORCE) == IResource.FORCE;
    if (!force && !tree.isSynchronized(srcf, IResource.DEPTH_ZERO))
      return false;

    final RepositoryMapping srcm = RepositoryMapping.getMapping(srcf);
    if (srcm == null)
      return false;
    final RepositoryMapping dstm = RepositoryMapping.getMapping(dstf);

    try {
      final String sPath = srcm.getRepoRelativePath(srcf);
      if (dstm != null && dstm.getRepository() == srcm.getRepository()) {
        final String dPath =
          srcm.getRepoRelativePath(dstf) + "/"; //$NON-NLS-1$
        MoveResult result = moveIndexContent(dPath, srcm, sPath);
        switch (result) {
        case SUCCESS:
View Full Code Here

      final IProgressMonitor monitor, IPath gitDir) throws CoreException,
      TeamException {
    IProject destination = source.getWorkspace().getRoot()
        .getProject(description.getName());
    GitProjectData projectData = new GitProjectData(destination);
    RepositoryMapping repositoryMapping = new RepositoryMapping(
        destination, gitDir.toFile());
    projectData.setRepositoryMappings(Arrays
        .asList(repositoryMapping));
    projectData.store();
    GitProjectData.add(destination, projectData);
View Full Code Here

  }

  public boolean moveProject(final IResourceTree tree, final IProject source,
      final IProjectDescription description, final int updateFlags,
      final IProgressMonitor monitor) {
    final RepositoryMapping srcm = RepositoryMapping.getMapping(source);
    if (srcm == null)
      return false;
    IPath newLocation = null;
    if (description.getLocationURI() != null)
      newLocation = URIUtil.toPath(description.getLocationURI());
    else
      newLocation = source.getWorkspace().getRoot().getLocation()
          .append(description.getName());
    IPath sourceLocation = source.getLocation();
    // Prevent a serious error.
    if (sourceLocation.isPrefixOf(newLocation)
        && sourceLocation.segmentCount() != newLocation.segmentCount()
        && !"true".equals(System.getProperty("egit.assume_307140_fixed"))) { //$NON-NLS-1$//$NON-NLS-2$
      // Graceful handling of bug, i.e. refuse to destroy your code
      tree.failed(new Status(
          IStatus.ERROR,
          Activator.getPluginId(),
          0,
          "Cannot move project. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=307140 (not resolved in 3.7)", //$NON-NLS-1$
          null));
      return true;
    }
    File newLocationFile = newLocation.toFile();
    // check if new location is below the same repository
    Path workTree = new Path(srcm.getRepository().getWorkTree().getAbsolutePath());
    int matchingFirstSegments = workTree.matchingFirstSegments(newLocation);
    if (matchingFirstSegments == workTree.segmentCount()) {
      return moveProjectHelperMoveOnlyProject(tree, source, description, updateFlags,
          monitor, srcm, newLocationFile);
    } else {
View Full Code Here

TOP

Related Classes of org.eclipse.egit.core.project.RepositoryMapping

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.