use of org.eclipse.egit.core.project.RepositoryMapping in project egit by eclipse.
the class UntrackOperation method remove.
private void remove(final IResource resource) throws CoreException {
final IProject proj = resource.getProject();
if (proj == null) {
return;
}
final GitProjectData pd = GitProjectData.get(proj);
if (pd == null) {
return;
}
final RepositoryMapping rm = pd.getRepositoryMapping(resource);
if (rm == null) {
return;
}
db = rm.getRepository();
remove(resource.getLocation());
}
use of org.eclipse.egit.core.project.RepositoryMapping in project egit by eclipse.
the class RuleUtil method getRuleForRepositories.
/**
* Calculates a {@link ISchedulingRule} for all repositories related to the
* given resources.
*
* @see RuleUtil#getRule(Repository)
* @param resources
* @return scheduling rule
*/
public static ISchedulingRule getRuleForRepositories(IResource[] resources) {
ISchedulingRule result = null;
Set<Repository> repositories = new HashSet<Repository>();
for (IResource resource : resources) {
RepositoryMapping mapping = RepositoryMapping.getMapping(resource);
if (mapping != null)
repositories.add(mapping.getRepository());
}
for (Repository repository : repositories) {
ISchedulingRule rule = getRule(repository);
result = MultiRule.combine(result, rule);
}
return result;
}
use of org.eclipse.egit.core.project.RepositoryMapping in project egit by eclipse.
the class DisconnectConnectTest method testDisconnectAndReconnect.
@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);
TestUtil.waitForJobs(500, 5000);
mapping = RepositoryMapping.getMapping(project);
assertNull(mapping);
SWTBotShell connectDialog = openConnectDialog();
// test the "share with repository in parent folder" scenario
connectDialog.bot().checkBox(UIText.ExistingOrNewPage_InternalModeCheckbox).select();
connectDialog.bot().tree().getAllItems()[0].select();
connectDialog.bot().button(IDialogConstants.FINISH_LABEL).click();
bot.waitUntil(Conditions.shellCloses(connectDialog));
ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, null);
TestUtil.waitForJobs(500, 5000);
mapping = RepositoryMapping.getMapping(project);
if (mapping == null) {
TestUtil.waitForJobs(500, 5000);
}
assertNotNull(mapping);
}
use of org.eclipse.egit.core.project.RepositoryMapping in project egit by eclipse.
the class DisconnectConnectTest method testDecorations.
@Test
public void testDecorations() throws Exception {
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJ1);
RepositoryMapping mapping = RepositoryMapping.getMapping(project);
assertNotNull(mapping);
SWTBotTree projectExplorerTree = TestUtil.getExplorerTree();
TestUtil.navigateTo(projectExplorerTree, new Path(FILE1_PATH).segments());
touch("File modified");
clickOnDisconnect();
TestUtil.waitForJobs(500, 5000);
TestUtil.joinJobs(JobFamilies.INDEX_DIFF_CACHE_UPDATE);
TestUtil.waitForDecorations();
assertFalse("Project should not have git decorations", getProjectItem(projectExplorerTree, PROJ1).getText().contains("["));
SWTBotShell connectDialog = openConnectDialog();
connectDialog.bot().button(IDialogConstants.FINISH_LABEL).click();
bot.waitUntil(Conditions.shellCloses(connectDialog));
TestUtil.waitForJobs(500, 5000);
TestUtil.joinJobs(JobFamilies.INDEX_DIFF_CACHE_UPDATE);
TestUtil.waitForDecorations();
assertTrue("Project should have git decorations", getProjectItem(projectExplorerTree, PROJ1).getText().contains("[FirstRepository"));
SWTBotTreeItem fileNode = TestUtil.navigateTo(projectExplorerTree, new Path(FILE1_PATH).segments());
assertTrue("File should have git decorations", fileNode.getText().startsWith(">"));
}
use of org.eclipse.egit.core.project.RepositoryMapping in project egit by eclipse.
the class CompareUtils method compareHeadWithWorkspace.
/**
* Opens a compare editor. The workspace version of the given file is
* compared with the version in the HEAD commit.
*
* @param repository
* @param file
*/
public static void compareHeadWithWorkspace(Repository repository, @NonNull IFile file) {
RepositoryMapping mapping = RepositoryMapping.getMapping(file);
if (mapping == null) {
Activator.error(NLS.bind(UIText.GitHistoryPage_errorLookingUpPath, file.getLocation(), repository), null);
return;
}
String path = mapping.getRepoRelativePath(file);
ITypedElement base = getHeadTypedElement(repository, path);
if (base == null)
return;
IFileRevision nextFile = new WorkspaceFileRevision(file);
String encoding = null;
try {
encoding = file.getCharset();
} catch (CoreException e) {
Activator.handleError(UIText.CompareUtils_errorGettingEncoding, e, true);
}
ITypedElement next = new FileRevisionTypedElement(nextFile, encoding);
GitCompareFileRevisionEditorInput input = new GitCompareFileRevisionEditorInput(next, base, null);
CompareUI.openCompareDialog(input);
}
Aggregations