Package org.eclipse.egit.core.project

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


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

    DirCacheEditor e = edits.get(db);
    if (e == null) {
      try {
        e = db.lockDirCache().editor();
      } catch (IOException err) {
        throw new CoreException(Activator.error(CoreText.UntrackOperation_failed, err));
      }
      edits.put(db, e);
      mappings.put(rm, rm);
    }

    if (path instanceof IContainer)
      e.add(new DirCacheEditor.DeleteTree(rm.getRepoRelativePath(path)));
    else
      e.add(new DirCacheEditor.DeletePath(rm.getRepoRelativePath(path)));
  }
View Full Code Here


  @Test
  public void testDisconnectAndReconnect() throws Exception {
    IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(
        PROJ1);
    RepositoryMapping mapping = RepositoryMapping.getMapping(project);
    assertNotNull(mapping);
    clickOnDisconnect();
    ResourcesPlugin.getWorkspace().getRoot().refreshLocal(
        IResource.DEPTH_INFINITE, null);
    waitInUI();
View Full Code Here

  @SuppressWarnings("boxing")
  private void assertTrackedState(IFile[] fileArr, boolean expectedState)
      throws IOException {
    DirCache cache = repository1.getRepository().readDirCache();
    for (IFile file : fileArr) {
      RepositoryMapping rm = RepositoryMapping.getMapping(file);
      String fileDir = rm.getRepoRelativePath(file);
      boolean tracked = cache.findEntry(fileDir) > -1;
      assertEquals("Wrong tracking state", expectedState, tracked);
    }
  }
View Full Code Here

  private void erase(String projectName, Set<File> dirs) throws CoreException, IOException {
    IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(
        projectName);
    if (project.exists()) {
      RepositoryMapping repo = RepositoryMapping.getMapping(project);
      if (repo != null) {
        IPath gitDirAbsolutePath = repo.getGitDirAbsolutePath();
        File canonicalFile = gitDirAbsolutePath.toFile().getCanonicalFile();
        dirs.add(canonicalFile);
        File workspacePath = ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile().getCanonicalFile();
        File gitDirParent = canonicalFile.getParentFile();
        if (!(gitDirParent.toString() + File.separator)
View Full Code Here

    Set<Repository> repositories = new HashSet<Repository>(projects.length);

    // we could use DecoratableResourceAdapter for each project, but that would be too much overhead,
    // as we need only very little information at all...
    for(IProject prj : projects) {
      RepositoryMapping repoMapping = RepositoryMapping.getMapping(prj);
      if(repoMapping == null)
        continue;

      IndexDiffData diffData = GitLightweightDecorator.getIndexDiffDataOrNull(prj);
      if(diffData == null)
        continue;

      // at least one contained resource is tracked for sure here.
      tracked = true;

      Repository repository = repoMapping.getRepository();
      String repoRelative = makeRepoRelative(repository, prj) + "/"; //$NON-NLS-1$

      Set<String> modified = diffData.getModified();
      Set<String> conflicting = diffData.getConflicting();
View Full Code Here

    // Don't decorate non-existing resources
    if (!resource.exists() && !resource.isPhantom())
      return null;

    // Make sure we're dealing with a project under Git revision control
    final RepositoryMapping mapping = RepositoryMapping
        .getMapping(resource);
    if (mapping == null)
      return null;

    // Cannot decorate linked resources
    if (mapping.getRepoRelativePath(resource) == null)
      return null;

    IndexDiffData indexDiffData = org.eclipse.egit.core.Activator
        .getDefault().getIndexDiffCache()
        .getIndexDiffCacheEntry(mapping.getRepository()).getIndexDiff();

    return indexDiffData;
  }
View Full Code Here

    boolean errorOccurred = false;
    List<ObjectId> ids = new ArrayList<ObjectId>();
    String gitPath = null;
    if (input instanceof IFile) {
      IFile resource = (IFile) input;
      final RepositoryMapping map = RepositoryMapping
          .getMapping(resource);
      gitPath = map.getRepoRelativePath(resource);
      Iterator<?> it = selection.iterator();
      while (it.hasNext()) {
        RevCommit commit = (RevCommit) it.next();
        String commitPath = getRenamedPath(gitPath, commit);
        IFileRevision rev = null;
        try {
          rev = CompareUtils.getFileRevision(commitPath, commit,
              map.getRepository(), null);
        } catch (IOException e) {
          Activator.logError(NLS.bind(
              UIText.GitHistoryPage_errorLookingUpPath, gitPath,
              commit.getId()), e);
          errorOccurred = true;
        }
        if (rev != null) {
          if (compareMode) {
            ITypedElement right = CompareUtils
                .getFileRevisionTypedElement(commitPath,
                    commit, map.getRepository());
            final GitCompareFileRevisionEditorInput in = new GitCompareFileRevisionEditorInput(
                SaveableCompareEditorInput
                    .createFileElement(resource), right,
                null);
            try {
View Full Code Here

      return;

    TreeWalk tw = null;
    RevWalk rw = null;
    try {
      RepositoryMapping mapping = RepositoryMapping.getMapping(resource);
      if (mapping == null) {
        setResolved(null, null, null, ""); //$NON-NLS-1$
        return;
      }
      final String gitPath = mapping.getRepoRelativePath(resource);
      if (gitPath == null) {
        setResolved(null, null, null, ""); //$NON-NLS-1$
        return;
      }
      final Repository repository = mapping.getRepository();
      String baseline = GitQuickDiffProvider.baseline.get(repository);
      if (baseline == null)
        baseline = Constants.HEAD;
      ObjectId commitId = repository.resolve(baseline);
      if (commitId != null) {
View Full Code Here

    if (reloadJob != null && reloadJob.getState() != Job.NONE)
      reloadJob.cancel();
  }

  private Repository getRepository() {
    RepositoryMapping mapping = RepositoryMapping.getMapping(resource);
    return (mapping != null) ? mapping.getRepository() : null;
  }
View Full Code Here

   */
  public static Map<Repository, Collection<String>> splitResourcesByRepository(
      Collection<IResource> resources) {
    Map<Repository, Collection<String>> result = new HashMap<Repository, Collection<String>>();
    for (IResource resource : resources) {
      RepositoryMapping repositoryMapping = RepositoryMapping
          .getMapping(resource);
      if (repositoryMapping == null)
        continue;
      String path = repositoryMapping.getRepoRelativePath(resource);
      addPathToMap(repositoryMapping.getRepository(), path, result);
    }
    return result;
  }
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.