Search in sources :

Example 91 with RevCommit

use of org.locationtech.geogig.api.RevCommit in project GeoGig by boundlessgeo.

the class CheckoutOpTest method testCheckoutBranch.

@Test
public void testCheckoutBranch() throws Exception {
    insertAndAdd(points1);
    final RevCommit c1 = geogig.command(CommitOp.class).setMessage("commit for " + idP1).call();
    final Ref branch1 = geogig.command(BranchCreateOp.class).setName("branch1").call();
    insertAndAdd(points2);
    final RevCommit c2 = geogig.command(CommitOp.class).setMessage("commit for " + idP2).call();
    final Ref branch2 = geogig.command(BranchCreateOp.class).setName("branch2").call();
    insertAndAdd(lines1);
    final RevCommit c3 = geogig.command(CommitOp.class).setMessage("commit for " + idL2).call();
    final Ref branch3 = geogig.command(BranchCreateOp.class).setName("branch3").call();
    CheckoutResult result;
    result = geogig.command(CheckoutOp.class).setSource("branch1").call();
    assertEquals(c1.getTreeId(), result.getNewTree());
    assertTrue(geogig.command(RefParse.class).setName(Ref.HEAD).call().get() instanceof SymRef);
    assertEquals(branch1.getName(), ((SymRef) geogig.command(RefParse.class).setName(Ref.HEAD).call().get()).getTarget());
    result = geogig.command(CheckoutOp.class).setSource("branch2").call();
    assertEquals(c2.getTreeId(), result.getNewTree());
    assertTrue(geogig.command(RefParse.class).setName(Ref.HEAD).call().get() instanceof SymRef);
    assertEquals(branch2.getName(), ((SymRef) geogig.command(RefParse.class).setName(Ref.HEAD).call().get()).getTarget());
    result = geogig.command(CheckoutOp.class).setSource("branch3").call();
    assertEquals(c3.getTreeId(), result.getNewTree());
    assertTrue(geogig.command(RefParse.class).setName(Ref.HEAD).call().get() instanceof SymRef);
    assertEquals(branch3.getName(), ((SymRef) geogig.command(RefParse.class).setName(Ref.HEAD).call().get()).getTarget());
}
Also used : Ref(org.locationtech.geogig.api.Ref) SymRef(org.locationtech.geogig.api.SymRef) NodeRef(org.locationtech.geogig.api.NodeRef) SymRef(org.locationtech.geogig.api.SymRef) CheckoutResult(org.locationtech.geogig.api.porcelain.CheckoutResult) CheckoutOp(org.locationtech.geogig.api.porcelain.CheckoutOp) RefParse(org.locationtech.geogig.api.plumbing.RefParse) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Example 92 with RevCommit

use of org.locationtech.geogig.api.RevCommit in project GeoGig by boundlessgeo.

the class BlameOpTest method testBlameChangedByLastCommit.

@Test
public void testBlameChangedByLastCommit() throws Exception {
    insertAndAdd(points1);
    geogig.command(CommitOp.class).call();
    insertAndAdd(points1_modified);
    RevCommit secondCommit = geogig.command(CommitOp.class).call();
    String path = NodeRef.appendChild(pointsName, idP1);
    BlameReport report = geogig.command(BlameOp.class).setPath(path).call();
    Map<String, ValueAndCommit> changes = report.getChanges();
    assertEquals(3, changes.size());
    Collection<ValueAndCommit> commits = changes.values();
    for (ValueAndCommit valueAndCommit : commits) {
        assertEquals(secondCommit, valueAndCommit.commit);
    }
}
Also used : ValueAndCommit(org.locationtech.geogig.api.porcelain.ValueAndCommit) BlameReport(org.locationtech.geogig.api.porcelain.BlameReport) CommitOp(org.locationtech.geogig.api.porcelain.CommitOp) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Example 93 with RevCommit

use of org.locationtech.geogig.api.RevCommit in project GeoGig by boundlessgeo.

the class CheckSparsePathTest method testCheckSparsePath.

@Test
public void testCheckSparsePath() throws Exception {
    // Create the following revision graph
    // o - commit1
    // |\
    // | o - commit2
    // | |
    // | o - commit3
    // | |\
    // | | o - commit4
    // | | |\
    // | | | o - commit5 (sparse)
    // | | | |
    // | | o | - commit6
    // | | |/
    // | | o - commit7
    // | |
    // o | - commit8
    // | |
    // | o - commit9
    // |/
    // o - commit10
    insertAndAdd(points1);
    RevCommit commit1 = geogig.command(CommitOp.class).setMessage("commit1").call();
    // create branch1 and checkout
    geogig.command(BranchCreateOp.class).setAutoCheckout(true).setName("branch1").call();
    insertAndAdd(points2);
    RevCommit commit2 = geogig.command(CommitOp.class).setMessage("commit2").call();
    insertAndAdd(points3);
    RevCommit commit3 = geogig.command(CommitOp.class).setMessage("commit3").call();
    geogig.command(BranchCreateOp.class).setAutoCheckout(true).setName("branch2").call();
    insertAndAdd(lines1);
    RevCommit commit4 = geogig.command(CommitOp.class).setMessage("commit4").call();
    geogig.command(BranchCreateOp.class).setAutoCheckout(true).setName("branch3").call();
    insertAndAdd(poly1);
    RevCommit commit5 = geogig.command(CommitOp.class).setMessage("commit5").call();
    geogig.getRepository().graphDatabase().setProperty(commit5.getId(), GraphDatabase.SPARSE_FLAG, "true");
    geogig.command(CheckoutOp.class).setSource("branch2").call();
    insertAndAdd(poly2);
    RevCommit commit6 = geogig.command(CommitOp.class).setMessage("commit6").call();
    RevCommit commit7 = geogig.command(MergeOp.class).setMessage("commit7").addCommit(Suppliers.ofInstance(commit5.getId())).call().getMergeCommit();
    geogig.command(CheckoutOp.class).setSource("branch1").call();
    insertAndAdd(lines3);
    RevCommit commit9 = geogig.command(CommitOp.class).setMessage("commit9").call();
    // checkout master
    geogig.command(CheckoutOp.class).setSource("master").call();
    insertAndAdd(lines2);
    RevCommit commit8 = geogig.command(CommitOp.class).setMessage("commit8").call();
    RevCommit commit10 = geogig.command(MergeOp.class).setMessage("commit10").addCommit(Suppliers.ofInstance(commit9.getId())).call().getMergeCommit();
    CheckSparsePath command = geogig.command(CheckSparsePath.class);
    assertTrue(command.setStart(commit7.getId()).setEnd(commit1.getId()).call());
    assertFalse(command.setStart(commit6.getId()).setEnd(commit1.getId()).call());
    assertTrue(command.setStart(commit5.getId()).setEnd(commit2.getId()).call());
    assertFalse(command.setStart(commit10.getId()).setEnd(commit1.getId()).call());
    assertFalse(command.setStart(commit10.getId()).setEnd(commit3.getId()).call());
    assertFalse(command.setStart(commit8.getId()).setEnd(commit1.getId()).call());
    assertFalse(command.setStart(commit4.getId()).setEnd(commit2.getId()).call());
    assertFalse(command.setStart(commit7.getId()).setEnd(commit5.getId()).call());
}
Also used : CheckSparsePath(org.locationtech.geogig.api.plumbing.CheckSparsePath) BranchCreateOp(org.locationtech.geogig.api.porcelain.BranchCreateOp) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Example 94 with RevCommit

use of org.locationtech.geogig.api.RevCommit in project GeoGig by boundlessgeo.

the class BlameOpTest method testBlameChangedByASingleCommit.

@Test
public void testBlameChangedByASingleCommit() throws Exception {
    insertAndAdd(points1);
    RevCommit firstCommit = geogig.command(CommitOp.class).call();
    String path = NodeRef.appendChild(pointsName, idP1);
    BlameReport report = geogig.command(BlameOp.class).setPath(path).call();
    Map<String, ValueAndCommit> changes = report.getChanges();
    assertEquals(3, changes.size());
    Collection<ValueAndCommit> commits = changes.values();
    for (ValueAndCommit valueAndCommit : commits) {
        assertEquals(firstCommit, valueAndCommit.commit);
    }
}
Also used : ValueAndCommit(org.locationtech.geogig.api.porcelain.ValueAndCommit) BlameReport(org.locationtech.geogig.api.porcelain.BlameReport) CommitOp(org.locationtech.geogig.api.porcelain.CommitOp) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Example 95 with RevCommit

use of org.locationtech.geogig.api.RevCommit in project GeoGig by boundlessgeo.

the class BranchCreateOpTest method testCreateBranchWithTheSameNameAsExistingBranchAndForce.

@Test
public void testCreateBranchWithTheSameNameAsExistingBranchAndForce() throws Exception {
    insertAndAdd(points1);
    geogig.command(CommitOp.class).setMessage("Commit1").call();
    geogig.command(BranchCreateOp.class).setName("branch1").call();
    insertAndAdd(points2);
    RevCommit newCommit = geogig.command(CommitOp.class).setMessage("Commit2").call();
    geogig.command(BranchCreateOp.class).setName("branch1").setForce(true).call();
    Optional<Ref> branch1 = geogig.command(RefParse.class).setName("branch1").call();
    assertTrue(branch1.isPresent());
    assertEquals(branch1.get().getObjectId(), newCommit.getId());
}
Also used : Ref(org.locationtech.geogig.api.Ref) BranchCreateOp(org.locationtech.geogig.api.porcelain.BranchCreateOp) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

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