Using a central repository for common code makes too much sense, especially as you are refactoring anyway. Cut and paste can lead to dozens or hundreds of almost like scripts, customized in unique ways for unique circumstances. It will always be easier to manage a single set of libraries whose differences are driven by a configuration file than it will to have hundreds of unique-but-almost-alike scripts whose differences are probably unknown.
And if location Z must have some unique code, that location can still inherit modules from the main repository.