Search in sources :

Example 16 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 17 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)

Example 18 with RevCommit

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

the class PullOpTest method testPullToCurrentBranch.

@Test
public void testPullToCurrentBranch() throws Exception {
    // Add a commit to the remote
    insertAndAdd(remoteGeogig.geogig, lines3);
    RevCommit commit = remoteGeogig.geogig.command(CommitOp.class).call();
    expectedMaster.addFirst(commit);
    // Make sure the local master matches the remote
    localGeogig.geogig.command(BranchCreateOp.class).setName("mynewbranch").setAutoCheckout(true).call();
    // Pull the commit
    PullOp pull = pull();
    pull.addRefSpec("master");
    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("mynewbranch", 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) 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) Test(org.junit.Test)

Example 19 with RevCommit

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

the class GeogigTransactionTest method testCommitUpdatesRemoteRefs.

@Test
public void testCommitUpdatesRemoteRefs() throws Exception {
    // make a commit
    insertAndAdd(points1);
    RevCommit headCommit = geogig.command(CommitOp.class).call();
    geogig.command(RemoteAddOp.class).setName("upstream").setURL("http://test.com/geogig/upstream").call();
    final String remoteRef = "refs/remotes/upstream/master";
    final String unchangedRemoteRef = "refs/remotes/upstream/testbranch";
    Ref remoteHead = geogig.command(UpdateRef.class).setName(remoteRef).setNewValue(headCommit.getId()).call().get();
    assertEquals(headCommit.getId(), remoteHead.getObjectId());
    geogig.command(UpdateRef.class).setName(unchangedRemoteRef).setNewValue(headCommit.getId()).call().get();
    // start a transaction
    GeogigTransaction tx = geogig.command(TransactionBegin.class).call();
    // make a commit
    insertAndAdd(tx, points2);
    RevCommit newcommit = tx.command(CommitOp.class).call();
    // upadte remote
    Ref txRemoteHead = tx.command(UpdateRef.class).setName(remoteRef).setNewValue(newcommit.getId()).call().get();
    assertEquals(newcommit.getId(), txRemoteHead.getObjectId());
    // commit transaction
    tx.commit();
    txRemoteHead = geogig.command(RefParse.class).setName(remoteRef).call().get();
    assertEquals(newcommit.getId(), txRemoteHead.getObjectId());
    txRemoteHead = geogig.command(RefParse.class).setName(unchangedRemoteRef).call().get();
    assertEquals(headCommit.getId(), txRemoteHead.getObjectId());
}
Also used : Ref(org.locationtech.geogig.api.Ref) UpdateRef(org.locationtech.geogig.api.plumbing.UpdateRef) RemoteAddOp(org.locationtech.geogig.api.porcelain.RemoteAddOp) GeogigTransaction(org.locationtech.geogig.api.GeogigTransaction) TransactionBegin(org.locationtech.geogig.api.plumbing.TransactionBegin) CommitOp(org.locationtech.geogig.api.porcelain.CommitOp) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Example 20 with RevCommit

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

the class GeogigTransactionTest method testTransaction.

@Test
public void testTransaction() throws Exception {
    LinkedList<RevCommit> expectedMain = new LinkedList<RevCommit>();
    LinkedList<RevCommit> expectedTransaction = new LinkedList<RevCommit>();
    // make a commit
    insertAndAdd(points1);
    RevCommit commit = geogig.command(CommitOp.class).call();
    expectedMain.addFirst(commit);
    expectedTransaction.addFirst(commit);
    // start a transaction
    GeogigTransaction t = geogig.command(TransactionBegin.class).call();
    // perform a commit in the transaction
    insertAndAdd(t, points2);
    commit = t.command(CommitOp.class).call();
    expectedTransaction.addFirst(commit);
    // Verify that the base repository is unchanged
    Iterator<RevCommit> logs = geogig.command(LogOp.class).call();
    List<RevCommit> logged = new ArrayList<RevCommit>();
    for (; logs.hasNext(); ) {
        logged.add(logs.next());
    }
    assertEquals(expectedMain, logged);
    // Verify that the transaction has the commit
    logs = t.command(LogOp.class).call();
    logged = new ArrayList<RevCommit>();
    for (; logs.hasNext(); ) {
        logged.add(logs.next());
    }
    assertEquals(expectedTransaction, logged);
    // Commit the transaction
    geogig.command(TransactionEnd.class).setTransaction(t).setRebase(true).call();
    // Verify that the base repository has the changes from the transaction
    logs = geogig.command(LogOp.class).call();
    logged = new ArrayList<RevCommit>();
    for (; logs.hasNext(); ) {
        logged.add(logs.next());
    }
    assertEquals(expectedTransaction, logged);
}
Also used : GeogigTransaction(org.locationtech.geogig.api.GeogigTransaction) TransactionBegin(org.locationtech.geogig.api.plumbing.TransactionBegin) LogOp(org.locationtech.geogig.api.porcelain.LogOp) ArrayList(java.util.ArrayList) CommitOp(org.locationtech.geogig.api.porcelain.CommitOp) LinkedList(java.util.LinkedList) RevCommit(org.locationtech.geogig.api.RevCommit) TransactionEnd(org.locationtech.geogig.api.plumbing.TransactionEnd) 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