public @Override <T extends AbstractGeoGigOp<?>> T command(Class<T> commandClass) { T command = context.command(commandClass); command.setContext(this); return command; }
/** * @return a list of all the feature type names in the working tree * @see FindFeatureTypeTrees */ @Override public List<NodeRef> getFeatureTypeTrees() { List<NodeRef> typeTrees = context.command(FindFeatureTypeTrees.class) .setRootTreeRef(Ref.WORK_HEAD).call(); return typeTrees; }
/** * Returns true if there are no unstaged changes, false otherwise */ public boolean isClean() { Optional<ObjectId> head; Optional<ObjectId> stageHead; head = context.command(ResolveTreeish.class).setTreeish(Ref.HEAD).call(); stageHead = context.command(ResolveTreeish.class).setTreeish(Ref.STAGE_HEAD).call(); return head.equals(stageHead); }
private WorkingTree callAdd() { final AddOp addOp = context.command(AddOp.class); addOp.setProgressListener(getProgressListener()); return addOp.call(); }
/** * @param pathFilter if specified, only changes that match the filter will be returned * @return the number differences between STAGE_HEAD and HEAD based on the path filter. */ @Override public DiffObjectCount countStaged(final @Nullable List<String> pathFilters) { DiffObjectCount count = context.command(DiffCount.class).setOldVersion(Ref.HEAD) .setNewVersion(Ref.STAGE_HEAD).setFilter(pathFilters).call(); return count; }
/** * Updates the WORK_HEAD ref to the specified tree. * * @param newTree the tree to be set as the new WORK_HEAD */ @Override public synchronized ObjectId updateWorkHead(ObjectId newTree) { context.command(UpdateRef.class).setName(Ref.WORK_HEAD).setNewValue(newTree).call(); return newTree; }
/** * @param pathFilter if specified, only changes that match the filter will be counted * @return the number differences between the work tree and the index based on the path filter. */ @Override public DiffObjectCount countUnstaged(final @Nullable String pathFilter) { DiffObjectCount count = context.command(DiffCount.class).setOldVersion(Ref.STAGE_HEAD) .setNewVersion(Ref.WORK_HEAD).addFilter(pathFilter).call(); return count; }
public void commit(ProgressListener listener) throws ConflictsException { context.command(TransactionEnd.class).setAuthor(authorName.orNull(), authorEmail.orNull()) .setTransaction(this).setCancel(false).setRebase(true).setProgressListener(listener) .call(); }
public TestData resumeTransaction(UUID transactionId) { checkState(transaction == null, "There's a transaction already running"); Optional<GeogigTransaction> tx = getContext().command(TransactionResolve.class) .setId(transactionId).call(); checkState(tx.isPresent(), "Transaction %s does not exist", transactionId); setTransaction(tx.get()); return this; }
public TestData add() { getContext().command(AddOp.class).call(); return this; }
public TestData startTransaction() { checkState(transaction == null, "There's a transaction already running"); GeogigTransaction tx = getContext().command(TransactionBegin.class).call(); setTransaction(tx); return this; }
public TestData branch(String newBranch) { Ref ref = getContext().command(BranchCreateOp.class).setName(newBranch).call(); checkState(newBranch.equals(ref.localName())); return this; }
public TestData branch(String newBranch) { Ref ref = getContext().command(BranchCreateOp.class).setName(newBranch).call(); checkState(newBranch.equals(ref.localName())); return this; }
private TestData commit(String commitMessage, boolean allowEmpty) { RevCommit commit = getContext().command(CommitOp.class).setAllowEmpty(allowEmpty) .setMessage(commitMessage).call(); LOG.debug(commit.toString()); return this; }
public TestData checkout(String branch) { getContext().command(CheckoutOp.class).setSource(branch).call(); Ref head = getContext().command(RefParse.class).setName(Ref.HEAD).call().get(); if (head instanceof SymRef) { String target = ((SymRef) head).getTarget(); head = getContext().command(RefParse.class).setName(target).call().get(); } String headBranch = head.localName(); checkState(branch.equals(headBranch), "expected %s, got %s", branch, headBranch); return this; }
public TestData mergeNoFF(String branchToMerge, String mergeCommitMessage) { ObjectId branchHead = getContext().command(RefParse.class).setName(branchToMerge).call() .get().getObjectId(); MergeReport report = getContext().command(MergeOp.class).setNoFastForward(true) .setMessage(mergeCommitMessage).addCommit(branchHead).call(); RevCommit mergeCommit = report.getMergeCommit(); checkState(mergeCommit.getParentIds().size() == 2); LOG.debug(mergeCommit.toString()); return this; }
private ImportOp getImportOp(DataStore dataStore) { final ImportOp importOp = context.command(ImportOp.class); return importOp.setDataStore(dataStore).setTable(table).setAll(all).setOverwrite(!add) .setAdaptToDefaultFeatureType(!forceFeatureType).setAlter(alter) .setDestinationPath(dest).setFidAttribute(fidAttribute); }
private ImportOp getImportOp(DataStore dataStore) { final ImportOp importOp = context.command(ImportOp.class); return importOp.setDataStore(dataStore).setTable(table).setAll(all).setOverwrite(!add) .setAdaptToDefaultFeatureType(!forceFeatureType).setAlter(alter) .setDestinationPath(dest).setFidAttribute(fidAttribute); }
public Map<String, RevFeatureType> getFeatureTypes(@NonNull String rootTreeIsh) { Context context = getContext(); List<NodeRef> treeNodes = context.command(FindFeatureTypeTrees.class) .setRootTreeRef(rootTreeIsh).call(); Iterator<RevFeatureType> types = context.objectDatabase().getAll( Iterables.transform(treeNodes, n -> n.getMetadataId()), BulkOpListener.NOOP_LISTENER, RevFeatureType.class); return Maps.uniqueIndex(types, t -> t.getName().getLocalPart()); }
@Test public void testSimple() { RevTree tree = createTree("blob"); NodeRef child = NodeRef.tree("subtree", tree.getId(), ObjectId.NULL); RevTree newRoot = context.command(UpdateTree.class).setRoot(RevTree.EMPTY).setChild(child) .call(); assertTrue(odb.exists(newRoot.getId())); Optional<NodeRef> ref = new DepthSearch(odb).find(newRoot.getId(), "subtree"); assertTrue(ref.isPresent()); assertEquals(child, ref.get()); }