public TrackingConfig MergeTrackingConfigs(
            IExecutionContext executionContext,
            TrackingConfig newConfig,
            TrackingConfig previousConfig)
        {
            Trace.Entering();

            TrackingConfig mergedConfig = previousConfig.Clone();

            // Update the sources directory if we don't have one
            if (!string.IsNullOrEmpty(mergedConfig.SourcesDirectory))
            {
                mergedConfig.SourcesDirectory = newConfig.SourcesDirectory;
            }

            // Fill out repository type if it's not there.
            // repository type is a new property introduced for maintenance job
            if (string.IsNullOrEmpty(mergedConfig.RepositoryType))
            {
                mergedConfig.RepositoryType = newConfig.RepositoryType;
            }

            if (string.IsNullOrEmpty(mergedConfig.CollectionUrl))
            {
                mergedConfig.CollectionUrl = newConfig.CollectionUrl;
            }

            return(previousConfig);
        }
        public TrackingConfig MergeTrackingConfigs(
            IExecutionContext executionContext,
            TrackingConfig newConfig,
            TrackingConfig previousConfig,
            bool overrideBuildDirectory
            )
        {
            /*
             * (Temporarily till we have automatic tests coverage for this case) for any changes in this method - please make sure to test following scenarios:
             * - Self-hosted agent + several sequential pipeline runs for the same repos set - make sure that Build.SourcesDirectory is set properly after last checkout
             */
            ArgUtil.NotNull(newConfig, nameof(newConfig));
            ArgUtil.NotNull(previousConfig, nameof(previousConfig));

            Trace.Entering();

            TrackingConfig mergedConfig = previousConfig.Clone();

            // Update the sources directory if we don't have one
            if (string.IsNullOrEmpty(mergedConfig.SourcesDirectory))
            {
                mergedConfig.SourcesDirectory = newConfig.SourcesDirectory;
            }

            if (overrideBuildDirectory)
            {
                mergedConfig.BuildDirectory = newConfig.BuildDirectory;
            }

            // Fill out repository type if it's not there.
            // repository type is a new property introduced for maintenance job
            if (string.IsNullOrEmpty(mergedConfig.RepositoryType))
            {
                mergedConfig.RepositoryType = newConfig.RepositoryType;
            }

            if (string.IsNullOrEmpty(mergedConfig.CollectionUrl))
            {
                mergedConfig.CollectionUrl = newConfig.CollectionUrl;
            }

            return(mergedConfig);
        }