<p>Returns the {@link InternalDocumentRevision} for a document ID and revision ID.</p>
@param id document ID
@param rev revision ID
@return the {@code DocumentRevision} for the document and revision ID
485722
public InternalDocumentRevision lookup(String id, String rev) {
        for(DocumentRevisionNode n : sequenceMap.values()) {
            if(n.getData().getId().equals(id) && n.getData().getRevision().equals(rev)) {
                return n.getData();
            }
        }
        return null;
    }
113874
public List<String> documentIds() {
        List<String> documentIds = new ArrayList<String>();
        List<DocumentRevision> docs = CollectionUtils.newArrayList(iterator());
        for (DocumentRevision doc : docs) {
            documentIds.add(doc.getId());
        }
        return documentIds;
    }
380108
public InternalDocumentRevision getCurrentRevision() {
        for(DocumentRevisionNode n : leafs) {
            if(n.getData().isCurrent()) {
                return n.getData();
            }
        }
        throw new IllegalStateException("No current revision found.");
    }
50047
public ItemRevision getItemRevision(int itemId, int revisionId) {
		return getResourceFactory().getApiResource(
				"/item/" + itemId + "/revision/" + revisionId).get(
				ItemRevision.class);
	}
1094910
public Document getDocument(@NonNull String id) {
        if (id == null) { throw new IllegalArgumentException("id cannot be null."); }

        synchronized (lock) {
            mustBeOpen();
            try {
                return new Document((Database) this, id, false);
            }
            catch (CouchbaseLiteException ex) {
                // only 404 - Not Found error throws CouchbaseLiteException
                return null;
            }
        }
    }
321881
public function getFromRevision( Revision $revision, array $extraParams = [] ) {
		$result =
			$this->api->getRequest(
				new SimpleRequest(
					'query',
					$this->getQuery( [ 'revids' => $revision->getId() ], $extraParams )
				)
			);
		$revisions = $this->getRevisionsFromResult( array_shift( $result['query']['pages'] ) );
		$revisions->addRevision( $revision );

		return new Page(
			new PageIdentifier(
				new Title(
					$result['title'],
					$result['ns']
				),
				$result['pageid']
			),
			$revisions
		);
	}
531238
@InterfaceAudience.Public
    public String getDocumentRevisionId() {
        // Get the revision id from either the embedded document contents,
        // or the '_rev' or 'rev' value key:
        String rev = null;
        if (documentRevision != null)
            rev = documentRevision.getRevID();
        if (rev == null) {
            if (value instanceof Map) {
                Map<String, Object> mapValue = (Map<String, Object>) value;
                rev = (String) mapValue.get("_rev");
                if (rev == null) {
                    rev = (String) mapValue.get("rev");
                }
            }
        }
        return rev;
    }
1283364
function buildRevision () {
    // get id columns for primary table
    var parentIdColumn = this.model.columnName('parentId')
    var primaryIdColumn = this.model.columnName('id')
    var originalIdColumn = this.model.columnName('originalId')
    // must have original and parent ids to query revisions
    if (!originalIdColumn || !parentIdColumn) {
        return
    }
    // if this is a query by id then the logic and options are different
    if (this.args.where.id || this.args.where[primaryIdColumn]) {
        // if current revision is requested the join with self on originalId
        // and then join with self on parentId = id
        if (this.args.current) {
            // get alias to join on originalId
            var originalAlias = this.newAlias(this.table)
            // get alias to join on parent id
            var revisionAlias = this.newAlias(this.table)
            // add join on original id
            this.join.push( this.leftJoinSql(this.table, originalAlias, originalIdColumn, this.alias, originalIdColumn) )
            // add join on parent id
            this.join.push( this.leftJoinSql(this.table, revisionAlias, parentIdColumn, this.alias, primaryIdColumn) )
            // add where clause
            this.where.push( revisionAlias+'.'+this.quoteName(primaryIdColumn)+' IS NULL' )
            // get value of id where arg
            var whereIdArg = this.args.where.id || this.args.where[primaryIdColumn]
            // where must be applied to originalAlias table instead of table
            // being selected from so delete where from args and create the
            // where clause with the correct alias
            delete this.args.where.id
            delete this.args.where[primaryIdColumn]
            // add where clase with correct alias
            this.buildWhere('id', whereIdArg, originalAlias)
            // build alias for id that row was selected by
            var primaryIdColumnSelect = primaryIdColumn+'Select'
            // get column name
            var selectColumnName = this.hexId(`${originalAlias}.${this.quoteName(primaryIdColumn)}`)
            // add id being selected by to column list
            this.select.push(`LOWER(${selectColumnName}) AS ${this.quoteName(primaryIdColumnSelect)}`)
        }
        // if not selecting current revision then join with self on
        // parentId = id to check if record is current
        else if (this.args.isCurrent) {
            // get new alias for primary table
            var revisionAlias = this.newAlias(this.table)
            // add join
            this.join.push( this.leftJoinSql(this.table, revisionAlias, parentIdColumn, this.alias, primaryIdColumn) )
            // get column name
            var selectColumnName = this.hexId(`${revisionAlias}.${this.quoteName(primaryIdColumn)}`)
            // add column to select currentId
            this.select.push(`LOWER(${selectColumnName}) AS childId`)
        }
    }
    // if querying all revisions then join with self on parentId = id to check
    // if each record is current
    else if (this.args.allRevisions) {
        // get new alias for primary table
        var revisionAlias = this.newAlias(this.table)
        // add join
        this.join.push( this.leftJoinSql(this.table, revisionAlias, parentIdColumn, this.alias, primaryIdColumn) )
        // get column name
        var selectColumnName = this.hexId(`${revisionAlias}.${this.quoteName(primaryIdColumn)}`)
        // add column to select currentId
        this.select.push(`LOWER(${selectColumnName}) AS childId`)
    }
    // for non-id queries get current revision by joining with self on
    // parentId = id and only getting rows that have no children
    else {
        // get new alias for primary table
        var revisionAlias = this.newAlias(this.table)
        // add join
        this.join.push( this.leftJoinSql(this.table, revisionAlias, parentIdColumn, this.alias, primaryIdColumn) )
        // add where clause
        this.where.push(`${revisionAlias}.${this.quoteName(primaryIdColumn)} IS NULL`)
    }
}
1067803
public List<ItemRevision> getItemRevisions(int itemId) {
		return getResourceFactory().getApiResource(
				"/item/" + itemId + "/revision/").get(
				new GenericType<List<ItemRevision>>() {
				});
	}
717397
@InterfaceAudience.Public
    public Document getDocument() {
        if (getDocumentId() == null) {
            return null;
        }
        assert (database != null);
        Document document = database.getDocument(getDocumentId());
        document.loadCurrentRevisionFrom(this);
        return document;
    }
441330
public function get( $revid ){
		if( !is_int( $revid ) ) {
			throw new InvalidArgumentException( '$revid needs to be an int' );
		}
		if( $this->hasRevisionWithId( $revid ) ){
			return $this->revisions[$revid];
		}
		throw new RuntimeException( 'No such revision loaded in Revisions object' );
	}
1368790
public InternalDocumentRevision build() {
        DocumentRevisionOptions options = new DocumentRevisionOptions();
        options.sequence = sequence;
        options.docInternalId = docInternalId;
        options.deleted = deleted;
        options.current = current;
        options.parent = parent;
        options.attachments = attachments;
        return new InternalDocumentRevision(docId, revId, body, options);
    }
1249094
def get_document_revision(id)
    login! unless logged_in?
    json = <<-EOF
      {
        "session": "#{@sugar_session_id}",
        "id": "#{id}"
      }
    EOF
    json.gsub!(/^\s{6}/,'')
    SugarCRM::Response.handle(send!(:get_document_revision, json), @session)
  end
270388
private boolean saveForest(Document doc,
                               String revID,
                               Map<String, Object> properties)
            throws ForestException {
        // after insertRevision, the selected revision is inserted revision.
        // need to select current revision.
        doc.selectCurrentRev();
        // Is the new revision the winner?
        boolean isWinner = doc.getSelectedRevID().equalsIgnoreCase(revID);
        // Update the documentType:
        if (!isWinner)
            properties = ForestBridge.bodyOfSelectedRevision(doc);
        if (properties != null && properties.containsKey("type") &&
                properties.get("type") instanceof String)
            doc.setType((String) properties.get("type"));
        // save
        doc.save(maxRevTreeDepth);
        return isWinner;
    }
153510
@Override
    public List<DocumentRevision> delete(final String id)
            throws DocumentNotFoundException, DocumentStoreException {
        Misc.checkNotNull(id, "ID");
        try {
            if (id.startsWith(CouchConstants._local_prefix)) {
                String localId = id.substring(CouchConstants._local_prefix.length());
                deleteLocalDocument(localId);
                // for local documents there is no "new document" to return as the document is
                // removed rather than updated with a tombstone
                return Collections.singletonList(null);
            } else {
                return get(queue.submitTransaction(new DeleteAllRevisionsCallable(id)));
            }
        } catch (ExecutionException e) {
            // documentnotfoundexception if it was a non-existent local document
            throwCauseAs(e, DocumentNotFoundException.class);
            String message = "Failed to delete document";
            logger.log(Level.SEVERE, message, e);
            throw new DocumentStoreException(message, e.getCause());
        }
    }
735745
public String getRevision()
        throws MojoExecutionException
    {

        if ( format != null && !useScm )
        {
            return revision;
        }
        useScm = false;

        try
        {
            return this.getScmRevision();
        }
        catch ( ScmException e )
        {
            if ( !StringUtils.isEmpty( revisionOnScmFailure ) )
            {
                getLog().warn( "Cannot get the revision information from the scm repository, proceeding with "
                    + "revision of " + revisionOnScmFailure + " : \n" + e.getLocalizedMessage() );

                setDoCheck( false );
                setDoUpdate( false );

                return revisionOnScmFailure;
            }

            throw new MojoExecutionException( "Cannot get the revision information from the scm repository : \n"
                + e.getLocalizedMessage(), e );

        }

    }
390947
public static RevisionList getTopicRevisionsById(final TopicProvider topicProvider, final Integer csId) {
        final List<Revision> results = new ArrayList<Revision>();
        CollectionWrapper<TopicWrapper> topicRevisions = topicProvider.getTopic(csId).getRevisions();

        // Create the unique array from the revisions
        if (topicRevisions != null && topicRevisions.getItems() != null) {
            final List<TopicWrapper> topicRevs = topicRevisions.getItems();
            for (final TopicWrapper topicRev : topicRevs) {
                Revision revision = new Revision();
                revision.setRevision(topicRev.getRevision());
                revision.setDate(topicRev.getLastModified());
                results.add(revision);
            }

            Collections.sort(results, new EnversRevisionSort());

            return new RevisionList(csId, "Topic", results);
        } else {
            return null;
        }
    }