Format a revision response. Shared between different ways to retrieve a revision (latest & with explicit revision).
431299
function returnRevision(req) {
    return (dbResult) => {
        if (dbResult.body && dbResult.body.items && dbResult.body.items.length) {
            const row = dbResult.body.items[0];
            const headers = Object.assign({}, row.headers || {}, {
                etag: mwUtil.makeETag(row.rev, row.tid),
                'content-type': row['content-type']
            });
            return {
                status: 200,
                headers,
                body: row.value
            };
        } else {
            throw new HTTPError({
                status: 404,
                body: {
                    type: 'not_found',
                    uri: req.uri,
                    method: req.method
                }
            });
        }
    };
}
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
632002
def revisions(
    request, slug, template_name='wakawaka/revisions.html', extra_context=None
):
    
    queryset = WikiPage.objects.all()
    page = get_object_or_404(queryset, slug=slug)

    template_context = {'page': page}
    template_context.update(extra_context or {})
    return render(request, template_name, template_context)
683258
def record_responsify(serializer, mimetype):
    
    def view(pid, record, code=200, headers=None, links_factory=None):
        response = current_app.response_class(
            serializer.serialize(pid, record, links_factory=links_factory),
            mimetype=mimetype)
        response.status_code = code
        response.set_etag(str(record.revision_id))
        response.last_modified = record.updated
        if headers is not None:
            response.headers.extend(headers)

        if links_factory is not None:
            add_link_header(response, links_factory(pid))

        return response

    return view
569237
def prepare_revision
      return if new_record?
      if (respond_to?(:fragments_attributes_changed) && fragments_attributes_changed) ||
        !(changed & revision_fields).empty?
        self.revision_data = revision_fields.each_with_object({}) do |field, c|
          c[field] = send("#{field}_was")
        end
      end
    end
142746
def recent_changes(request):
    """"""
    page = max(1, request.args.get("page", type=int))
    query = RevisionedPage.query.order_by(RevisionedPage.revision_id.desc())
    return Response(
        generate_template(
            "recent_changes.html",
            pagination=Pagination(query, 20, page, "Special:Recent_Changes"),
        )
    )
633713
def get_tuids_from_revision(self, revision):
        
        result = []
        URL_TO_FILES = self.hg_url / self.config.hg.branch / 'json-info' / revision
        try:
            mozobject = http.get_json(url=URL_TO_FILES, retry=RETRY)
        except Exception as e:
            Log.warning("Unexpected error trying to get file list for revision {{revision}}", cause=e)
            return None

        files = mozobject[revision]['files']

        results = self.get_tuids(files, revision)
        return results
1042728
def get(self, request, uri):
        
        uri = self.decode_uri(uri)
        revisions = cio.revisions(uri)
        revisions = [list(revision) for revision in revisions]  # Convert tuples to lists
        return self.render_to_json(revisions)
448454
def __update_action(self, revision):
        

        patch = revision.get("patch")
        if patch.get("_id"):
            del patch["_id"]

        update_response = yield self.collection.patch(revision.get("master_id"), self.__make_storeable_patch_patchable(patch))

        if update_response.get("n") == 0:
            raise RevisionNotFoundException()
1176421
def get_version(svn=False, limit=3):
    ""
    v = '.'.join([str(i) for i in VERSION[:limit]])
    if svn and limit >= 3:
        from django.utils.version import get_svn_revision
        import os
        svn_rev = get_svn_revision(os.path.dirname(__file__))
        if svn_rev:
            v = '%s.%s' % (v, svn_rev)
    return v
1367170
def _doc_rev(self, res):
        
        jstr = res.headers['X-Couchbase-Meta']
        jobj = json.loads(jstr)
        return jobj['rev']
527662
def get_remote_revision(url, branch):
    
    proc = Process("git remote revision", ["git", "ls-remote", url, "refs/heads/" + branch])

    try:
        while True:
            raw_line = proc.stdout.pop()
            line = raw_line.strip().decode('utf8')
            if not line:
                continue
            return line.split("\t")[0]
    finally:
        try:
            proc.join()
        except Exception:
            pass
1314918
def content(self):
    '''
    
    '''

    if not getattr(self, '_content', False):
      query_params = {
        'prop': 'extracts|revisions',
        'explaintext': '',
        'rvprop': 'ids'
      }
      if not getattr(self, 'title', None) is None:
         query_params['titles'] = self.title
      else:
         query_params['pageids'] = self.pageid
      request = _wiki_request(query_params)
      self._content     = request['query']['pages'][self.pageid]['extract']
      self._revision_id = request['query']['pages'][self.pageid]['revisions'][0]['revid']
      self._parent_id   = request['query']['pages'][self.pageid]['revisions'][0]['parentid']

    return self._content
642976
def create_revision(cls, id, revision, raw, api=None):
        

        api = api if api else cls._API
        extra = {'resource': cls.__name__, 'query': {
            'id': id,
            'data': raw
        }}
        logger.info('Creating app revision', extra=extra)
        app = api.post(url=cls._URL['create_revision'].format(
            id=id, revision=revision), data=raw).json()
        app_wrapper = api.get(
            url=cls._URL['get'].format(id=app['sbg:id'])).json()
        return App(api=api, **app_wrapper)
711647
def checkout(self, revision, options):
        
        rev = revision.key
        self.repo.git.checkout(rev)
649075
@Override
	protected Revision readRevision()
		throws IOException, ArticleReaderException
	{

		Revision rev = super.readRevision();
		this.readRevisionCounter++;
		return rev;
	}
376124
def get_version():
    

    if all([VERSION, UPDATED, any([isinstance(UPDATED, date), isinstance(UPDATED, datetime), ]), ]):

        return FORMAT_STRING.format(**{"version": VERSION, "updated": UPDATED, })
    elif VERSION:

        return VERSION
    elif UPDATED:

        return localize(UPDATED) if any([isinstance(UPDATED, date), isinstance(UPDATED, datetime), ]) else ""
    else:

        return ""