示例#1
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();
        }
示例#2
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);
        }
示例#3
0
        public override Dictionary <string, string> GetRenameList()
        {
            if (!m_ccConfiguration.QueryRenameHistory)
            {
                return(null);
            }
            m_hwmDelta.Reload();
            DateTime since = m_hwmDelta.Value;
            List <ClearCaseDetailedHistoryAdapter.CCHistoryRecord> historyRecordList = m_clearCaseServer.GetHistoryRecords(m_configurationService.Filters, since, true);

            historyRecordList.Sort();

            CCVersion version;
            CCItem    currentItem            = null;
            CCItem    previousLnItem         = null;
            string    previousLnItemLeafName = null;
            bool      isDirectory;
            List <ClearCaseDetailedHistoryAdapter.CCHistoryRecord> processedRecordList = new List <ClearCaseDetailedHistoryAdapter.CCHistoryRecord>();
            Dictionary <string, string> renameList = new Dictionary <string, string>();

            foreach (ClearCaseDetailedHistoryAdapter.CCHistoryRecord historyRecord in historyRecordList)
            {
                switch (historyRecord.OperationType)
                {
                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.Rmname:
                    string rmItemName = ClearCaseEventSpec.ParseRmNameComment(historyRecord.Comment, out isDirectory);
                    version     = m_clearCaseServer.ApplicationClass.get_Version(historyRecord.VersionExtendedPath);
                    currentItem = new CCItem(version, ClearCasePath.GetVobName(historyRecord.AbsoluteVobPath));
                    if (currentItem.Equals(previousLnItem))
                    {
                        string renameTo   = ClearCasePath.Combine(currentItem.AbsoluteVobPath, previousLnItemLeafName);
                        string renameFrom = ClearCasePath.Combine(currentItem.AbsoluteVobPath, rmItemName);
                        addEntryToRenameList(renameList, renameFrom, renameTo);
                        previousLnItem         = null;
                        previousLnItemLeafName = null;
                    }
                    break;

                default:
                    break;
                }
            }
            return(renameList);
        }