Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn O. Pearce2010-07-26 19:27:03 -0400
committerShawn O. Pearce2010-07-27 11:41:44 -0400
commit7a832d965464e56c96ea9b67abb205e2253d8e4c (patch)
treef39d26d7ce0be61c55d4809b6771aae8f805ba17 /org.eclipse.egit.core.test
parent6e34f6838a7c249969025a16ad631b817c92143d (diff)
downloadegit-7a832d965464e56c96ea9b67abb205e2253d8e4c.tar.gz
egit-7a832d965464e56c96ea9b67abb205e2253d8e4c.tar.xz
egit-7a832d965464e56c96ea9b67abb205e2253d8e4c.zip
Update to latest JGit API
* Change to use FileRepository throughout most of EGit. Too much of the code currently has assumptions about the repository being on the local filesystem, accessible by java.io.File. Use the file specific repository type to better describe the dependency. * Replace getWorkDir() with getWorkTree() * Replace openObject(), openBlob(), hasObject() with the newer short style open() and has(). * Always treat blobs as InputStreams when possible. This ensures that even on very large files, EGit won't explode the JVM heap and cause an OutOfMemoryError. * Adapted to the new style RepositoryListener interfaces, which promises better long-term API stability. * Replace static DirCache read() and lock() with Repository instance methods, further hiding the storage method of the working directory's index. Change-Id: I2459757a26f8c724b95468f9f38bac2ee172a932 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'org.eclipse.egit.core.test')
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/internal/storage/BlobStorageTest.java3
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantComparatorTest.java3
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantTreeTest.java3
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitSyncInfoTest.java3
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/AdaptableFileTreeIteratorTest.java5
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/DualRepositoryTestCase.java2
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/TestRepository.java19
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/internal/mapping/HistoryTest.java5
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/ConnectProviderOperationTest.java5
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/ListRemoteOperationTest.java4
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/PushOperationTest.java6
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/TrackUntrackOperationTest.java2
12 files changed, 34 insertions, 26 deletions
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/internal/storage/BlobStorageTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/internal/storage/BlobStorageTest.java
index 7b59fb3fe..83c699592 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/internal/storage/BlobStorageTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/internal/storage/BlobStorageTest.java
@@ -16,6 +16,7 @@ import org.eclipse.core.runtime.Path;
import org.eclipse.egit.core.test.GitTestCase;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.storage.file.FileRepository;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -27,7 +28,7 @@ public class BlobStorageTest extends GitTestCase {
@Before
public void setUp() throws Exception {
super.setUp();
- repository = new Repository(gitDir);
+ repository = new FileRepository(gitDir);
repository.create();
}
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantComparatorTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantComparatorTest.java
index 9b9db5e5e..7c9de9015 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantComparatorTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantComparatorTest.java
@@ -33,6 +33,7 @@ import org.eclipse.egit.core.synchronize.dto.GitSynchronizeDataSet;
import org.eclipse.egit.core.test.GitTestCase;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.storage.file.FileRepository;
import org.eclipse.team.core.variants.IResourceVariant;
import org.junit.After;
import org.junit.Before;
@@ -48,7 +49,7 @@ public class GitResourceVariantComparatorTest extends GitTestCase {
IProject iProject = project.project;
if (!gitDir.exists())
- new Repository(gitDir).create();
+ new FileRepository(gitDir).create();
new ConnectProviderOperation(iProject, gitDir).execute(null);
repo = RepositoryMapping.getMapping(iProject).getRepository();
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantTreeTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantTreeTest.java
index 68e18ad0a..6ead88687 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantTreeTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantTreeTest.java
@@ -42,6 +42,7 @@ import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.RefUpdate;
import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.storage.file.FileRepository;
import org.eclipse.team.core.variants.IResourceVariant;
import org.eclipse.team.core.variants.ResourceVariantByteStore;
import org.eclipse.team.core.variants.SessionResourceVariantByteStore;
@@ -60,7 +61,7 @@ public class GitResourceVariantTreeTest extends GitTestCase {
public void createGitRepository() throws Exception {
IProject iProject = project.project;
if (!gitDir.exists())
- new Repository(gitDir).create();
+ new FileRepository(gitDir).create();
new ConnectProviderOperation(iProject, gitDir).execute(null);
repo = RepositoryMapping.getMapping(iProject).getRepository();
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitSyncInfoTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitSyncInfoTest.java
index 93de88354..22f858857 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitSyncInfoTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitSyncInfoTest.java
@@ -43,6 +43,7 @@ import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.GitIndex.Entry;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevCommitList;
+import org.eclipse.jgit.storage.file.FileRepository;
import org.junit.Before;
import org.junit.Test;
@@ -57,7 +58,7 @@ public class GitSyncInfoTest extends GitTestCase {
super.setUp();
IProject iProject = project.project;
if (!gitDir.exists())
- new Repository(gitDir).create();
+ new FileRepository(gitDir).create();
new ConnectProviderOperation(iProject, gitDir).execute(null);
repo = RepositoryMapping.getMapping(iProject).getRepository();
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/AdaptableFileTreeIteratorTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/AdaptableFileTreeIteratorTest.java
index a43d248aa..1ac5b6b53 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/AdaptableFileTreeIteratorTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/AdaptableFileTreeIteratorTest.java
@@ -23,6 +23,7 @@ import org.eclipse.egit.core.ContainerTreeIterator;
import org.eclipse.egit.core.op.ConnectProviderOperation;
import org.eclipse.egit.core.project.RepositoryMapping;
import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.storage.file.FileRepository;
import org.eclipse.jgit.treewalk.TreeWalk;
import org.eclipse.jgit.treewalk.WorkingTreeIterator;
import org.eclipse.jgit.treewalk.filter.PathFilterGroup;
@@ -41,8 +42,8 @@ public class AdaptableFileTreeIteratorTest extends GitTestCase {
public void setUp() throws Exception {
super.setUp();
- repository = new Repository(gitDir);
- repositoryRoot = repository.getWorkDir();
+ repository = new FileRepository(gitDir);
+ repositoryRoot = repository.getWorkTree();
repository.create();
file = new File(project.getProject().getLocation().toFile(), "a.txt");
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/DualRepositoryTestCase.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/DualRepositoryTestCase.java
index d53c527a7..73f32ee4e 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/DualRepositoryTestCase.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/DualRepositoryTestCase.java
@@ -34,7 +34,7 @@ public abstract class DualRepositoryTestCase {
firstProject.delete(false, null);
IProjectDescription desc = ResourcesPlugin.getWorkspace()
.newProjectDescription(projectName);
- File parentFile = repo.getRepository().getWorkDir();
+ File parentFile = repo.getRepository().getWorkTree();
desc.setLocation(new Path(new File(parentFile, projectName).getPath()));
firstProject.create(desc, null);
firstProject.open(null);
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/TestRepository.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/TestRepository.java
index 6ab42936b..f81713d2a 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/TestRepository.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/TestRepository.java
@@ -34,6 +34,7 @@ import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.Tree;
import org.eclipse.jgit.lib.GitIndex.Entry;
import org.eclipse.jgit.revwalk.RevCommit;
+import org.eclipse.jgit.storage.file.FileRepository;
/**
* Helper class for creating and filling a test repository
@@ -51,12 +52,12 @@ public class TestRepository {
* @throws IOException
*/
public TestRepository(File gitDir) throws IOException {
- repository = new Repository(gitDir);
+ repository = new FileRepository(gitDir);
repository.create();
try {
- workdirPrefix = repository.getWorkDir().getCanonicalPath();
+ workdirPrefix = repository.getWorkTree().getCanonicalPath();
} catch (IOException err) {
- workdirPrefix = repository.getWorkDir().getAbsolutePath();
+ workdirPrefix = repository.getWorkTree().getAbsolutePath();
}
workdirPrefix = workdirPrefix.replace('\\', '/');
if (!workdirPrefix.endsWith("/")) //$NON-NLS-1$
@@ -71,9 +72,9 @@ public class TestRepository {
public TestRepository(Repository repository) throws IOException {
this.repository = repository;
try {
- workdirPrefix = repository.getWorkDir().getCanonicalPath();
+ workdirPrefix = repository.getWorkTree().getCanonicalPath();
} catch (IOException err) {
- workdirPrefix = repository.getWorkDir().getAbsolutePath();
+ workdirPrefix = repository.getWorkTree().getAbsolutePath();
}
workdirPrefix = workdirPrefix.replace('\\', '/');
if (!workdirPrefix.endsWith("/")) //$NON-NLS-1$
@@ -103,7 +104,7 @@ public class TestRepository {
public RevCommit createInitialCommit(String message) throws IOException,
NoHeadException, NoMessageException, ConcurrentRefUpdateException,
JGitInternalException, WrongRepositoryStateException {
- String repoPath = repository.getWorkDir().getAbsolutePath();
+ String repoPath = repository.getWorkTree().getAbsolutePath();
File file = new File(repoPath, "dummy");
file.createNewFile();
track(file);
@@ -144,7 +145,7 @@ public class TestRepository {
*/
public void track(File file) throws IOException {
GitIndex index = repository.getIndex();
- Entry entry = index.add(repository.getWorkDir(), file);
+ Entry entry = index.add(repository.getWorkTree(), file);
entry.setAssumeValid(false);
index.write();
}
@@ -184,8 +185,8 @@ public class TestRepository {
GitIndex index = repository.getIndex();
Entry entry = index.getEntry(getRepoRelativePath(file.getLocation().toOSString()));
assertNotNull(entry);
- if (entry.isModified(repository.getWorkDir()))
- entry.update(new File(repository.getWorkDir(), entry.getName()));
+ if (entry.isModified(repository.getWorkTree()))
+ entry.update(new File(repository.getWorkTree(), entry.getName()));
index.write();
}
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/internal/mapping/HistoryTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/internal/mapping/HistoryTest.java
index 28c0217d0..f5a08929e 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/internal/mapping/HistoryTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/internal/mapping/HistoryTest.java
@@ -32,6 +32,7 @@ import org.eclipse.jgit.lib.PersonIdent;
import org.eclipse.jgit.lib.RefUpdate;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.Tree;
+import org.eclipse.jgit.storage.file.FileRepository;
import org.eclipse.team.core.RepositoryProvider;
import org.eclipse.team.core.history.IFileHistory;
import org.eclipse.team.core.history.IFileHistoryProvider;
@@ -63,8 +64,8 @@ public class HistoryTest extends GitTestCase {
project.createSourceFolder();
gitDir = new File(project.getProject().getWorkspace().getRoot()
.getRawLocation().toFile(), Constants.DOT_GIT);
- thisGit = new Repository(gitDir);
- workDir = thisGit.getWorkDir();
+ thisGit = new FileRepository(gitDir);
+ workDir = thisGit.getWorkTree();
thisGit.create();
objectWriter = new ObjectWriter(thisGit);
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/ConnectProviderOperationTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/ConnectProviderOperationTest.java
index 934e132fd..ecb2022b3 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/ConnectProviderOperationTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/ConnectProviderOperationTest.java
@@ -36,6 +36,7 @@ import org.eclipse.jgit.lib.PersonIdent;
import org.eclipse.jgit.lib.RefUpdate;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.Tree;
+import org.eclipse.jgit.storage.file.FileRepository;
import org.eclipse.team.core.RepositoryProvider;
import org.junit.Test;
@@ -57,7 +58,7 @@ public class ConnectProviderOperationTest extends GitTestCase {
File gitDir = new File(project.getProject().getWorkspace().getRoot()
.getRawLocation().toFile(), Constants.DOT_GIT);
- Repository repository = new Repository(gitDir);
+ Repository repository = new FileRepository(gitDir);
repository.create();
repository.close();
ConnectProviderOperation operation = new ConnectProviderOperation(
@@ -80,7 +81,7 @@ public class ConnectProviderOperationTest extends GitTestCase {
File gitDir = new File(project.getProject().getWorkspace().getRoot()
.getRawLocation().toFile(), Constants.DOT_GIT);
- Repository thisGit = new Repository(gitDir);
+ Repository thisGit = new FileRepository(gitDir);
thisGit.create();
Tree rootTree = new Tree(thisGit);
Tree prjTree = rootTree.addTree(project.getProject().getName());
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/ListRemoteOperationTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/ListRemoteOperationTest.java
index 4b38e19ec..183f173b4 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/ListRemoteOperationTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/ListRemoteOperationTest.java
@@ -30,7 +30,7 @@ import org.eclipse.egit.core.test.DualRepositoryTestCase;
import org.eclipse.egit.core.test.TestRepository;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.RefUpdate;
-import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.storage.file.FileRepository;
import org.eclipse.jgit.transport.URIish;
import org.junit.After;
import org.junit.Before;
@@ -95,7 +95,7 @@ public class ListRemoteOperationTest extends DualRepositoryTestCase {
"refs/heads/master", "origin");
clop.run(null);
- repository2 = new TestRepository(new Repository(new File(workdir2,
+ repository2 = new TestRepository(new FileRepository(new File(workdir2,
Constants.DOT_GIT)));
// we push to branch "test" of repository2
RefUpdate createBranch = repository2.getRepository().updateRef(
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/PushOperationTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/PushOperationTest.java
index 162e8002c..742d98d92 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/PushOperationTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/PushOperationTest.java
@@ -38,7 +38,7 @@ import org.eclipse.egit.core.test.TestRepository;
import org.eclipse.egit.core.test.TestUtils;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.RefUpdate;
-import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.storage.file.FileRepository;
import org.eclipse.jgit.transport.RemoteRefUpdate;
import org.eclipse.jgit.transport.URIish;
import org.eclipse.jgit.transport.RemoteRefUpdate.Status;
@@ -105,7 +105,7 @@ public class PushOperationTest extends DualRepositoryTestCase {
"refs/heads/master", "origin");
clop.run(null);
- repository2 = new TestRepository(new Repository(new File(workdir2,
+ repository2 = new TestRepository(new FileRepository(new File(workdir2,
Constants.DOT_GIT)));
// we push to branch "test" of repository2
RefUpdate createBranch = repository2.getRepository().updateRef(
@@ -147,7 +147,7 @@ public class PushOperationTest extends DualRepositoryTestCase {
IFile[] fileArr = files.toArray(new IFile[files.size()]);
// TODO This should be removed once we replace GitIndex with DirCache
- // The following wait is currently needed on file
+ // The following wait is currently needed on file
// systems with low time stamp accuracy or a buggy
// java.io.File.lastModified.
Thread.sleep(1000);
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/TrackUntrackOperationTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/TrackUntrackOperationTest.java
index 7112ddb7a..fe54ae97e 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/TrackUntrackOperationTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/TrackUntrackOperationTest.java
@@ -97,7 +97,7 @@ public class TrackUntrackOperationTest extends DualRepositoryTestCase {
private void assertTrackedState(IFile[] fileArr, boolean expectedState)
throws IOException {
- DirCache cache = DirCache.read(repository1.getRepository());
+ DirCache cache = repository1.getRepository().readDirCache();
for (IFile file : fileArr) {
RepositoryMapping rm = RepositoryMapping.getMapping(file);
String fileDir = rm.getRepoRelativePath(file);

Back to the top