code: private void createVersion(Node fileNode, InputStream inputStream, String autoVersion, List<String> mixins) throws RepositoryException
     {
        if (!fileNode.isNodeType(VersionHistoryUtils.MIX_VERSIONABLE))
        {
           if (fileNode.canAddMixin(VersionHistoryUtils.MIX_VERSIONABLE))
           {
              fileNode.addMixin(VersionHistoryUtils.MIX_VERSIONABLE);
              fileNode.getSession().save();
           }
           if (!(CHECKIN_CHECKOUT.equals(autoVersion)))
           {
              fileNode.checkin();
              fileNode.getSession().save();
           }
        }
        if (CHECKIN_CHECKOUT.equals(autoVersion))
        {
           fileNode.checkin();
           fileNode.checkout();
           fileNode.getSession().save();
           updateContent(fileNode, inputStream, mixins);
           fileNode.getSession().save();
        }
        else
        {
           createVersion(fileNode, inputStream, mixins);
        }
     }
docs: Creates the new version of file.
  
  @param fileNode file node
  @param inputStream input stream that contains the content of file
  @param autoVersion auto-version value
  @param mixins list of mixins
  @throws RepositoryException {@link RepositoryException}