How is the node revision ID getting updated?
drupal_write_record handles that.

vid is the primary key on the node_revision table, as declared in node_schema, and drupal_write_record knows that because it introspects the schema when writing the record.

From there it just takes the ID returned from the database query, and populates the correct property on the object that was passed in. In this case, that's the vid property on the node object.