try { FetchOp fetch = cli.getGeogig().command(FetchOp.class); fetch.setProgressListener(cli.getProgressListener()); fetch.setAll(all).setPrune(prune).setFullDepth(fulldepth); fetch.setDepth(depth); fetch.setFetchIndexes(withIndexes); fetch.addRemote(repo); result = fetch.call(); } catch (SynchronizationException e) { switch (e.statusCode) {
for (Remote r : fetchOp.getRemotes()) { checkRestricted(r.getFetchURL());
private Collection<RefDiff> fetchRemoteData(final Repository clone, Remote remote, final int depth, final boolean cloneIndexes) { // Fetch remote data final TransferSummary fetchResults; final ProgressListener progress = getProgressListener(); fetchResults = clone.command(FetchOp.class)// .addRemote(remote)// .setDepth(depth)// .setAutofetchTags(true)// .setFetchIndexes(cloneIndexes)// .setProgressListener(progress)// .call(); Map<String, Collection<RefDiff>> changedRefs = fetchResults.getRefDiffs(); String fetchURL = remote.getFetchURL(); Collection<RefDiff> refs = changedRefs.get(fetchURL); if (refs == null) { refs = ImmutableList.of(); } return refs; }
protected @Override FetchOp fetchOp() throws RepositoryConnectionException { FetchOp fetchOp = super.fetchOp(); fetchOp.addListener(verifyFetchedIndexesListener); return fetchOp.setFetchIndexes(true); }
.addRemote(remote)// .setDepth(depth.or(0))// .setFullDepth(fullDepth)// .setAllRemotes(all)// .setFetchIndexes(includeIndexes)// .setProgressListener(getProgressListener())// .call();
@Test public void testFetchWithPrune() throws Exception { // fetch from the remote FetchOp fetch = fetchOp(); fetch.addRemote("origin").setAllRemotes(true).call(); verifyFetch(); Optional<Ref> localOriginBranch1 = getRef(localRepo, "refs/remotes/origin/Branch1"); assertTrue(localOriginBranch1.isPresent()); // Remove a branch from the remote remoteGeogig.geogig.command(BranchDeleteOp.class).setName("Branch1").call(); // fetch again fetch = fetchOp(); TransferSummary summary = fetch.setPrune(true).call(); assertSummary(summary, origin.getFetchURL(), localOriginBranch1, absent()); verifyPrune(); }
getProgressListener().started(); TransferSummary fetchResult = command(FetchOp.class).addRemote(remote).setDepth(depth.or(0)) .setFullDepth(fullDepth).setAll(all).setProgressListener(subProgress(80.f)).call();
@Test public void testFetchSpecificRemote() throws Exception { // fetch from the remote FetchOp fetch = fetchOp(); TransferSummary summary = fetch.addRemote("upstream").call(); assertEquals(1, summary.getRefDiffs().size()); assertTrue(summary.getRefDiffs().containsKey(upstream.getFetchURL())); assertSummary(summary, upstream.getFetchURL(), absent(), upstreamMaster); assertSummary(summary, upstream.getFetchURL(), absent(), upstreamTag); assertSummary(summary, upstream.getFetchURL(), absent(), upstreamBranch1); TestSupport.verifySameContents(upstreamRepo, localRepo); }
@Test public void testFetchSingleRef() throws Exception { final Repository remote = this.originRepo; final Repository local = this.localRepo; remote.command(BranchCreateOp.class).setName("branch2").setAutoCheckout(true).call(); insertAndAdd(remote, lines1_modified, lines2_modified, lines3_modified); RevCommit branch2Tip = commit(remote, "modified lines on branch2"); checkout(remote, "master"); remote.command(BranchCreateOp.class).setName("branch3").setAutoCheckout(true).call(); insertAndAdd(remote, points1_modified, points2_modified, points3_modified); RevCommit branch3Tip = commit(remote, "modified points on branch3"); checkout(remote, "master"); Optional<Ref> originBranch2 = Optional .of(toRemote(origin, getRef(remote, "branch2").get())); // fetch from the remote FetchOp fetch = fetchOp().setAutofetchTags(false); Remote singleRefOrigin = origin.fetch("refs/heads/branch2"); TransferSummary summary = fetch.addRemote(singleRefOrigin).call(); assertFalse(getRef(local, "refs/heads/branch2").isPresent()); assertTrue(getRef(local, "refs/remotes/origin/branch2").isPresent()); assertFalse(getRef(local, "branch3").isPresent()); assertEquals(branch2Tip.getId(), getRef(local, "refs/remotes/origin/branch2").get().getObjectId()); assertEquals(1, summary.getRefDiffs().size()); assertTrue(summary.getRefDiffs().containsKey(origin.getFetchURL())); assertEquals(1, summary.getRefDiffs().get(origin.getFetchURL()).size()); assertSummary(summary, origin.getFetchURL(), absent(), originBranch2); TestSupport.verifyRepositoryContents(local, "refs/remotes/origin/branch2"); }
@Test public void testFetchFullDepthWithFullRepo() throws Exception { prepareForFetch(true); FetchOp fetch = fetchOp(); fetch.setFullDepth(true); fetch.call(); verifyFetch(); }
@Test public void testFetchSpecificRemoteAndAll() throws Exception { // fetch from the remote FetchOp fetch = fetchOp(); TransferSummary summary = fetch.addRemote("upstream").setAll(true).call(); assertEquals(2, summary.getRefDiffs().size()); assertTrue(summary.getRefDiffs().containsKey(origin.getFetchURL())); assertTrue(summary.getRefDiffs().containsKey(upstream.getFetchURL())); assertSummary(summary, origin.getFetchURL(), localOriginMaster, originMaster); assertSummary(summary, origin.getFetchURL(), absent(), originBranch1); assertSummary(summary, origin.getFetchURL(), absent(), originTag); assertSummary(summary, upstream.getFetchURL(), absent(), upstreamMaster); assertSummary(summary, upstream.getFetchURL(), absent(), upstreamBranch1); verifyFetch(); }
command.getClientData().put(remote.getFetchURL(), repo1); command.setAllRemotes(true)// .setFetchIndexes(false)// NOT FETCHING INDEXES INITIALLY .call(); command.getClientData().put(remote.getFetchURL(), repo1); TransferSummary ts = command.setAllRemotes(true)// .setFetchIndexes(true)// BUT FETCHING AFTERWARDS, SHOULD GET THEM ALL .call(); verifyFetchedIndexes(command, ts);
@Test public void testFetchNoArgsDefaultsToOrigin() throws Exception { // fetch from the remote FetchOp fetch = fetchOp(); TransferSummary summary = fetch.call(); assertNotNull(summary); assertEquals(1, summary.getRefDiffs().size()); assertTrue(summary.getRefDiffs().containsKey(origin.getFetchURL())); assertSummary(summary, origin.getFetchURL(), localOriginMaster, originMaster); assertSummary(summary, origin.getFetchURL(), absent(), originBranch1); assertSummary(summary, origin.getFetchURL(), absent(), originTag); verifyFetch(); }
private void fakeUpToDate() { Remote remote = request.buildRemote(); GeogigTransaction tx = request.getTransaction(origin.getRepo().context()); tx.command(FetchOp.class).setFetchIndexes(true).addRemote(remote).call(); Ref remoteBranchState = clone.getRef(request.getRemoteBranch()); Ref localRemoteBranchState = tx.command(RefParse.class).setName(request.getOriginRef()) .call().get(); assertEquals(remoteBranchState.getObjectId(), localRemoteBranchState.getObjectId()); } }
private Collection<RefDiff> fetchRemoteData(final Repository clone, final Remote remote, final int depth) { // Fetch remote data final TransferSummary fetchResults; final String remoteName = remote.getName(); final ProgressListener progress = getProgressListener(); fetchResults = clone.command(FetchOp.class)// .addRemote(remoteName)// .setDepth(depth)// .setProgressListener(progress)// .call(); Map<String, Collection<RefDiff>> changedRefs = fetchResults.getRefDiffs(); String fetchURL = remote.getFetchURL(); Collection<RefDiff> refs = changedRefs.get(fetchURL); if (refs == null) { refs = ImmutableList.of(); } return refs; }
@Test public void testFetchAll() throws Exception { // fetch from the remote FetchOp fetch = fetchOp(); TransferSummary summary = fetch.setAll(true).call(); assertEquals(2, summary.getRefDiffs().size()); assertTrue(summary.getRefDiffs().containsKey(origin.getFetchURL())); assertTrue(summary.getRefDiffs().containsKey(upstream.getFetchURL())); assertSummary(summary, origin.getFetchURL(), localOriginMaster, originMaster); assertSummary(summary, origin.getFetchURL(), absent(), originBranch1); assertSummary(summary, origin.getFetchURL(), absent(), originTag); assertSummary(summary, upstream.getFetchURL(), absent(), upstreamMaster); assertSummary(summary, upstream.getFetchURL(), absent(), upstreamBranch1); verifyFetch(); }
@Test public void testFetchSpecificRemoteAndAll() throws Exception { // fetch from the remote FetchOp fetch = fetchOp(); TransferSummary summary = fetch.addRemote("upstream").setAllRemotes(true).call(); assertEquals(2, summary.getRefDiffs().size()); assertTrue(summary.getRefDiffs().containsKey(origin.getFetchURL())); assertTrue(summary.getRefDiffs().containsKey(upstream.getFetchURL())); assertSummary(summary, origin.getFetchURL(), localOriginMaster, originMaster); assertSummary(summary, origin.getFetchURL(), absent(), originBranch1); assertSummary(summary, origin.getFetchURL(), absent(), originTag); assertSummary(summary, upstream.getFetchURL(), absent(), upstreamMaster); assertSummary(summary, upstream.getFetchURL(), absent(), upstreamBranch1); verifyFetch(); }