Search in sources :

Example 71 with RevCommit

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());
}
Also used : RevFeature(org.locationtech.geogig.api.RevFeature) CommitOp(org.locationtech.geogig.api.porcelain.CommitOp) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Example 72 with RevCommit

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());
}
Also used : MergeReport(org.locationtech.geogig.api.porcelain.MergeOp.MergeReport) UpdateRef(org.locationtech.geogig.api.plumbing.UpdateRef) UpdateSymRef(org.locationtech.geogig.api.plumbing.UpdateSymRef) Ref(org.locationtech.geogig.api.Ref) NodeRef(org.locationtech.geogig.api.NodeRef) BranchCreateOp(org.locationtech.geogig.api.porcelain.BranchCreateOp) LogOp(org.locationtech.geogig.api.porcelain.LogOp) RefParse(org.locationtech.geogig.api.plumbing.RefParse) FindTreeChild(org.locationtech.geogig.api.plumbing.FindTreeChild) RevTree(org.locationtech.geogig.api.RevTree) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Example 73 with RevCommit

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();
}
Also used : PullOp(org.locationtech.geogig.api.porcelain.PullOp) CommitOp(org.locationtech.geogig.api.porcelain.CommitOp) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Example 74 with RevCommit

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);
}
Also used : PushOp(org.locationtech.geogig.api.porcelain.PushOp) LogOp(org.locationtech.geogig.api.porcelain.LogOp) ArrayList(java.util.ArrayList) CommitOp(org.locationtech.geogig.api.porcelain.CommitOp) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Example 75 with RevCommit

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);
}
Also used : CloneOp(org.locationtech.geogig.api.porcelain.CloneOp) BranchCreateOp(org.locationtech.geogig.api.porcelain.BranchCreateOp) LogOp(org.locationtech.geogig.api.porcelain.LogOp) ArrayList(java.util.ArrayList) CommitOp(org.locationtech.geogig.api.porcelain.CommitOp) RevCommit(org.locationtech.geogig.api.RevCommit)

Aggregations

RevCommit (org.locationtech.geogig.api.RevCommit)291 Test (org.junit.Test)212 ObjectId (org.locationtech.geogig.api.ObjectId)109 CommitOp (org.locationtech.geogig.api.porcelain.CommitOp)107 LogOp (org.locationtech.geogig.api.porcelain.LogOp)86 Ref (org.locationtech.geogig.api.Ref)71 Feature (org.opengis.feature.Feature)52 NodeRef (org.locationtech.geogig.api.NodeRef)47 ArrayList (java.util.ArrayList)44 BranchCreateOp (org.locationtech.geogig.api.porcelain.BranchCreateOp)44 RevTree (org.locationtech.geogig.api.RevTree)36 SymRef (org.locationtech.geogig.api.SymRef)33 RefParse (org.locationtech.geogig.api.plumbing.RefParse)33 DiffEntry (org.locationtech.geogig.api.plumbing.diff.DiffEntry)31 RevObject (org.locationtech.geogig.api.RevObject)30 UpdateRef (org.locationtech.geogig.api.plumbing.UpdateRef)30 MergeScenarioReport (org.locationtech.geogig.api.plumbing.merge.MergeScenarioReport)30 UpdateSymRef (org.locationtech.geogig.api.plumbing.UpdateSymRef)26 LinkedList (java.util.LinkedList)24 AddOp (org.locationtech.geogig.api.porcelain.AddOp)21