def _query_for_diff(review_request, user, revision, draft):
 if revision:
  revision = int(revision)
 if (draft and draft.diffset_id and ((revision is None) or (draft.diffset.revision == revision))):
  return draft.diffset
 query = Q(history=review_request.diffset_history_id)
 if (revision is not None):
  query = (query & Q(revision=revision))
 try:
  return DiffSet.objects.filter(query).latest()
 except DiffSet.DoesNotExist:
  raise Http404

def _query_for_diff ( review_request , user , revision , draft ) : if revision : revision = int ( revision ) if ( draft and draft . diffset_id and ( ( revision is None ) or ( draft . diffset . revision == revision ) ) ) : return draft . diffset query = Q ( history = review_request . diffset_history_id ) if ( revision is not None ) : query = ( query & Q ( revision = revision ) ) try : return DiffSet . objects . filter ( query ) . latest ( ) except DiffSet . DoesNotExist : raise Http404
queries for a diff based on several parameters .