Esempio n. 1
0
        /// <summary>
        /// Generate the delta table
        /// </summary>
        public void GenerateDeltaTable()
        {
            // Load the current high water mark from any previous run of this session
            m_hwmDelta.Reload();

            m_renameList        = null;
            m_renameListUpdated = false;

            // Removing the in-progress change groups created by this side (fils system)
            m_changeGroupService.RemoveInProgressChangeGroups();

            if (m_changeGroupService.GetInProgressMigrationInstructionCount() > 0)
            {
                // If there are in-progress migration instructions translated from the other side, mark this delta table as contentcon flict detection only.
                m_contentConflictDetectionOnly = true;
                TraceManager.TraceInformation("Migration instruction in progress, the delta table will be generated for content conflict detection only");
            }
            else
            {
                m_contentConflictDetectionOnly = false;
            }

            DateTime newHighWaterMarkTime = DateTime.Now;

            List <String> pathsToBeVerified = new List <String>();
            int           versionToBeSynced = 0;

            // In a two-way sync, versionToBeSynced is set to the last sync point - either the latest changeset migrated from TFS or the latest changeset migrated to TFS
            // In one way sync, versionToBeSynced is always set to the GetLatestChangesetId of TFS
            if (m_hwmLastSyncedTfsChangeset != null)
            {
                // m_hwmLastSyncedTfsChangeset is the latest TFS changeset migrated to the file system side.
                // This highwater mark will be set when TfsFileSystemAnalysisProvider is combined with another provider to form a two-way sync.
                m_hwmLastSyncedTfsChangeset.Reload();
                // m_lastHighWaterMarkMigratedToPeer is the latest TFS changeset migrated from this TfsFileSystemAnalysisProvider.
                m_lastHighWaterMarkMigratedToPeer.Reload();
                versionToBeSynced = m_lastHighWaterMarkMigratedToPeer.Value > m_hwmLastSyncedTfsChangeset.Value ?
                                    m_lastHighWaterMarkMigratedToPeer.Value : m_hwmLastSyncedTfsChangeset.Value;
            }
            else
            {
                versionToBeSynced = m_destinationTfs.GetLatestChangesetId();
            }

            FileSystemVerifier fileSystemVerifier = new FileSystemVerifier();

            ChangeGroup changeGroup = m_changeGroupService.CreateChangeGroupForDeltaTable(DateTime.Now.ToString());

            populateChangeGroupMetaData(changeGroup);

            foreach (MappingEntry m in ConfigurationService.Filters)
            {
                if (m.Cloak)
                {
                    continue;
                }
                string canonicalPath = removeTrailingSlash(m.Path);
                fileSystemVerifier.AddPathForVerification(canonicalPath);
                analyzeFolder(canonicalPath, versionToBeSynced, changeGroup);
            }

            if (!fileSystemVerifier.Verify())
            {
                TraceManager.TraceError(
                    "Analysis failed as the local file system state was changed during the analysis phase. No changes were created.");
                markChangeGroupAsObsolete(changeGroup);
                return;
            }

            if (changeGroup.Actions.Count > 0)
            {
                // We only want to promote deltas to pending if we actually created and saved a change group.
                changeGroup.Save();
                m_changeGroupService.PromoteDeltaToPending();
            }
            else
            {
                markChangeGroupAsObsolete(changeGroup);
            }

            m_lastTfsChangesetAnalyzed.Update(versionToBeSynced);
            m_hwmDelta.Update(newHighWaterMarkTime);
            TraceManager.TraceInformation(String.Format(CultureInfo.InvariantCulture,
                                                        TfsFileSystemResources.UpdatedHighWaterMark, newHighWaterMarkTime));
        }