summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2011-03-07 12:36:48 -0800
committerShawn O. Pearce <spearce@spearce.org>2011-03-07 12:36:51 -0800
commitef822fe3cd26c61f87a8fce6fb5ac5e7a71e6108 (patch)
tree619519213d3599ff60c72033d7342cf4416cabed /org.eclipse.jgit.test
parent1f57061684c83623d7d08be9044fc9cfd7b9fb54 (diff)
downloadjgit-ef822fe3cd26c61f87a8fce6fb5ac5e7a71e6108.tar.gz
jgit-ef822fe3cd26c61f87a8fce6fb5ac5e7a71e6108.zip
Remove deprecated Repository.mapTree
The mapTree() routines have been deprecated for a long time, and their sibilings for mapCommit() and mapTag() were already removed from the main Repository API. Remove mapTree(). Application callers who only need the tree's name can use resolve("^{tree}") syntax to resolve to the tree ObjectId, or fail if the input is not a tree. Applications that want to read a tree should use DirCache or TreeWalk. Change-Id: I85726413790fc87721271c482f6636f81baf8b82 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/exttst/org/eclipse/jgit/lib/T0007_GitIndexTest.java18
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/T0002_TreeTest.java9
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/SimpleMergeTest.java6
3 files changed, 20 insertions, 13 deletions
diff --git a/org.eclipse.jgit.test/exttst/org/eclipse/jgit/lib/T0007_GitIndexTest.java b/org.eclipse.jgit.test/exttst/org/eclipse/jgit/lib/T0007_GitIndexTest.java
index 4c59d5a949..fac828822b 100644
--- a/org.eclipse.jgit.test/exttst/org/eclipse/jgit/lib/T0007_GitIndexTest.java
+++ b/org.eclipse.jgit.test/exttst/org/eclipse/jgit/lib/T0007_GitIndexTest.java
@@ -228,8 +228,7 @@ public class T0007_GitIndexTest extends LocalDiskRepositoryTestCase {
assertEquals("c696abc3ab8e091c665f49d00eb8919690b3aec3", id.name());
GitIndex index2 = new GitIndex(db);
- index2.readTree(db.mapTree(ObjectId.fromString(
- "c696abc3ab8e091c665f49d00eb8919690b3aec3")));
+ index2.readTree(mapTree("c696abc3ab8e091c665f49d00eb8919690b3aec3"));
Entry[] members = index2.getMembers();
assertEquals(3, members.length);
assertEquals("a.b", members[0].getName());
@@ -272,8 +271,7 @@ public class T0007_GitIndexTest extends LocalDiskRepositoryTestCase {
assertEquals("ba78e065e2c261d4f7b8f42107588051e87e18e9", id.name());
GitIndex index2 = new GitIndex(db);
- index2.readTree(db.mapTree(ObjectId.fromString(
- "ba78e065e2c261d4f7b8f42107588051e87e18e9")));
+ index2.readTree(mapTree("ba78e065e2c261d4f7b8f42107588051e87e18e9"));
Entry[] members = index2.getMembers();
assertEquals(6, members.length);
assertEquals("a.b", members[0].getName());
@@ -341,8 +339,7 @@ public class T0007_GitIndexTest extends LocalDiskRepositoryTestCase {
GitIndex index2 = new GitIndex(db);
assertEquals(0, index2.getMembers().length);
- index2.readTree(db.mapTree(ObjectId.fromString(
- "c696abc3ab8e091c665f49d00eb8919690b3aec3")));
+ index2.readTree(mapTree("c696abc3ab8e091c665f49d00eb8919690b3aec3"));
index2.checkout(trash);
assertEquals("data:a/b", read(aslashb));
@@ -375,7 +372,7 @@ public class T0007_GitIndexTest extends LocalDiskRepositoryTestCase {
index.filemode = Boolean.TRUE; // TODO: we need a way to set this using config
index.add(trash, execFile);
index.add(trash, nonexecFile);
- Tree tree = db.mapTree(index.writeTree());
+ Tree tree = mapTree(index.writeTree().name());
assertEquals(FileMode.EXECUTABLE_FILE, tree.findBlobMember(execFile.getName()).getMode());
assertEquals(FileMode.REGULAR_FILE, tree.findBlobMember(nonexecFile.getName()).getMode());
@@ -431,7 +428,7 @@ public class T0007_GitIndexTest extends LocalDiskRepositoryTestCase {
index.filemode = Boolean.FALSE; // TODO: we need a way to set this using config
index.add(trash, execFile);
index.add(trash, nonexecFile);
- Tree tree = db.mapTree(index.writeTree());
+ Tree tree = mapTree(index.writeTree().name());
assertEquals(FileMode.REGULAR_FILE, tree.findBlobMember(execFile.getName()).getMode());
assertEquals(FileMode.REGULAR_FILE, tree.findBlobMember(nonexecFile.getName()).getMode());
@@ -476,4 +473,9 @@ public class T0007_GitIndexTest extends LocalDiskRepositoryTestCase {
write(path, body);
return path;
}
+
+ private Tree mapTree(String name) throws IOException {
+ ObjectId id = db.resolve(name + "^{tree}");
+ return new Tree(db, id, db.open(id).getCachedBytes());
+ }
}
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/T0002_TreeTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/T0002_TreeTest.java
index 0c208cd86f..8027f980d6 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/T0002_TreeTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/T0002_TreeTest.java
@@ -303,9 +303,14 @@ public class T0002_TreeTest extends SampleDataRepositoryTestCase {
@Test
public void test009_SymlinkAndGitlink() throws IOException {
- final Tree symlinkTree = db.mapTree("symlink");
+ final Tree symlinkTree = mapTree("symlink");
assertTrue("Symlink entry exists", symlinkTree.existsBlob("symlink.txt"));
- final Tree gitlinkTree = db.mapTree("gitlink");
+ final Tree gitlinkTree = mapTree("gitlink");
assertTrue("Gitlink entry exists", gitlinkTree.existsBlob("submodule"));
}
+
+ private Tree mapTree(String name) throws IOException {
+ ObjectId id = db.resolve(name + "^{tree}");
+ return new Tree(db, id, db.open(id).getCachedBytes());
+ }
}
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/SimpleMergeTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/SimpleMergeTest.java
index dbf536165e..45b8aa855a 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/SimpleMergeTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/SimpleMergeTest.java
@@ -71,7 +71,7 @@ public class SimpleMergeTest extends SampleDataRepositoryTestCase {
Merger ourMerger = MergeStrategy.OURS.newMerger(db);
boolean merge = ourMerger.merge(new ObjectId[] { db.resolve("a"), db.resolve("c") });
assertTrue(merge);
- assertEquals(db.mapTree("a").getId(), ourMerger.getResultTreeId());
+ assertEquals(db.resolve("a^{tree}"), ourMerger.getResultTreeId());
}
@Test
@@ -79,7 +79,7 @@ public class SimpleMergeTest extends SampleDataRepositoryTestCase {
Merger ourMerger = MergeStrategy.THEIRS.newMerger(db);
boolean merge = ourMerger.merge(new ObjectId[] { db.resolve("a"), db.resolve("c") });
assertTrue(merge);
- assertEquals(db.mapTree("c").getId(), ourMerger.getResultTreeId());
+ assertEquals(db.resolve("c^{tree}"), ourMerger.getResultTreeId());
}
@Test
@@ -103,7 +103,7 @@ public class SimpleMergeTest extends SampleDataRepositoryTestCase {
Merger ourMerger = MergeStrategy.SIMPLE_TWO_WAY_IN_CORE.newMerger(db);
boolean merge = ourMerger.merge(new ObjectId[] { db.resolve("a^0^0^0"), db.resolve("a^0^0^1") });
assertTrue(merge);
- assertEquals(db.mapTree("a^0^0").getId(), ourMerger.getResultTreeId());
+ assertEquals(db.resolve("a^0^0^{tree}"), ourMerger.getResultTreeId());
}
@Test