private void logAndUnmapGoneMappedResource(final RepositoryMapping m) { Activator.logError( MessageFormat.format(CoreText.GitProjectData_mappedResourceGone, m.toString()), new FileNotFoundException(m.getContainerPath().toString())); m.clear(); UnmapJob unmapJob = new UnmapJob(getProject()); unmapJob.schedule(); }
private void map(final RepositoryMapping m) { final IResource r; final File git; final IResource dotGit; IContainer c = null; m.clear(); r = getProject().findMember(m.getContainerPath()); if (r instanceof IContainer) { c = (IContainer) r; } else if (r != null) { c = Utils.getAdapter(r, IContainer.class); } if (c == null) { logAndUnmapGoneMappedResource(m); return; } m.setContainer(c); IPath absolutePath = m.getGitDirAbsolutePath(); if (absolutePath == null) { logAndUnmapGoneMappedResource(m); return; } git = absolutePath.toFile(); if (!git.isDirectory() || !new File(git, "config").isFile()) { // $NON-NLS-1$ logAndUnmapGoneMappedResource(m); return; } try { m.setRepository(Activator.getDefault().getRepositoryCache().lookupRepository(git)); } catch (IOException ioe) { logAndUnmapGoneMappedResource(m); return; } m.fireRepositoryChanged(); trace( "map " //$NON-NLS-1$ + c + " -> " //$NON-NLS-1$ + m.getRepository()); try { c.setSessionProperty(MAPPING_KEY, m); } catch (CoreException err) { Activator.logError(CoreText.GitProjectData_failedToCacheRepoMapping, err); } dotGit = c.findMember(Constants.DOT_GIT); if (dotGit != null && dotGit.getLocation().toFile().equals(git)) { protect(dotGit); } }