private void renameSymbol(Program oldProgram, Symbol oldSymbol, Program newProgram,
			Symbol newSymbol)
			throws DuplicateNameException, InvalidInputException, CircularDependencyException {
		SourceType source = newSymbol.getSource();
		String newName = newSymbol.getName();
		Address addressInOldProgram =
			SimpleDiffUtility.getCompatibleAddress(newProgram, newSymbol.getAddress(), oldProgram);
		Namespace namespaceInOldProgram =
			DiffUtility.getNamespace(newSymbol.getParentNamespace(), oldProgram);
		if (namespaceInOldProgram == null) {
			throw new InvalidInputException("Couldn't get namespace '" +
				newSymbol.getParentNamespace().toString() + "' in result program.");
		}
		SymbolTable oldSymTab = oldProgram.getSymbolTable();
		Symbol existingSymbol =
			oldSymTab.getSymbol(newName, addressInOldProgram, namespaceInOldProgram);
		if (oldSymbol == existingSymbol) {
			return; // Already has correct name and scope.
		}

		// rename and then set namespace.
		String oldName = oldSymbol.getName();
		Namespace oldNamespace = oldSymbol.getParentNamespace();
		boolean nameChanged = !newName.equals(oldName);
		boolean scopeChanged = namespaceInOldProgram != oldNamespace;
		String tempName = null;
		if (nameChanged) {
			try {
				oldSymbol.setName(newName, source);
			}
			catch (DuplicateNameException e) {
				// Just transitioning so use a temporary name.
				tempName = ProgramMerge.getUniqueName(oldSymTab, newName, addressInOldProgram,
					oldNamespace, namespaceInOldProgram, oldSymbol.getSymbolType());
				if (tempName == null) {
					throw e;
				}
				oldSymbol.setName(tempName, source);
			}
		}
		if (scopeChanged) {
			oldSymbol.setNamespace(namespaceInOldProgram);
		}
		// Fix the name back up.
		if (tempName != null) {
			try {
				oldSymbol.setName(newName, source);
			}
			catch (DuplicateNameException e) {
				if (!tempName.equals(newName)) {
					renamedConflictIDs.add(oldSymbol.getID());
				}
			}
		}
	}
Renames the oldSymbol to have a name and namespace equivalent to that of the newSymbol.
@param oldProgram the program containing the old symbol
@param oldSymbol the old symbol
@param newProgram the program containing the new symbol
@param newSymbol the new symbol
@throws DuplicateNameException
@throws InvalidInputException
@throws CircularDependencyException
Ghidra/Features/Base/src/main/java/ghidra/app/merge/listing/SymbolMerger.java