@Override
	public boolean applyTo(Program program, TaskMonitor monitor) {
		monitor.setMessage("ApplyDiffTask starting...");
		applied = false;
		final ProgramLocation origLocation = plugin.getProgramLocation();
		if (!plugin.isTaskInProgress()) {

			plugin.setTaskInProgress(true);
			String statusMsg = "One or more differences couldn't be applied.";
			title = "Program Diff: One or more differences couldn't be applied.";
			applyMsg = null;
			setStatusMsg(null);
			try {
				AutoAnalysisManager autoAnalysisManager =
					AutoAnalysisManager.getAnalysisManager(plugin.getFirstProgram());
				boolean merged = autoAnalysisManager.scheduleWorker(this, null, false, monitor);
				if (merged) {
					statusMsg = "Apply differences has finished." +
						" If your expected change didn't occur, check your Diff Apply Settings.";
					title = "Program Diff: Apply differences has finished.";
					applied = true;
				}
				else {
					applyMsg = diffControl.getApplyMessage();
				}
			}
			catch (InterruptedException e) {
				applyMsg = "Unexpected InterruptedException\n" + diffControl.getApplyMessage();
			}
			catch (InvocationTargetException e) {
				Throwable t = e.getCause();
				String message = "";
				// Protect against dereferencing the getCause call above, which may return null.
				if (t != null) {
					String excMessage = t.getMessage();
					if (excMessage != null && excMessage.length() > 0) {
						message = excMessage + "\n";
					}
				}
				Msg.showError(this, plugin.getListingPanel(), "Error Applying Diff",
					"An error occurred while applying differences.\n" +
						"Only some of the differences may have been applied.",
					(t != null) ? t : e);
				applyMsg = message + diffControl.getApplyMessage();
			}
			catch (CancelledException e) {
				statusMsg = "User cancelled \"Apply Differences\". " +
					"Differences were only partially applied.";
				applyMsg = diffControl.getApplyMessage();
			}
			finally {
				setStatusMsg(statusMsg);
				plugin.getTool().setStatusInfo(statusMsg);
				plugin.setTaskInProgress(false);

				Runnable r = new Runnable() {
					@Override
					public void run() {
						plugin.adjustDiffDisplay();
						plugin.firePluginEvent(new ProgramSelectionPluginEvent(plugin.getName(),
							plugin.getCurrentSelection(), plugin.getCurrentProgram()));
						plugin.programLocationChanged(origLocation, null);
						if (applyMsg != null && applyMsg.length() > 0) {
							ReadTextDialog detailsDialog = new ReadTextDialog(title, applyMsg);
							plugin.getTool().showDialog(detailsDialog, plugin.getListingPanel());
						}
					}
				};
//				// The events were disabled while doing apply Diff. Now re-enable them by firing object restored event.
//				((DomainObjectAdapter)currentProgram).fireEvent(new DomainObjectChangeRecord(
//									DomainObjectEvent.RESTORED));
//				((DomainObjectAdapter)currentProgram).flushEvents();
				if (!monitor.isCancelled()) {
					SwingUtilities.invokeLater(r);
				}
			}
		}
		return applied;
	}
Command to apply diffs to current program.
Ghidra/Features/ProgramDiff/src/main/java/ghidra/app/plugin/core/diff/ApplyDiffCommand.java