static NodeStateEx create(
InternalVersionManagerBase vMgr, NodeStateEx parent, Name name,
NodeState nodeState, NodeId copiedFrom) throws RepositoryException {
// create history node
NodeId historyId = new NodeId();
NodeStateEx pNode = parent.addNode(name, NameConstants.NT_VERSIONHISTORY, historyId, true);
// set the versionable uuid
String versionableUUID = nodeState.getNodeId().toString();
pNode.setPropertyValue(NameConstants.JCR_VERSIONABLEUUID, InternalValue.create(versionableUUID));
// create label node
pNode.addNode(NameConstants.JCR_VERSIONLABELS, NameConstants.NT_VERSIONLABELS, null, false);
// initialize the 'jcr:copiedFrom' property
if (copiedFrom != null) {
pNode.setPropertyValue(NameConstants.JCR_COPIEDFROM, InternalValue.create(copiedFrom, true));
}
// create root version
NodeId versionId = new NodeId();
NodeStateEx vNode = pNode.addNode(NameConstants.JCR_ROOTVERSION, NameConstants.NT_VERSION, versionId, true);
// initialize 'created' and 'predecessors'
vNode.setPropertyValue(NameConstants.JCR_CREATED, InternalValue.create(getCurrentTime()));
vNode.setPropertyValues(NameConstants.JCR_PREDECESSORS, PropertyType.REFERENCE, InternalValue.EMPTY_ARRAY);