public void createNewVersion(ManagedBufferFile destFile, String fileComment,
			TaskMonitor monitor) throws CancelledException, IOException {

		if (monitor != null) {
			monitor.checkCancelled();
			monitor.setMessage("Opening versioned file for update...");
			monitor.setProgress(0);
		}
		ManagedBufferFile outFile = destFile.getSaveFile();
		if (outFile == null) {
			throw new IOException("File update not permitted");
		}

		boolean success = false;
		BufferFile newChangeFile = null;
		BufferFile changeDataFile = null;
		try {
			if (monitor != null) {
				monitor.checkCancelled();
				monitor.setMessage("Creating new file version...");
			}
			outFile.setVersionComment(fileComment);

			changeDataFile = getNextChangeDataFile(true);
			if (changeDataFile == null) {
				throw new IOException("Unexpected state for check-in file");
			}

			BufferFile nextChangeDataFile = getNextChangeDataFile(false);
			if (nextChangeDataFile != null) {
				nextChangeDataFile.dispose();
				throw new IOException("Unexpected state for check-in file");
			}

			// Create new version
			ChangeMap newChangeMap = new ChangeMap(getForwardModMapData());
			copyFile(this, outFile, newChangeMap, monitor);

			// Copy change data
			newChangeFile = destFile.getSaveChangeDataFile();
			copyFile(changeDataFile, newChangeFile, null, monitor);

			newChangeFile.close(); // commit and close newChangeFile
			newChangeFile = null;  // null indicates closed state

			success = true;
		}
		finally {
			if (changeDataFile != null) {
				changeDataFile.dispose();
			}
			if (newChangeFile != null) {
				newChangeFile.dispose();
			}
			try {
				destFile.saveCompleted(success);
			}
			finally {
				outFile.dispose();
			}
		}
	}
Create a new buffer file version (used for check-in) 
@param destFile must be an versioned file representing an earlier version
of srcFile.
@param fileComment a comment for the new version.
@param monitor the current monitor.
@throws CancelledException if the operation is canceled.
@throws IOException if the file is in an unexpected state.
Ghidra/Framework/DB/src/main/java/db/buffers/LocalManagedBufferFile.java