Example #1
0
        private void generateSnapshotForVCSession()
        {
            foreach (var setting in m_configurationService.VcCustomSetting.Settings.Setting)
            {
                if (setting.SettingKey == "SnapshotStartPoint")
                {
                    m_sessionLevelSnapshotTime = parseSnapShotStartPoint(setting.SettingValue);
                }
            }

            m_hwmDelta.Reload();
            if (m_hwmDelta.Value >= m_sessionLevelSnapshotTime)
            {
                // We've already passed snapshot changeset Id, just return.
                m_sessionlevelSnapshotCompleted = true;
                return;
            }

            ChangeGroup snapshotGroup = createChangeGroupForSnapshot(m_sessionLevelSnapshotTime, 0);

            m_clearCaseServer.SetConfigSpecForSnapshotStartPoint(m_sessionLevelSnapshotTime);

            try
            {
                foreach (MappingEntry mappingEntry in m_configurationService.Filters)
                {
                    if (mappingEntry.Cloak)
                    {
                        continue;
                    }
                    string localMappingPath = m_clearCaseServer.GetViewLocalPathFromServerPath(mappingEntry.Path);
                    foreach (string subDirectory in Directory.GetDirectories(localMappingPath, "*", SearchOption.AllDirectories))
                    {
                        createAddActionForSnapshot(snapshotGroup, subDirectory, true);
                    }
                    foreach (string subFile in Directory.GetFiles(localMappingPath, "*", SearchOption.AllDirectories))
                    {
                        createAddActionForSnapshot(snapshotGroup, subFile, false);
                    }
                }
            }
            finally
            {
                m_clearCaseServer.ResetConfigSpec();
            }

            snapshotGroup.Save();
            m_hwmDelta.Update(m_sessionLevelSnapshotTime);
            m_changeGroupService.PromoteDeltaToPending();
            m_sessionlevelSnapshotCompleted = true;
        }
Example #2
0
        /// <summary>
        /// 1. Read snapshot information from configuration.
        /// 2. Populate the 2 in-memory snapshot table
        /// </summary>
        private void initializeSnapshotTable()
        {
            m_hwmDelta.Reload();
            // Read snapshot information from configuration.
            foreach (MappingEntry mappingEntry in ConfigurationService.Filters)
            {
                if ((!string.IsNullOrEmpty(mappingEntry.SnapshotStartPoint)) && !mappingEntry.Cloak)
                {
                    int snapshotChangeset;
                    try
                    {
                        snapshotChangeset = int.Parse(mappingEntry.SnapshotStartPoint);

                        int peerSnapshotChangeset;
                        if (int.TryParse(mappingEntry.PeerSnapshotStartPoint, out peerSnapshotChangeset))
                        {
                            // create conversion history
                            ConversionResult convRslt = new ConversionResult(ConfigurationService.SourceId, ConfigurationService.MigrationPeer);
                            convRslt.ChangeId = mappingEntry.PeerSnapshotStartPoint;
                            convRslt.ItemConversionHistory.Add(new ItemConversionHistory(mappingEntry.SnapshotStartPoint, string.Empty, convRslt.ChangeId, string.Empty));
                            try
                            {
                                convRslt.Save(ConfigurationService.SourceId);
                            }
                            catch (System.Data.DataException)
                            {
                                // conversion history already updated
                            }
                            continue;
                        }
                    }
                    catch (Exception e)
                    {
                        throw new MigrationException(
                                  string.Format(TfsVCAdapterResource.Culture, TfsVCAdapterResource.PathSnapShotFormatError, mappingEntry.SnapshotStartPoint),
                                  e);
                    }
                    if (snapshotChangeset < m_hwmDelta.Value)
                    {
                        m_processedSnapShotChangeset.Add(mappingEntry.Path, snapshotChangeset);
                    }
                    else
                    {
                        m_unprocessedSnapshotChangeset.Add(mappingEntry.Path, snapshotChangeset);
                    }
                }
            }
        }
Example #3
0
        /// <summary>
        /// Generates the delta table.
        /// </summary>
        public override void GenerateDeltaTable()
        {
            string viewName = this.configurationService.Filters[0].Path;

            TraceManager.TraceInformation("WSSWIT:AP:GenerateDeltaTable:View - {0}", viewName);
            highWaterMarkDelta.Reload();
            GetSharePointTaskUpdates(viewName);
            highWaterMarkDelta.Update(DateTime.Now);
            changeGroupService.PromoteDeltaToPending();
        }
Example #4
0
 private void initializeDestinationTfsClient()
 {
     try
     {
         m_destinationTfs = VersionSpecificUtils.GetVersionControlServer(ConfigurationService.PeerServerUrl);
         if (m_hwmLastSyncedTfsChangeset != null)
         {
             ConfigurationService.RegisterHighWaterMarkWithSession(m_hwmLastSyncedTfsChangeset);
             m_hwmLastSyncedTfsChangeset.Reload();
             if (m_hwmLastSyncedTfsChangeset.Value < 1)
             {
                 m_hwmLastSyncedTfsChangeset.Update(1);
             }
         }
     }
     catch (Exception ex)
     {
         // The destination must be a TFS server.
         throw new MigrationException(string.Format(TfsFileSystemResources.ErrorConnectingTargetTfsServer, ex.Message), ex);
     }
 }
Example #5
0
 /// <summary>
 /// Generate the delta table.
 /// </summary>
 public override void GenerateDeltaTable()
 {
     TraceManager.TraceInformation("WSSVC:AP:GenerateDeltaTable");
     highWaterMarkDelta.Reload();
     TraceManager.TraceInformation("\tWSSVC:AP:Initial HighWaterMark {0} ", highWaterMarkDelta.Value);
     deltaTableStartTime = DateTime.Now;
     TraceManager.TraceInformation("\tWSSVC:AP:CutOff {0} ", deltaTableStartTime);
     GetSharePointUpdates();
     highWaterMarkDelta.Update(deltaTableStartTime);
     TraceManager.TraceInformation("\tWSSVC:AP:Updated HighWaterMark {0} ", highWaterMarkDelta.Value);
     changeGroupService.PromoteDeltaToPending();
 }
Example #6
0
        public override void GenerateDeltaTable()
        {
            TraceManager.TraceInformation("POC:AP:GenerateDeltaTable");
            m_hwmDelta.Reload();
            TraceManager.TraceInformation("     POC:HighWaterMark {0} ", m_hwmDelta.Value);
            deltaTableStartTime = DateTime.Now;
            TraceManager.TraceInformation("     POC:CutOff {0} ", deltaTableStartTime);

            ReadOnlyCollection <MappingEntry> filters = ConfigurationService.Filters;

            GetPocUpdates(filters[0].Path);
            m_hwmDelta.Update(deltaTableStartTime);
            m_changeGroupService.PromoteDeltaToPending();
        }
        public override bool ProceedToAnalysis(AnalysisContext analysisContext)
        {
            m_semaphoreFileTouchedTime = GetSemaphoreFileTouchedTime();
            m_hwmSemaphoreFile.Reload();

            if (m_semaphoreFileTouchedTime > m_hwmSemaphoreFile.Value)
            {
                // Persisted DateTime is rounded down to the nearest second in the DB.  Add
                // a second to the HWM to make sure we don't take changes due to shaved milliseconds.
                TimeSpan oneSecond = new TimeSpan(0, 0, 1);
                m_hwmSemaphoreFile.Update(m_semaphoreFileTouchedTime + oneSecond);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #8
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));
        }
Example #9
0
        public void GenerateDeltaTable()
        {
            try
            {
                if (!m_isLoginUserSQLEditor)
                {
                    ValidateIsSQLEditor();
                    m_isLoginUserSQLEditor = true;
                }

                // load high watermark; as for CQ, we store local time for queries
                m_hwmDelta.Reload();
                DateTime hwmDeltaValue = m_hwmDelta.Value;
                if (hwmDeltaValue.Equals(default(DateTime)))
                {
                    hwmDeltaValue = new DateTime(1900, 1, 1);
                }
                hwmDeltaValue = hwmDeltaValue.AddSeconds(-1);   // go back 1 second as we'll drop the millisec below

                m_migrationContext.CurrentHWMBaseLine = hwmDeltaValue;

                // HACK HACK HACK
                //string hwmDeltaValueStr = hwmDeltaValue.ToString("o"); // using "ISO 8601" DateTime string format
                string hwmDeltaValueStr = hwmDeltaValue.ToString("u").Replace("Z", ""); // using "ISO 8601" DateTime string format

                if (hwmDeltaValueStr.LastIndexOf('.') >= 0)
                {
                    hwmDeltaValueStr = hwmDeltaValueStr.Substring(0, hwmDeltaValueStr.LastIndexOf('.')); // drop the millisec
                }
                // HACK HACK HACK

                DateTime newHwmValue = DateTime.Now;

                foreach (CQRecordFilter filter in m_filters)
                {
                    ComputeDeltaPerRecordType(filter, hwmDeltaValueStr);
                }

                // persist results and hwm
                TraceManager.TraceInformation("Promote delta to pending.");
                m_changeGroupService.PromoteDeltaToPending();

                m_hwmDelta.Update(newHwmValue);
                TraceManager.TraceInformation("Persisted CQ HWM: {0}", ClearQuestConstants.CqRecordHwm);
                TraceManager.TraceInformation("Updated CQ HWM: {0}", newHwmValue.ToString());
            }
            catch (ClearQuestInsufficientPrivilegeException privEx)
            {
                ConflictResolutionResult rslt = UtilityMethods.HandleInsufficientPriviledgeException(privEx, m_conflictManagerService);
                if (rslt.Resolved)
                {
                    // todo: currently not expected, as we only enabled manual/skip resolution action
                }
            }
            catch (ClearQuestCOMDllNotFoundException cqComNotFoundEx)
            {
                UtilityMethods.HandleCOMDllNotFoundException(cqComNotFoundEx, ErrorManager, m_conflictManagerService);
            }
            catch (ClearQuestCOMCallException cqComCallEx)
            {
                UtilityMethods.HandleCQComCallException(cqComCallEx, ErrorManager, m_conflictManagerService);
            }
            catch (Exception ex)
            {
                ErrorManager errMgr = null;
                if (m_analysisServiceContainer != null)
                {
                    errMgr = m_analysisServiceContainer.GetService(typeof(ErrorManager)) as ErrorManager;
                }
                UtilityMethods.HandleGeneralException(ex, errMgr, m_conflictManagerService);
            }
        }
Example #10
0
        public virtual ReadOnlyCollection <LinkChangeGroup> GenerateNextLinkDeltaSlice(
            LinkService linkService,
            int maxDeltaSliceSize)
        {
            try
            {
                var linkChangeGroups = new List <LinkChangeGroup>();

                if (null == ExtractLinkChangeActionsCallback)
                {
                    return(linkChangeGroups.AsReadOnly());
                }

                // load main Highwater Mark
                m_hwmLink.Reload();
                DateTime hwmLinkValue    = m_hwmLink.Value;
                string   hwmLinkValueStr = hwmLinkValue.ToString(CultureInfo.InvariantCulture);

                // load Work Items for extracting links
                string sourceId  = m_migrationSource.UniqueId;
                string storeName = m_migrationSource.WorkItemStore.StoreName;

                // Get items based on primary Highwater Mark
                TraceManager.TraceInformation(TfsWITAdapterResources.GettingModifiedItems, sourceId, storeName);
                IEnumerable <TfsMigrationWorkItem> items = m_migrationSource.WorkItemStore.GetItems(ref hwmLinkValueStr);
                TraceManager.TraceInformation(TfsWITAdapterResources.ReceivedModifiedItems, sourceId, storeName);

                // Record the updated HWM value
                DateTime newHwmLinkValue = Convert.ToDateTime(hwmLinkValueStr, CultureInfo.InvariantCulture);

                // store to be used to analyze deleted links
                WorkItemLinkStore store = new WorkItemLinkStore(new Guid(sourceId));

                // extract links
                var inMaxDeltaSliceSize = maxDeltaSliceSize;
                foreach (TfsMigrationWorkItem tfsMigrationWorkItem in items)
                {
                    if (tfsMigrationWorkItem.WorkItem == null)
                    {
                        continue;
                    }

                    TraceManager.TraceInformation("Generating linking delta for Work Item: {0}", tfsMigrationWorkItem.WorkItem.Id.ToString());
                    var perWorkItemlinkChangeGroups = new List <LinkChangeGroup>();
                    ExtractLinkChangeActionsCallback(tfsMigrationWorkItem, perWorkItemlinkChangeGroups, store);

                    if (perWorkItemlinkChangeGroups.Count == 0)
                    {
                        TraceManager.TraceInformation("Number of links: {0}", 0);
                        continue;
                    }

                    LinkChangeGroup consolidatedLinkChangeGroup = perWorkItemlinkChangeGroups[0];
                    for (int i = 1; i < perWorkItemlinkChangeGroups.Count; ++i)
                    {
                        foreach (LinkChangeAction action in perWorkItemlinkChangeGroups[i].Actions)
                        {
                            consolidatedLinkChangeGroup.AddChangeAction(action);
                        }
                    }
                    TraceManager.TraceInformation("Number of links: {0}", consolidatedLinkChangeGroup.Actions.Count.ToString());

                    // VERY IMPORTANT: use the RelatedArtifactsStore to detect link deletion
                    store.UpdatePerItemLinkChangeGroupsByCheckingRelatedItemRecords(
                        tfsMigrationWorkItem.Uri, consolidatedLinkChangeGroup, this);

                    if (consolidatedLinkChangeGroup.Actions.Count > 0)
                    {
                        linkChangeGroups.Add(consolidatedLinkChangeGroup);
                    }
                    maxDeltaSliceSize -= consolidatedLinkChangeGroup.Actions.Count;

                    if (maxDeltaSliceSize <= 0)
                    {
                        // size limit reached - persist groups to DB
                        linkService.AddChangeGroups(linkChangeGroups);
                        linkChangeGroups.Clear();
                        maxDeltaSliceSize = inMaxDeltaSliceSize;
                    }
                }

                // persist remaining groups to DB
                linkService.AddChangeGroups(linkChangeGroups);

                // clean up the returned link change group collection
                // when the caller (toolkit) receives an empty collection, it understands there is no more
                // delta to generate for the moment, and proceeds to next phase
                linkChangeGroups.Clear();

                // update primary Highwater Mark
                m_hwmLink.Update(newHwmLinkValue);
                TraceManager.TraceInformation("Persisted WIT linking HWM: {0}", Toolkit.Constants.HwmDeltaLink);
                TraceManager.TraceInformation(TfsWITAdapterResources.UpdatedHighWatermark, hwmLinkValueStr);

                return(linkChangeGroups.AsReadOnly());
            }
            catch (Exception exception)
            {
                ErrorManager errMgr = m_serviceContainer.GetService(typeof(ErrorManager)) as ErrorManager;
                errMgr.TryHandleException(exception);
                return(new List <LinkChangeGroup>().AsReadOnly());
            }
        }
Example #11
0
        public ChangeSummary GetSummaryOfChangesSince(string lastProcessedChangeItemId, List <string> filterStrings)
        {
            ChangeSummary changeSummary = new ChangeSummary();

            changeSummary.ChangeCount = 0;
            changeSummary.FirstChangeModifiedTimeUtc = DateTime.MinValue;

            // Now find all history records for changes since the High Water Mark
            m_hwmDelta.Reload();
            DateTime since = m_hwmDelta.Value;
            List <CCHistoryRecord> historyRecordList = m_clearCaseServer.GetHistoryRecords(m_configurationService.Filters, since, false);

            long lastProcessedEventId;

            try
            {
                lastProcessedEventId = long.Parse(lastProcessedChangeItemId);
            }
            catch (FormatException)
            {
                throw new ArgumentException(String.Format(CultureInfo.InvariantCulture,
                                                          CCResources.InvalidChangeItemIdFormat, lastProcessedChangeItemId));
            }

            CCHistoryRecord nextHistoryRecordToBeMigrated = null;

            // Of all of the history records since the HWM, find the oldest one (based on EventId which increases over time)
            foreach (CCHistoryRecord historyRecord in historyRecordList)
            {
                // We only want to count history records with OperationTypes of Checkin and Rmname for the backlog,
                // not individual element operation or other operations such as mklabel that are not processed by the ClearCaseAnalysisProvider
                // *** NOTE: If the ClearCaseAnalysisProvider is changed to process other OperationTypes, this code needs to change as well ***
                // TODO: Should we create a common static list of processed OperationTypes so that there is just one place to update?
                if (historyRecord.EventId > lastProcessedEventId &&
                    (historyRecord.OperationType == OperationType.Checkin || historyRecord.OperationType == OperationType.Rmname))
                {
                    // Don't count DirectoryVersion check-in records in the backlog as these may produce false positives in the backlog
                    if (!string.Equals(historyRecord.OperationDescription, OperationDescription.DirectoryVersion, StringComparison.Ordinal))
                    {
                        changeSummary.ChangeCount++;
                        if (nextHistoryRecordToBeMigrated == null || historyRecord.EventId < nextHistoryRecordToBeMigrated.EventId)
                        {
                            nextHistoryRecordToBeMigrated = historyRecord;
                        }

                        /* Uncomment for debugging
                         * Console.WriteLine(String.Format(CultureInfo.InvariantCulture,
                         *  "CCSyncMonitorProvider including backlog item for history record: EventId: {0}, OperationType: {1}, AbsoluteVobPath: {2}, VersionTime: {3}",
                         *  historyRecord.EventId, historyRecord.OperationType, historyRecord.AbsoluteVobPath, historyRecord.VersionTime));
                         */
                    }
                }
            }

            if (nextHistoryRecordToBeMigrated != null)
            {
                changeSummary.FirstChangeModifiedTimeUtc = nextHistoryRecordToBeMigrated.VersionTime.ToUniversalTime();
            }

            return(changeSummary);
        }
        private void SetServerLinkChangeIds(List <LinkChangeAction> linkChangeActions)
        {
            if (linkChangeActions.Count == 0)
            {
                return;
            }
            m_hwmSubmittedLinkChangeId.Reload();
            long hwmSubmittedValue = m_hwmSubmittedLinkChangeId.Value;

            Dictionary <int, List <LinkChangeAction> > linkChangeActionsByLowerId = new Dictionary <int, List <LinkChangeAction> >();

            foreach (LinkChangeAction action in linkChangeActions)
            {
                int workItemIdKey = GetLowerWorkItemId(action);
                if (!linkChangeActionsByLowerId.ContainsKey(workItemIdKey))
                {
                    linkChangeActionsByLowerId.Add(workItemIdKey, new List <LinkChangeAction>());
                }
                linkChangeActionsByLowerId[workItemIdKey].Add(action);
            }

            /*
             * TraceManager.TraceVerbose(String.Format(
             *  "SetServerLinkChangeIds calling WorkItemServer.GetWorkItemLinkChanges to find Ids for {0} successful link actions starting with RowNumber {1}",
             *  linkChangeActions.Count, hwmSubmittedValue));
             */
            Stopwatch stopwatch = Stopwatch.StartNew();

            int serverLinkChangeIdsSet = 0;

            foreach (WorkItemLinkChange linkChange in WorkItemServer.GetWorkItemLinkChanges(Guid.NewGuid().ToString(), hwmSubmittedValue))
            {
                int linkChangeKey = GetLowerWorkItemId(linkChange);
                List <LinkChangeAction> actions;
                if (linkChangeActionsByLowerId.TryGetValue(linkChangeKey, out actions))
                {
                    foreach (LinkChangeAction action in actions)
                    {
                        if (LinkChangeMatchesLinkAction(linkChange, action))
                        {
                            action.ServerLinkChangeId = linkChange.RowVersion.ToString();
                            serverLinkChangeIdsSet++;
                            hwmSubmittedValue = linkChange.RowVersion;
                            // Don't break here because there could be more than one LinkChangeAction in the list that matches the WorkItemLinkChange
                            // break;
                        }
                    }
                }
            }

            stopwatch.Stop();
            TraceManager.TraceVerbose("Time to call GetWorkItemLinkChanges() and process return values: {0} seconds", stopwatch.Elapsed.TotalSeconds);

            if (serverLinkChangeIdsSet < linkChangeActions.Count)
            {
                // Look for any LinkChangeActions that did not get the ServerLinkChangeId set
                foreach (LinkChangeAction linkChangeAction in linkChangeActions)
                {
                    if (linkChangeAction.ServerLinkChangeId == null)
                    {
                        string msg = String.Format(
                            "Unable to set ServerLinkChangeId on at least one LinkChangeAction: {0} '{1}'->'{2}' ({3})",
                            linkChangeAction.ChangeActionId == WellKnownChangeActionId.Add ? "Add" : "Delete",
                            linkChangeAction.Link.SourceArtifact.Uri, linkChangeAction.Link.TargetArtifact.Uri, linkChangeAction.Link.LinkType.ReferenceName);
                        TraceManager.TraceWarning(msg);
                        break;
                    }
                }
            }

            /*
             * else
             * {
             *  TraceManager.TraceVerbose(String.Format("SetServerLinkChangeIds set values for {0} link actions ending with RowNumber {1}",
             *      serverLinkChangeIdsSet, hwmSubmittedValue));
             * }
             */

            m_hwmSubmittedLinkChangeId.Update(hwmSubmittedValue);

            TraceManager.TraceInformation("Persisted WIT linking sequence HWM: {0} (MigrationSourceId: {1})",
                                          TfsConstants.HwmSubmittedLinkChangeId, m_hwmSubmittedLinkChangeId.SourceUniqueId.ToString());
            TraceManager.TraceInformation(TfsWITAdapterResources.UpdatedHighWatermark, hwmSubmittedValue);
        }
        private void generateSnapshotForVCSession()
        {
            foreach (var setting in m_configurationService.VcCustomSetting.Settings.Setting)
            {
                if (setting.SettingKey == "SnapshotStartPoint")
                {
                    m_sessionLevelSnapshotTime = parseSnapShotStartPoint(setting.SettingValue);
                }
            }

            m_hwmDelta.Reload();
            if (m_hwmDelta.Value >= m_sessionLevelSnapshotTime)
            {
                // We've already passed snapshot changeset Id, just return.
                m_sessionlevelSnapshotCompleted = true;
                return;
            }

            ChangeGroup snapshotGroup = createChangeGroupForSnapshot(m_sessionLevelSnapshotTime, 0);

            m_clearCaseServer.SetConfigSpecForSnapshotStartPoint(m_sessionLevelSnapshotTime);

            try
            {
                foreach (MappingEntry mappingEntry in m_configurationService.Filters)
                {
                    if (mappingEntry.Cloak)
                    {
                        continue;
                    }
                    string localMappingPath = m_clearCaseServer.GetViewLocalPathFromServerPath(mappingEntry.Path);
                    foreach (string subDirectory in Directory.GetDirectories(localMappingPath, "*", SearchOption.AllDirectories))
                    {
                        string serverPath = m_clearCaseServer.GetServerPathFromViewLocalPath(subDirectory);
                        snapshotGroup.CreateAction(
                            WellKnownChangeActionId.Add,
                            new ClearCaseMigrationItem(
                                m_clearCaseServer.ViewName,
                                m_clearCaseServer.ApplicationClass.get_Element(serverPath).Version.ExtendedPath,
                                true),
                            null,
                            serverPath,
                            null,
                            null,
                            WellKnownContentType.VersionControlledFolder.ReferenceName,
                            null);
                    }
                    foreach (string subFile in Directory.GetFiles(localMappingPath, "*", SearchOption.AllDirectories))
                    {
                        string serverPath = m_clearCaseServer.GetServerPathFromViewLocalPath(subFile);
                        snapshotGroup.CreateAction(
                            WellKnownChangeActionId.Add,
                            new ClearCaseMigrationItem(
                                m_clearCaseServer.ViewName,
                                m_clearCaseServer.ApplicationClass.get_Element(serverPath).Version.ExtendedPath,
                                true),
                            null,
                            serverPath,
                            null,
                            null,
                            WellKnownContentType.VersionControlledFile.ReferenceName,
                            null);
                    }
                }
            }
            finally
            {
                m_clearCaseServer.ResetConfigSpec();
            }


            snapshotGroup.Save();
            m_hwmDelta.Update(m_sessionLevelSnapshotTime);
            m_changeGroupService.PromoteDeltaToPending();
            m_sessionlevelSnapshotCompleted = true;
        }
        private int[] getMappedSubversionChanges()
        {
            m_hwmDelta.Reload();
            Debug.Assert(m_hwmDelta.Value >= 0, "High water mark of delta table must be non-negtive");

            int latestChangeset = m_repository.GetLatestRevisionNumber();

            if (m_hwmDelta.Value >= latestChangeset)
            {
                // No new changesets on server, return.
                return(new int[0]);
            }

            int    startingChangeset = m_hwmDelta.Value + 1;
            string skipComment       = m_configurationService.GetValue <string>(Constants.SkipComment, "**NOMIGRATION**");

            var lookup = new HashSet <int>();

            foreach (var mappedPath in m_configurationManager.MappedServerPaths)
            {
                var records = m_repository.QueryHistoryRange(mappedPath, startingChangeset, latestChangeset, false);

                // Todo: Skip mirrored changes created by migration tool itself

                //Iterate across all records and filter out those records that are already in the list
                foreach (var record in records.Values)
                {
                    //check wether we alredy have this record. If this is the case, we can simply continue with the next record
                    if (lookup.Contains(record.Revision))
                    {
                        continue;
                    }

                    //The skip comment is empty. Therefore we can skip the evaluation of the skip comment
                    if (!string.IsNullOrEmpty(skipComment))
                    {
                        if (record.Comment != null && record.Comment.Contains(skipComment))
                        {
                            //The record has the skip commnet. Just print an information and resume with the next one
                            TraceManager.TraceInformation("LogRecord {0} contains the skip comment {1}", record.Revision, skipComment);
                            continue;
                        }
                    }

                    //Add the record to the hashmap. We alredy verified that this is the first record
                    lookup.Add(record.Revision);
                }
            }

            if (lookup.Count > 0)
            {
                int[] revisions = lookup.ToArray();
                Array.Sort(revisions);
                return(revisions);
            }
            else
            {
                // No new changesets are found, update the HWM as current latest
                m_hwmDelta.Update(latestChangeset);
                return(new int[0]);
            }
        }
Example #15
0
        private void queryHistory(ChangeGroupService changeGroupService)
        {
            m_hwmDelta.Reload();
            DateTime since = m_hwmDelta.Value;
            List <CCHistoryRecord> historyRecordList = m_clearCaseServer.GetHistoryRecords(m_configurationService.Filters, since, true);

            historyRecordList.Sort();

            CCVersion version;
            CCItem    currentItem                      = null;
            CCItem    previousLnItem                   = null;
            string    previousLnItemLeafName           = null;
            string    previousMkElemItemPath           = null;
            List <CCHistoryRecord> processedRecordList = new List <CCHistoryRecord>();

            foreach (CCHistoryRecord historyRecord in historyRecordList)
            {
                switch (historyRecord.OperationType)
                {
                case OperationType.Checkin:
                    version     = m_clearCaseServer.ApplicationClass.get_Version(historyRecord.VersionExtendedPath);
                    currentItem = new CCItem(version, ClearCasePath.GetVobName(historyRecord.AbsoluteVobPath));
                    if (string.Equals(historyRecord.OperationDescription, OperationDescription.Version))
                    {
                        if (ClearCasePath.Equals(previousMkElemItemPath, currentItem.AbsoluteVobPath))
                        {
                            // File version checkin following a mkelem, create an Add
                            historyRecord.AbsoluteVobPath = currentItem.AbsoluteVobPath;
                            historyRecord.ChangeAction    = WellKnownChangeActionId.Add;
                            historyRecord.IsDirectory     = version.IsDirectory;
                            processedRecordList.Add(historyRecord);
                            previousMkElemItemPath = null;
                        }
                        else
                        {
                            // File version checkin following a mkelem, create an Edit
                            historyRecord.AbsoluteVobPath = currentItem.AbsoluteVobPath;
                            historyRecord.ChangeAction    = WellKnownChangeActionId.Edit;
                            historyRecord.IsDirectory     = version.IsDirectory;
                            processedRecordList.Add(historyRecord);
                        }
                    }
                    else if (string.Equals(historyRecord.OperationDescription, OperationDescription.DirectoryVersion) &&
                             (ClearCasePath.Equals(previousMkElemItemPath, currentItem.AbsoluteVobPath)))
                    {
                        // Directory version checkin following a mkelem, create an Add
                        historyRecord.AbsoluteVobPath = currentItem.AbsoluteVobPath;
                        historyRecord.ChangeAction    = WellKnownChangeActionId.Add;
                        historyRecord.IsDirectory     = version.IsDirectory;
                        processedRecordList.Add(historyRecord);
                        previousMkElemItemPath = null;
                    }
                    break;

                case OperationType.Mkattr:
                case OperationType.Mkpool:
                case OperationType.Mkreplica:
                case OperationType.Mktype:
                    // ToDo
                    // writeHistoryRecord(historyFields);
                    break;

                case OperationType.Lnname:
                    version                = m_clearCaseServer.ApplicationClass.get_Version(historyRecord.VersionExtendedPath);
                    currentItem            = new CCItem(version, ClearCasePath.GetVobName(historyRecord.AbsoluteVobPath));
                    previousLnItem         = currentItem;
                    previousLnItemLeafName = ClearCaseEventSpec.ParseLnNameComment(historyRecord.Comment);
                    break;

                case OperationType.Mkbranch:
                    // ToDo
                    if (string.Equals(historyRecord.OperationDescription, OperationDescription.Version) ||
                        string.Equals(historyRecord.OperationDescription, OperationDescription.DirectoryVersion))
                    {
                        /*version = m_clearCaseServer.ApplicationClass.get_Version(historyRecord.VersionExtendedPath);
                         * currentItem = new CCItem(version, vob);
                         * historyRecord.AbsoluteVobPath = currentItem.AbsoluteVobPath;
                         * historyRecord.ChangeAction = WellKnownChangeActionId.Add;
                         * historyRecord.IsDirectory = version.IsDirectory;
                         * historyRecordList.Add(historyRecord);
                         * */
                    }
                    break;

                case OperationType.Mkelem:
                    if (string.Equals(historyRecord.OperationDescription, OperationDescription.DirectoryElement))
                    {
                        // Todo

                        /*if (currentState == OperationState.Initialized)
                         * {
                         *  currentState = OperationState.CreateDirectoryElement;
                         *  currentItem = new Item(historyFields[1], ItemType.Element, m_vobName);
                         * }
                         * else
                         * {
                         *  logStateTransitionError(currentState, operationType, operationDescription);
                         * }*/
                    }
                    else if (string.Equals(historyRecord.OperationDescription, OperationDescription.Branch))
                    {
                        // Todo

                        /*
                         * if ((currentState == OperationState.AddDirectoryToParent)
                         || (currentState == OperationState.CreateDirectoryElement))
                         ||{
                         || currentState = OperationState.CreateDirectoryBranch;
                         || currentItem = new Item(historyFields[1], ItemType.Branch, m_vobName);
                         ||}
                         ||else
                         ||{
                         || logStateTransitionError(currentState, operationType, operationDescription);
                         ||}
                         * */
                    }
                    else if (string.Equals(historyRecord.OperationDescription, OperationDescription.DirectoryVersion) ||
                             string.Equals(historyRecord.OperationDescription, OperationDescription.Version))
                    {
                        version                = m_clearCaseServer.ApplicationClass.get_Version(historyRecord.VersionExtendedPath);
                        currentItem            = new CCItem(version, ClearCasePath.GetVobName(historyRecord.AbsoluteVobPath));
                        previousMkElemItemPath = currentItem.AbsoluteVobPath;
                        //if (currentState == OperationState.CreateDirectoryBranch)
                        //{

                        /*version = m_clearCaseServer.ApplicationClass.get_Version(historyFields[1]);
                         * currentItem = new Item(version, vob);
                         * if (IsPathMapped(currentItem.AbsoluteVobPath) &&
                         *  IsOurChange(ClearCasePath.removeViewLocationFromVersion(version.ExtendedPath, m_clearCaseServer.ViewRootPath)))
                         * {
                         *  createMigrationAction(
                         *  version,
                         *  null,
                         *  currentItem.AbsoluteVobPath,
                         *  versionTime,
                         *  WellKnownChangeActionId.Add,
                         *  version.IsDirectory);
                         * }*/

                        // Verify the version to be 0
                        //currentState = OperationState.Initialized;
                        //}
                        //else
                        //{
                        //    logStateTransitionError(currentState, operationType, operationDescription);
                        //}
                    }
                    else
                    {
                        //logStateTransitionError(currentState, operationType, operationDescription);
                    }
                    break;

                case OperationType.Mkhlink:
                    // ToDo
                    // writeHistoryRecord(historyFields);
                    break;

                case OperationType.Mklabel:
                    break;

                case OperationType.Rmname:
                    bool   isDirectory;
                    string rmItemName = ClearCaseEventSpec.ParseRmNameComment(historyRecord.Comment, out isDirectory);
                    if (rmItemName == null)
                    {
                        TraceManager.TraceWarning(String.Format("Skipping rmname operation: Unable to determine element type from history record comment: '{0}'", historyRecord.Comment));
                        continue;
                    }
                    version     = m_clearCaseServer.ApplicationClass.get_Version(historyRecord.VersionExtendedPath);
                    currentItem = new CCItem(version, ClearCasePath.GetVobName(historyRecord.AbsoluteVobPath));
                    if (currentItem.Equals(previousLnItem))
                    {
                        historyRecord.AbsoluteVobPath     = ClearCasePath.Combine(currentItem.AbsoluteVobPath, previousLnItemLeafName);
                        historyRecord.AbsoluteVobPathFrom = ClearCasePath.Combine(currentItem.AbsoluteVobPath, rmItemName);
                        historyRecord.ChangeAction        = WellKnownChangeActionId.Rename;
                        historyRecord.IsDirectory         = isDirectory;
                        processedRecordList.Add(historyRecord);
                        previousLnItem         = null;
                        previousLnItemLeafName = null;
                        // todo, path not mapped exception
                    }
                    else
                    {
                        // delete operation
                        historyRecord.AbsoluteVobPath = ClearCasePath.Combine(currentItem.AbsoluteVobPath, rmItemName);
                        historyRecord.ChangeAction    = WellKnownChangeActionId.Delete;
                        historyRecord.IsDirectory     = isDirectory;
                        processedRecordList.Add(historyRecord);
                    }
                    break;

                case OperationType.Undefined:
                    break;

                case OperationType.Mkvob:
                // Add of Vob itself.
                // ToDo
                // writeHistoryRecord(historyFields);
                default:
                    break;
                }
            }

            reviseHistoryRecordsForRename(processedRecordList);

            m_hwmEventId.Reload();
            long lastProcessedEventId = m_hwmEventId.Value;

            foreach (CCHistoryRecord historyRecord in processedRecordList)
            {
                if (historyRecord.EventId <= lastProcessedEventId)
                {
                    // The event has been processed in previous sync.
                    TraceManager.TraceInformation("Skipping history record because the event was processed in a previous sync pass of this session");
                    continue;
                }
                if (Utils.IsOurChange(historyRecord))
                {
                    TraceManager.TraceInformation("Skipping history record because it represents a change migrated by the Integration Platform");
                    continue;
                }
                if (Utils.IsPathMapped(historyRecord.AbsoluteVobPath, m_configurationService))
                {
                    if (historyRecord.ChangeAction == WellKnownChangeActionId.Rename)
                    {
                        if (Utils.IsPathMapped(historyRecord.AbsoluteVobPathFrom, m_configurationService))
                        {
                            m_currentChangeGroup = createMigrationAction(historyRecord, historyRecord.ChangeAction);
                        }
                        else
                        {
                            // ToDo Path not mapped conflict
                            m_currentChangeGroup = createMigrationAction(historyRecord, WellKnownChangeActionId.Add);
                        }
                    }
                    else
                    {
                        m_currentChangeGroup = createMigrationAction(historyRecord, historyRecord.ChangeAction);
                    }
                }
                else
                {
                    // ToDo path not mapped conflict
                    if ((historyRecord.ChangeAction == WellKnownChangeActionId.Rename) && (Utils.IsPathMapped(historyRecord.AbsoluteVobPathFrom, m_configurationService)))
                    {
                        m_currentChangeGroup = createMigrationAction(historyRecord, WellKnownChangeActionId.Delete);
                    }
                    else
                    {
                        TraceManager.TraceWarning("Skipping history record because the path '{0}' is not mapped in a filter string", historyRecord.AbsoluteVobPath);
                    }
                }
            }
            if (m_currentChangeGroup != null)
            {
                m_currentChangeGroup.Save();
            }
            if (processedRecordList.Count > 0)
            {
                m_hwmDelta.Update(processedRecordList.Last().VersionTime);
            }
            m_changeGroupService.PromoteDeltaToPending();
        }
Example #16
0
        public ReadOnlyCollection <LinkChangeGroup> GenerateNextLinkDeltaSlice(
            LinkService linkService,
            int maxDeltaSliceSize)
        {
            try
            {
                var linkChangeGroups = new List <LinkChangeGroup>();

                if (null == ExtractLinkChangeActionsCallback)
                {
                    return(linkChangeGroups.AsReadOnly());
                }

                // load high watermark; as for CQ, we store local time for queries
                m_hwmLink.Reload();
                DateTime hwmDeltaValue = m_hwmLink.Value;
                if (hwmDeltaValue.Equals(default(DateTime)))
                {
                    hwmDeltaValue = new DateTime(1900, 1, 1);
                }
                hwmDeltaValue = hwmDeltaValue.AddSeconds(-1);           // go back 1 second as we'll drop the millisec below

                string hwmDeltaValueStr = hwmDeltaValue.ToString(m_migrationContext.CQQueryDateTimeFormat, CultureInfo.InvariantCulture);

                // record current time to update HWM after processing
                DateTime newHwmValue = CQUtilityMethods.GetTimeForNewHighWaterMark(m_migrationContext.CQTimeOffsetFromServerHistoryTimesInMinutes);

                // store to be used for analysis
                WorkItemLinkStore store = new WorkItemLinkStore(m_configurationService.SourceId);

                // extract links
                var inMaxDeltaSliceSize = maxDeltaSliceSize;
                foreach (CQRecordFilter filter in m_filters)
                {
                    CQRecordQueryBase recordQuery = CQRecordQueryFactory.CreateQuery(m_userSession, filter, hwmDeltaValueStr, this);
                    foreach (ClearQuestOleServer.OAdEntity record in recordQuery)
                    {
                        // HACK HACK
                        if (record == null)
                        {
                            continue;
                        }
                        // HACK HACK

                        string recDispName = CQWrapper.GetEntityDisplayName(record);

                        TraceManager.TraceInformation("Generating linking delta for CQ Record: {0}", recDispName);

                        var perWorkItemlinkChangeGroups = new List <LinkChangeGroup>();
                        ExtractLinkChangeActionsCallback(m_userSession, record, perWorkItemlinkChangeGroups);

                        if (perWorkItemlinkChangeGroups.Count == 0)
                        {
                            TraceManager.TraceInformation("Number of links: {0}", 0);
                            continue;
                        }

                        LinkChangeGroup consolidatedLinkChangeGroup = perWorkItemlinkChangeGroups[0];
                        for (int i = 1; i < perWorkItemlinkChangeGroups.Count; ++i)
                        {
                            foreach (LinkChangeAction action in perWorkItemlinkChangeGroups[i].Actions)
                            {
                                consolidatedLinkChangeGroup.AddChangeAction(action);
                            }
                        }
                        TraceManager.TraceInformation("Number of links: {0}", consolidatedLinkChangeGroup.Actions.Count.ToString());

                        // VERY IMPORTANT STEP: update the link delta to store
                        string hostRecMigrItemId = UtilityMethods.CreateCQRecordMigrationItemId(record);
                        store.UpdatePerItemLinkChangeGroupsByCheckingRelatedItemRecords(
                            hostRecMigrItemId, consolidatedLinkChangeGroup, this);

                        if (consolidatedLinkChangeGroup.Actions.Count > 0)
                        {
                            linkChangeGroups.Add(consolidatedLinkChangeGroup);
                        }
                        maxDeltaSliceSize -= consolidatedLinkChangeGroup.Actions.Count;

                        if (maxDeltaSliceSize <= 0)
                        {
                            // size limit reached - persist groups to DB, then empty the slice and process next slice
                            linkService.AddChangeGroups(linkChangeGroups);
                            linkChangeGroups.Clear();
                            maxDeltaSliceSize = inMaxDeltaSliceSize;
                        }
                    }
                }

                // persist remaining groups to DB
                linkService.AddChangeGroups(linkChangeGroups);

                // clean up the returned link change group collection
                // when the caller (toolkit) receives an empty collection, it understands there is no more
                // delta to generate for the moment, and proceeds to next phase
                linkChangeGroups.Clear();

                // update primary Highwater Mark
                m_hwmLink.Update(newHwmValue);
                TraceManager.TraceInformation("Persisted CQ linking HWM: {0}", ClearQuestConstants.CqLinkHwm);
                TraceManager.TraceInformation("Updated CQ linking HWM: {0}", newHwmValue.ToString());

                return(linkChangeGroups.AsReadOnly());
            }
            catch (Exception exception)
            {
                // [teyang] TODO CONFLICT HANDLING

                //MigrationConflict genericeConflict = WitGeneralConflictType.CreateConflict(exception);
                //var conflictManager = m_conflictManager.GetService(typeof(ConflictManager)) as ConflictManager;
                //Debug.Assert(null != conflictManager);
                //List<MigrationAction> resolutionActions;
                //ConflictResolutionResult resolveRslt =
                //    conflictManager.TryResolveNewConflict(conflictManager.SourceId, genericeConflict, out resolutionActions);
                //Debug.Assert(!resolveRslt.Resolved);
                TraceManager.TraceException(exception);
                return(new List <LinkChangeGroup>().AsReadOnly());
            }
        }
Example #17
0
        /// <summary>
        /// Process the change group.
        /// </summary>
        /// <param name="group"></param>
        /// <returns></returns>
        public ConversionResult ProcessChangeGroup(ChangeGroup group)
        {
            ConversionResult  rslt;
            CCBatchingContext ctx = new CCBatchingContext(m_clearCaseServer, GetChangeComment(group),
                                                          group, m_ccConfiguration.DownloadFolder, m_conflictManagementService, m_ccConfiguration, m_overrideTargetChange);

            int processedActionCount = 0;

            m_changeGroupHighWaterMark.Reload();

            if (m_changeGroupHighWaterMark.Value == group.ChangeGroupId)
            {
                // Todo get the last action id from ClearCase history
            }

            try
            {
                foreach (MigrationAction action in group.Actions)
                {
                    if (processedActionCount > 50000)
                    {
                        TraceManager.TraceInformation("Processed 50,000 actions");
                        processedActionCount = 0;
                    }

                    processedActionCount++;

                    if (action.State != ActionState.Pending)
                    {
                        continue;
                    }

                    if (action.Action == WellKnownChangeActionId.Add)
                    {
                        if (string.Equals(action.ItemTypeReferenceName, WellKnownContentType.VersionControlLabel.ReferenceName, StringComparison.Ordinal))
                        {
                            ctx.CacheLabel(action);
                        }
                        else if (string.Equals(action.ItemTypeReferenceName, WellKnownContentType.VersionControlLabelItem.ReferenceName, StringComparison.Ordinal) ||
                                 string.Equals(action.ItemTypeReferenceName, WellKnownContentType.VersionControlRecursiveLabelItem.ReferenceName, StringComparison.Ordinal))
                        {
                            ctx.CacheLabelItem(action);
                        }
                        else
                        {
                            // Todo handle branch and undelete seperately.
                            if (ClearCasePath.IsVobRoot(ClearCasePath.GetFullPath(action.Path)))
                            {
                                TraceManager.TraceWarning("Skipped the change action that creates vob itself");
                                continue;
                            }
                            ctx.AddSingleItem(action, WellKnownChangeActionId.Add);
                        }
                    }
                    else if ((action.Action == WellKnownChangeActionId.Branch) ||
                             (action.Action == WellKnownChangeActionId.BranchMerge) ||
                             (action.Action == WellKnownChangeActionId.Undelete))
                    {
                        // Todo handle branch and undelete seperately.
                        if (ClearCasePath.IsVobRoot(ClearCasePath.GetFullPath(action.Path)))
                        {
                            TraceManager.TraceWarning("Skipped the change action that creates vob itself");
                            continue;
                        }
                        ctx.AddSingleItem(action, WellKnownChangeActionId.Add);
                    }
                    else if (action.Action == WellKnownChangeActionId.Edit)
                    {
                        ctx.AddSingleItem(action, WellKnownChangeActionId.Edit);
                    }
                    else if (action.Action == WellKnownChangeActionId.Delete)
                    {
                        ctx.AddSingleItem(action, WellKnownChangeActionId.Delete);
                    }
                    else if (action.Action == WellKnownChangeActionId.Rename)
                    {
                        if (ClearCasePath.Equals(action.Path, action.FromPath))
                        {
                            // Skip case-only rename.
                            continue;
                        }
                        ctx.AddSingleItem(action, WellKnownChangeActionId.Rename);
                    }
                    else if (action.Action == WellKnownChangeActionId.Merge)
                    {
                        continue;
                    }
                    else if (action.Action == WellKnownChangeActionId.AddFileProperties)
                    {
                        ctx.AddSingleItem(action, WellKnownChangeActionId.AddFileProperties);
                    }
                }

                rslt          = new ConversionResult(m_configurationService.SourceId, m_configurationService.MigrationPeer);
                rslt.ChangeId = m_clearCaseServer.GetRelativePathFromVobAbsolutePath(ctx.Flush());
                rslt.ItemConversionHistory.Add(new ItemConversionHistory(group.Name, string.Empty, rslt.ChangeId, string.Empty));
                rslt.ContinueProcessing = true;
                m_changeGroupHighWaterMark.Update(group.ChangeGroupId);
                if (m_hwmLastSyncedTfsChangeset != null)
                {
                    m_hwmLastSyncedTfsChangeset.Update(int.Parse(group.Name));
                }
            }
            catch (Exception e)
            {
                // Undo any pending checkouts that would have been checked in by the call to ctx.Flush() if no exception occurred.
                // (If ctx.Flush() has already been called, this will just return.)
                // It will catch and log any exception as an error, but will not throw it so that the original exception is raised as the conflict.
                ctx.CancelCachedCheckouts();

                if (!(e is MigrationUnresolvedConflictException))
                {
                    TraceManager.TraceInformation("Raising generic conflict for exception: {0}", e.Message);
                    createGenericConflict(e, group);
                }

                rslt = new ConversionResult(Guid.Empty, group.SourceId);
                rslt.ContinueProcessing = false;
            }

            return(rslt);
        }