Ejemplo n.º 1
0
 /// <summary>
 /// Compare two CCItem object by VobExtededePath and
 /// </summary>
 /// <param name="obj"></param>
 /// <returns></returns>
 public override bool Equals(object obj)
 {
     if (obj == null)
     {
         return(false);
     }
     else
     {
         CCItem otherItem = (CCItem)obj;
         if (otherItem == null)
         {
             return(false);
         }
         return((otherItem.VersionExtendedPath == VersionExtendedPath) &&
                (otherItem.ItemType == ItemType));
     }
 }
Ejemplo n.º 2
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();
        }