code: public static Map<String, Object> revisionHistoryToJson(List<InternalDocumentRevision> history,
                                                              Map<String, ? extends Attachment> attachments,
                                                              boolean shouldInline,
                                                              int minRevPos) {
          Misc.checkNotNull(history, "History");
          Misc.checkArgument(history.size() > 0, "History must have at least one DocumentRevision.");
          Misc.checkArgument(checkHistoryIsInDescendingOrder(history),
                  "History must be in descending order.");
  
          InternalDocumentRevision currentNode = history.get(0);
  
          Map<String, Object> m = currentNode.asMap();
          if (attachments != null && !attachments.isEmpty()) {
              // graft attachments on to m for this particular revision here
              addAttachments(attachments, m, shouldInline, minRevPos);
          }
  
          m.put(CouchConstants._revisions, createRevisions(history));
  
          return m;
      }
docs: <p>Serialise a branch's revision history, in the form of a list of
  {@link InternalDocumentRevision}s, into the JSON format expected by CouchDB's _bulk_docs
  endpoint.</p>
  
  @param history list of {@code DocumentRevision}s. This should be a complete list
  from the revision furthest down the branch to the root.
  @param attachments list of {@code Attachment}s, if any. This allows the {@code _attachments}
  dictionary to be correctly serialised. If there are no attachments, set
  to null.
  @param shouldInline whether to upload attachments inline or separately via multipart/related.
  @param minRevPos generation number of most recent ancestor on the remote database. If the
  {@code revpos} value of a given attachment is greater than {@code minRevPos},
  then it is newer than the version on the remote database and must be sent.
  Otherwise, a stub can be sent.
  @return JSON-serialised {@code String} suitable for sending to CouchDB's
  _bulk_docs endpoint.
  
  @see DocumentRevs