Search in sources :

Example 61 with RevCommit

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

the class FindCommonAncestorTest method testFindCommonAncestorCase5.

@Test
public void testFindCommonAncestorCase5() throws Exception {
    // Create the following revision graph
    // o - root commit Add Points 1
    // |\
    // | o - commit1 Add Points 2
    // | |\
    // o | | - commit2 Add Points 3
    // | | |
    // | | o - commit3 Modify Points 1
    // | | |
    // | o | - commit4 Add Lines 1
    // | |\|
    // | | o - commit5 Merge commit
    // | | |
    // | o | - commit6 Add Lines 2
    // | | |
    // | o | - commit7 Add Lines 3
    // | | |
    // | o | - commit8 Add Polygon 1
    // | | |
    // | o | - commit9 Add Polygon 2
    // | | |
    // | | o - commit10 Add Polygon 3
    // |/
    // o - commit11 Merge commit
    // root commit
    insertAndAdd(points1);
    geogig.command(CommitOp.class).setMessage("root commit").call();
    // commit1
    geogig.command(BranchCreateOp.class).setAutoCheckout(true).setName("branch1").call();
    insertAndAdd(points2);
    geogig.command(CommitOp.class).setMessage("commit1").call();
    geogig.command(BranchCreateOp.class).setAutoCheckout(false).setName("branch2").call();
    // commit2
    geogig.command(CheckoutOp.class).setSource("master").call();
    insertAndAdd(points3);
    geogig.command(CommitOp.class).setMessage("commit2").call();
    // commit3
    geogig.command(CheckoutOp.class).setSource("branch2").call();
    insertAndAdd(points1_modified);
    geogig.command(CommitOp.class).setMessage("commit3").call();
    // commit4
    geogig.command(CheckoutOp.class).setSource("branch1").call();
    insertAndAdd(lines1);
    ObjectId commit4 = geogig.command(CommitOp.class).setMessage("commit4").call().getId();
    // commit5
    geogig.command(CheckoutOp.class).setSource("branch2").call();
    geogig.command(MergeOp.class).setMessage("commit3").addCommit(Suppliers.ofInstance(commit4)).call();
    // commit6
    geogig.command(CheckoutOp.class).setSource("branch1").call();
    insertAndAdd(lines2);
    geogig.command(CommitOp.class).setMessage("commit6").call();
    // commit7
    insertAndAdd(lines3);
    geogig.command(CommitOp.class).setMessage("commit7").call();
    // commit8
    insertAndAdd(poly1);
    geogig.command(CommitOp.class).setMessage("commit8").call();
    // commit9
    insertAndAdd(poly2);
    ObjectId commit9 = geogig.command(CommitOp.class).setMessage("commit9").call().getId();
    // commit10
    geogig.command(CheckoutOp.class).setSource("branch2").call();
    insertAndAdd(poly3);
    RevCommit commit10 = geogig.command(CommitOp.class).setMessage("commit10").call();
    // commit11
    geogig.command(CheckoutOp.class).setSource("master").call();
    MergeReport report = geogig.command(MergeOp.class).setMessage("commit11").addCommit(Suppliers.ofInstance(commit9)).call();
    Optional<ObjectId> commonAncestor = geogig.command(FindCommonAncestor.class).setLeft(report.getMergeCommit()).setRight(commit10).call();
    assertTrue(commonAncestor.isPresent());
    assertEquals(commonAncestor.get(), commit4);
}
Also used : MergeReport(org.locationtech.geogig.api.porcelain.MergeOp.MergeReport) BranchCreateOp(org.locationtech.geogig.api.porcelain.BranchCreateOp) ObjectId(org.locationtech.geogig.api.ObjectId) FindCommonAncestor(org.locationtech.geogig.api.plumbing.FindCommonAncestor) MergeOp(org.locationtech.geogig.api.porcelain.MergeOp) CommitOp(org.locationtech.geogig.api.porcelain.CommitOp) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Example 62 with RevCommit

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

the class FindCommonAncestorTest method testFindCommonAncestorCase3.

@Test
public void testFindCommonAncestorCase3() throws Exception {
    // Create the following revision graph
    // o
    // |
    // o - Points 1 added
    // |\
    // | o - Points 2 added
    // | |
    // | o - Points 3 added
    // | |\
    // | | o - Lines 1 added - branch2
    // | |
    // o | - Lines 2 added
    // | |
    // | o - Lines 3 added - branch1
    // |/
    // o - master - HEAD - Merge Commit
    insertAndAdd(points1);
    geogig.command(CommitOp.class).setMessage("commit for " + idP1).call();
    // create branch1 and checkout
    geogig.command(BranchCreateOp.class).setAutoCheckout(true).setName("branch1").call();
    insertAndAdd(points2);
    geogig.command(CommitOp.class).setMessage("commit for " + idP2).call();
    insertAndAdd(points3);
    final RevCommit ancestor = geogig.command(CommitOp.class).setMessage("commit for " + idP3).call();
    geogig.command(BranchCreateOp.class).setAutoCheckout(true).setName("branch2").call();
    insertAndAdd(lines1);
    final RevCommit branch2 = geogig.command(CommitOp.class).setMessage("commit for " + idL1).call();
    geogig.command(CheckoutOp.class).setSource("branch1").call();
    insertAndAdd(lines3);
    final RevCommit left = geogig.command(CommitOp.class).setMessage("commit for " + idL3).call();
    // checkout master
    geogig.command(CheckoutOp.class).setSource("master").call();
    insertAndAdd(lines2);
    geogig.command(CommitOp.class).setMessage("commit for " + idL2).call();
    final MergeReport mergeReport = geogig.command(MergeOp.class).addCommit(Suppliers.ofInstance(left.getId())).call();
    Optional<ObjectId> commonAncestor = geogig.command(FindCommonAncestor.class).setLeft(mergeReport.getMergeCommit()).setRight(branch2).call();
    assertTrue(commonAncestor.isPresent());
    assertEquals(commonAncestor.get(), ancestor.getId());
}
Also used : MergeReport(org.locationtech.geogig.api.porcelain.MergeOp.MergeReport) BranchCreateOp(org.locationtech.geogig.api.porcelain.BranchCreateOp) ObjectId(org.locationtech.geogig.api.ObjectId) FindCommonAncestor(org.locationtech.geogig.api.plumbing.FindCommonAncestor) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Example 63 with RevCommit

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

the class FindCommonAncestorTest method testFindCommonAncestorCase2.

@Test
public void testFindCommonAncestorCase2() throws Exception {
    // Create the following revision graph
    // o
    // |
    // o - Points 1 added
    // |\
    // | o - Points 2 added
    // | |
    // | o - Points 3 added
    // | |
    // | o - Lines 2 added - branch1
    // |
    // o - master - HEAD - Lines 1 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);
    geogig.command(CommitOp.class).setMessage("commit for " + idP2).call();
    insertAndAdd(points3);
    geogig.command(CommitOp.class).setMessage("commit for " + idP3).call();
    insertAndAdd(lines2);
    final RevCommit left = geogig.command(CommitOp.class).setMessage("commit for " + idL2).call();
    // checkout master
    geogig.command(CheckoutOp.class).setSource("master").call();
    insertAndAdd(lines1);
    final RevCommit right = geogig.command(CommitOp.class).setMessage("commit for " + idL1).call();
    Optional<ObjectId> commonAncestor = geogig.command(FindCommonAncestor.class).setLeft(left).setRight(right).call();
    assertTrue(commonAncestor.isPresent());
    assertEquals(commonAncestor.get(), c1.getId());
}
Also used : BranchCreateOp(org.locationtech.geogig.api.porcelain.BranchCreateOp) ObjectId(org.locationtech.geogig.api.ObjectId) FindCommonAncestor(org.locationtech.geogig.api.plumbing.FindCommonAncestor) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Example 64 with RevCommit

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

the class PullOpTest method testPullRebase.

@Test
public void testPullRebase() 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.setRebase(true).setAll(true).call();
    Iterator<RevCommit> logs = localGeogig.geogig.command(LogOp.class).call();
    List<RevCommit> logged = new ArrayList<RevCommit>();
    for (; logs.hasNext(); ) {
        logged.add(logs.next());
    }
    assertEquals(expectedMaster, logged);
}
Also used : PullOp(org.locationtech.geogig.api.porcelain.PullOp) 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 65 with RevCommit

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

the class PullOpTest method testPullRefspecs.

@Test
public void testPullRefspecs() 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");
    pull.setRebase(true).call();
    final Optional<Ref> currHead = localGeogig.geogig.command(RefParse.class).setName(Ref.HEAD).call();
    assertTrue(currHead.isPresent());
    assertTrue(currHead.get() instanceof SymRef);
    final SymRef headRef = (SymRef) currHead.get();
    final String currentBranch = Ref.localName(headRef.getTarget());
    assertEquals("newbranch", currentBranch);
    Iterator<RevCommit> logs = localGeogig.geogig.command(LogOp.class).call();
    List<RevCommit> logged = new ArrayList<RevCommit>();
    for (; logs.hasNext(); ) {
        logged.add(logs.next());
    }
    assertEquals(expectedMaster, logged);
}
Also used : PullOp(org.locationtech.geogig.api.porcelain.PullOp) UpdateRef(org.locationtech.geogig.api.plumbing.UpdateRef) UpdateSymRef(org.locationtech.geogig.api.plumbing.UpdateSymRef) Ref(org.locationtech.geogig.api.Ref) SymRef(org.locationtech.geogig.api.SymRef) UpdateSymRef(org.locationtech.geogig.api.plumbing.UpdateSymRef) SymRef(org.locationtech.geogig.api.SymRef) 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)

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