This whole block is seemingly equivalent to

    glstate.depthTest.enable();
    glstate.depthFunc.set(GL_ALWAYS); 
    glstate.depthWrite.set((depthMask || !gstate.isDepthTestEnabled()) ? GL_TRUE : GL_FALSE); 

Which is almost the same as before, except that depthWrite is not set to false if depth testing is disabled, even if the depth mask bit is not set. Interesting.