use of org.locationtech.geogig.api.porcelain.CloneOp in project GeoGig by boundlessgeo.
the class FetchOpTest method testFetchNewCommitsWithShallowClone2.
@Test
public void testFetchNewCommitsWithShallowClone2() throws Exception {
insertAndAdd(remoteGeogig.geogig, points1);
RevCommit commit = remoteGeogig.geogig.command(CommitOp.class).setMessage("1").call();
insertAndAdd(remoteGeogig.geogig, points2);
commit = remoteGeogig.geogig.command(CommitOp.class).setMessage("2").call();
insertAndAdd(remoteGeogig.geogig, points3);
commit = remoteGeogig.geogig.command(CommitOp.class).setMessage("3").call();
// clone the repository
CloneOp clone = clone();
clone.setDepth(2);
clone.setRepositoryURL(remoteGeogig.envHome.getCanonicalPath()).call();
// Checkout master and commit some changes
remoteGeogig.geogig.command(CheckoutOp.class).setSource("master").call();
insertAndAdd(remoteGeogig.geogig, lines1);
commit = remoteGeogig.geogig.command(CommitOp.class).setMessage("4").call();
insertAndAdd(remoteGeogig.geogig, points1_modified);
commit = remoteGeogig.geogig.command(CommitOp.class).setMessage("5").call();
insertAndAdd(remoteGeogig.geogig, lines2);
commit = remoteGeogig.geogig.command(CommitOp.class).setMessage("6").call();
insertAndAdd(remoteGeogig.geogig, lines3);
commit = remoteGeogig.geogig.command(CommitOp.class).setMessage("7").call();
FetchOp fetch = fetch();
// fetch.setDepth(2);
fetch.call();
localGeogig.geogig.command(CheckoutOp.class).setSource("refs/remotes/origin/master").call();
Iterator<RevCommit> logs = localGeogig.geogig.command(LogOp.class).call();
List<RevCommit> logged = Lists.newArrayList(logs);
// Should have the previous 2 commits, plus all 4 new commits.
assertEquals(6, logged.size());
}
use of org.locationtech.geogig.api.porcelain.CloneOp in project GeoGig by boundlessgeo.
the class CloneOpTest method testCloneWithTags.
@Test
public void testCloneWithTags() throws Exception {
// Commit several features to the remote
List<Feature> features = Arrays.asList(points1, lines1, points2, lines2, points3, lines3);
LinkedList<RevCommit> expected = new LinkedList<RevCommit>();
List<RevTag> tags = Lists.newArrayList();
for (Feature f : features) {
ObjectId oId = insertAndAdd(remoteGeogig.geogig, f);
final RevCommit commit = remoteGeogig.geogig.command(CommitOp.class).call();
expected.addFirst(commit);
Optional<RevObject> childObject = remoteGeogig.geogig.command(RevObjectParse.class).setObjectId(oId).call();
assertTrue(childObject.isPresent());
RevTag tag = remoteGeogig.geogig.command(TagCreateOp.class).setCommitId(commit.getId()).setName(f.getIdentifier().getID()).call();
tags.add(tag);
}
// Make sure the remote 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(expected, logged);
// Make sure the remote has all of the tags
ImmutableList<RevTag> remoteTags = remoteGeogig.geogig.command(TagListOp.class).call();
assertEquals(tags.size(), remoteTags.size());
for (RevTag tag : tags) {
assertTrue(remoteTags.contains(tag));
}
// 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.setDepth(0);
clone.setRepositoryURL(remoteGeogig.envHome.getCanonicalPath()).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(expected, logged);
/*
* This is commented out, since the clone operation does not clone tags yet This test
* verifies that no errors are raised when the repo to clone contains tags, but not to
* verify that tags are also cloned, since that is not supported
*
* I leave this dommented code here, to uncomment it once tag support is implemented for the
* clone operation
*
*
* // Make sure the local repository got all of the tags
*
* ImmutableList<RevTag> localTags = localGeogig.geogig.command(TagListOp.class).call();
*
* assertEquals(tags.size(), localTags.size());
*
* for (RevTag tag : tags) {
*
* assertTrue(localTags.contains(tag));
*
* }
*/
}
use of org.locationtech.geogig.api.porcelain.CloneOp in project GeoGig by boundlessgeo.
the class CloneOpTest method testCloneNoRepoSpecified.
@Test
public void testCloneNoRepoSpecified() throws Exception {
CloneOp clone = clone();
exception.expect(IllegalArgumentException.class);
clone.call();
}
use of org.locationtech.geogig.api.porcelain.CloneOp in project GeoGig by boundlessgeo.
the class SparseCloneTest method setupSparseClone.
private void setupSparseClone() throws Exception {
Map<String, String> filter = new HashMap<String, String>();
filter.put("default", "BBOX(pp,30, -125, 40, -110,'EPSG:4326')");
filter.put("Cities", "BBOX(pp,33, -125, 40, -110,'EPSG:4326')");
createFilterFile(filter);
// Commit several features to the remote
List<Feature> features = Arrays.asList(city3, road1, city2, road2);
LinkedList<RevCommit> expected = new LinkedList<RevCommit>();
Map<Feature, ObjectId> oids = new HashMap<Feature, ObjectId>();
for (Feature f : features) {
ObjectId oId = insertAndAdd(remoteGeogig.geogig, f);
oids.put(f, oId);
final RevCommit commit = remoteGeogig.geogig.command(CommitOp.class).setMessage(f.getIdentifier().toString()).call();
expected.addFirst(commit);
Optional<RevObject> childObject = remoteGeogig.geogig.command(RevObjectParse.class).setObjectId(oId).call();
assertTrue(childObject.isPresent());
}
// Make sure the remote 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(expected, 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.setDepth(0);
clone.setRepositoryURL(remoteGeogig.envHome.getCanonicalPath()).setBranch("master").call();
logs = localGeogig.geogig.command(LogOp.class).call();
logged = new ArrayList<RevCommit>();
for (; logs.hasNext(); ) {
logged.add(logs.next());
}
assertEquals("Roads.2", logged.get(0).getMessage());
assertFalse(expected.get(0).getId().equals(logged.get(0).getId()));
assertEquals(expected.get(2).getId(), logged.get(1).getId());
assertEquals(expected.get(3).getId(), logged.get(2).getId());
}
use of org.locationtech.geogig.api.porcelain.CloneOp in project GeoGig by boundlessgeo.
the class FetchOpTest method testFetchFullDepth.
@Test
public void testFetchFullDepth() throws Exception {
prepareForFetch(false);
// clone the repository
CloneOp clone = clone();
clone.setDepth(2);
clone.setRepositoryURL(remoteGeogig.envHome.getCanonicalPath()).call();
FetchOp fetch = fetch();
fetch.setFullDepth(true);
fetch.call();
verifyFetch();
}
Aggregations