use of org.locationtech.geogig.api.RevCommit in project GeoGig by boundlessgeo.
the class MergeOpTest method testOctopusMergeSameFeatureChanges.
@Test
public void testOctopusMergeSameFeatureChanges() throws Exception {
insertAndAdd(points1);
geogig.command(CommitOp.class).call();
geogig.command(BranchCreateOp.class).setName("branch1").call();
geogig.command(BranchCreateOp.class).setName("branch2").call();
geogig.command(BranchCreateOp.class).setName("branch3").call();
insertAndAdd(points1_modified);
geogig.command(CommitOp.class).call();
geogig.command(CheckoutOp.class).setSource("branch1").call();
insertAndAdd(points2);
RevCommit branch1 = geogig.command(CommitOp.class).call();
geogig.command(CheckoutOp.class).setSource("branch2").call();
insertAndAdd(points3);
RevCommit branch2 = geogig.command(CommitOp.class).call();
geogig.command(CheckoutOp.class).setSource("branch3").call();
insertAndAdd(points1_modified);
RevCommit branch3 = geogig.command(CommitOp.class).call();
geogig.command(CheckoutOp.class).setSource("master").call();
geogig.command(MergeOp.class).addCommit(Suppliers.ofInstance(branch1.getId())).addCommit(Suppliers.ofInstance(branch2.getId())).addCommit(Suppliers.ofInstance(branch3.getId())).call();
String path = NodeRef.appendChild(pointsName, idP1);
Optional<RevFeature> revFeature = geogig.command(RevObjectParse.class).setRefSpec(Ref.HEAD + ":" + path).call(RevFeature.class);
assertTrue(revFeature.isPresent());
assertEquals(RevFeatureBuilder.build(points1_modified), revFeature.get());
}
use of org.locationtech.geogig.api.RevCommit in project GeoGig by boundlessgeo.
the class MergeOpTest method testMergeFastForward.
@Test
public void testMergeFastForward() throws Exception {
// Create the following revision graph
// o
// |
// o - master - HEAD - Points 1 added
// .\
// . o - branch1 - Points 2 added
insertAndAdd(points1);
final RevCommit c1 = geogig.command(CommitOp.class).setMessage("commit for " + idP1).call();
// create branch1 and checkout
geogig.command(BranchCreateOp.class).setAutoCheckout(true).setName("branch1").call();
insertAndAdd(points2);
final RevCommit c2 = geogig.command(CommitOp.class).setMessage("commit for " + idP2).call();
// checkout master
geogig.command(CheckoutOp.class).setSource("master").call();
// Merge branch1 into master to create the following revision graph
// o
// |
// o - Points 1 added
// |
// o - master - HEAD - branch1 - Points 2 added
Ref branch1 = geogig.command(RefParse.class).setName("branch1").call().get();
final MergeReport mergeReport = geogig.command(MergeOp.class).addCommit(Suppliers.ofInstance(branch1.getObjectId())).call();
RevTree mergedTree = repo.getTree(mergeReport.getMergeCommit().getTreeId());
String path = appendChild(pointsName, points1.getIdentifier().getID());
assertTrue(repo.command(FindTreeChild.class).setParent(mergedTree).setChildPath(path).call().isPresent());
path = appendChild(pointsName, points2.getIdentifier().getID());
assertTrue(repo.command(FindTreeChild.class).setParent(mergedTree).setChildPath(path).call().isPresent());
Iterator<RevCommit> log = geogig.command(LogOp.class).call();
// Commit 2
RevCommit logC2 = log.next();
assertEquals(c2.getAuthor(), logC2.getAuthor());
assertEquals(c2.getCommitter(), logC2.getCommitter());
assertEquals(c2.getMessage(), logC2.getMessage());
assertEquals(c2.getTreeId(), logC2.getTreeId());
// Commit 1
RevCommit logC1 = log.next();
assertEquals(c1.getAuthor(), logC1.getAuthor());
assertEquals(c1.getCommitter(), logC1.getCommitter());
assertEquals(c1.getMessage(), logC1.getMessage());
assertEquals(c1.getTreeId(), logC1.getTreeId());
}
use of org.locationtech.geogig.api.RevCommit in project GeoGig by boundlessgeo.
the class PullOpTest method testPullTooManyRefs.
@Test
public void testPullTooManyRefs() throws Exception {
// Add a commit to the remote
insertAndAdd(remoteGeogig.geogig, lines3);
RevCommit commit = remoteGeogig.geogig.command(CommitOp.class).call();
expectedMaster.addFirst(commit);
// Pull the commit
PullOp pull = pull();
pull.addRefSpec("master:newbranch:newbranch2");
exception.expect(IllegalArgumentException.class);
pull.setRebase(true).call();
}
use of org.locationtech.geogig.api.RevCommit in project GeoGig by boundlessgeo.
the class PushOpTest method testPushAll.
@Test
public void testPushAll() throws Exception {
// Add a commit to the local repository
insertAndAdd(localGeogig.geogig, lines3);
RevCommit commit = localGeogig.geogig.command(CommitOp.class).call();
expectedMaster.addFirst(commit);
localGeogig.geogig.command(CheckoutOp.class).setSource("Branch1").call();
insertAndAdd(localGeogig.geogig, points1_modified);
RevCommit commit2 = localGeogig.geogig.command(CommitOp.class).call();
expectedBranch.addFirst(commit2);
// Push the commit
PushOp push = push();
push.setAll(true).call();
// verify that the remote got the commit on both branches
remoteGeogig.geogig.command(CheckoutOp.class).setSource("master").call();
Iterator<RevCommit> logs = remoteGeogig.geogig.command(LogOp.class).call();
List<RevCommit> logged = new ArrayList<RevCommit>();
for (; logs.hasNext(); ) {
logged.add(logs.next());
}
assertEquals(expectedMaster, logged);
remoteGeogig.geogig.command(CheckoutOp.class).setSource("Branch1").call();
logs = remoteGeogig.geogig.command(LogOp.class).call();
logged = new ArrayList<RevCommit>();
for (; logs.hasNext(); ) {
logged.add(logs.next());
}
assertEquals(expectedBranch, logged);
}
use of org.locationtech.geogig.api.RevCommit in project GeoGig by boundlessgeo.
the class PushOpTest method setUpInternal.
@Override
protected void setUpInternal() throws Exception {
// Commit several features to the remote
expectedMaster = new LinkedList<RevCommit>();
expectedBranch = new LinkedList<RevCommit>();
insertAndAdd(remoteGeogig.geogig, points1);
RevCommit commit = remoteGeogig.geogig.command(CommitOp.class).call();
expectedMaster.addFirst(commit);
expectedBranch.addFirst(commit);
// Create and checkout branch1
remoteGeogig.geogig.command(BranchCreateOp.class).setAutoCheckout(true).setName("Branch1").call();
// Commit some changes to branch1
insertAndAdd(remoteGeogig.geogig, points2);
commit = remoteGeogig.geogig.command(CommitOp.class).call();
expectedBranch.addFirst(commit);
insertAndAdd(remoteGeogig.geogig, points3);
commit = remoteGeogig.geogig.command(CommitOp.class).call();
expectedBranch.addFirst(commit);
// Make sure Branch1 has all of the commits
Iterator<RevCommit> logs = remoteGeogig.geogig.command(LogOp.class).call();
List<RevCommit> logged = new ArrayList<RevCommit>();
for (; logs.hasNext(); ) {
logged.add(logs.next());
}
assertEquals(expectedBranch, logged);
// Checkout master and commit some changes
remoteGeogig.geogig.command(CheckoutOp.class).setSource("master").call();
insertAndAdd(remoteGeogig.geogig, lines1);
commit = remoteGeogig.geogig.command(CommitOp.class).call();
expectedMaster.addFirst(commit);
insertAndAdd(remoteGeogig.geogig, lines2);
commit = remoteGeogig.geogig.command(CommitOp.class).call();
expectedMaster.addFirst(commit);
// Make sure master has all of the commits
logs = remoteGeogig.geogig.command(LogOp.class).call();
logged = new ArrayList<RevCommit>();
for (; logs.hasNext(); ) {
logged.add(logs.next());
}
assertEquals(expectedMaster, logged);
// Make sure the local repository has no commits prior to clone
logs = localGeogig.geogig.command(LogOp.class).call();
assertNotNull(logs);
assertFalse(logs.hasNext());
// clone from the remote
CloneOp clone = clone();
clone.setRepositoryURL(remoteGeogig.envHome.getCanonicalPath()).setBranch("Branch1").call();
// Make sure the local repository got all of the commits
logs = localGeogig.geogig.command(LogOp.class).call();
logged = new ArrayList<RevCommit>();
for (; logs.hasNext(); ) {
logged.add(logs.next());
}
assertEquals(expectedBranch, logged);
// Make sure the local master matches the remote
localGeogig.geogig.command(CheckoutOp.class).setSource("master").call();
logs = localGeogig.geogig.command(LogOp.class).call();
logged = new ArrayList<RevCommit>();
for (; logs.hasNext(); ) {
logged.add(logs.next());
}
assertEquals(expectedMaster, logged);
}
Aggregations