Beispiel #1
0
        private void reviseNameForRename(CCHistoryRecord historyRecord, Dictionary <string, string> renameList)
        {
            if (renameList.Count == 0)
            {
                return;
            }

            string path = historyRecord.AbsoluteVobPath;

            while (!ClearCasePath.IsVobRoot(path))
            {
                if (renameList.ContainsKey(path))
                {
                    historyRecord.AbsoluteVobPath =
                        ClearCasePath.Combine(renameList[path], historyRecord.AbsoluteVobPath.Substring(path.Length));
                    break;
                }
                path = ClearCasePath.GetFolderName(path);
            }

            if (historyRecord.ChangeAction == WellKnownChangeActionId.Rename)
            {
                string fromPath = historyRecord.AbsoluteVobPathFrom;
                while (!ClearCasePath.IsVobRoot(fromPath))
                {
                    if (renameList.ContainsKey(fromPath))
                    {
                        historyRecord.AbsoluteVobPathFrom =
                            ClearCasePath.Combine(renameList[fromPath], historyRecord.AbsoluteVobPathFrom.Substring(fromPath.Length));
                        break;
                    }
                    fromPath = ClearCasePath.GetFolderName(fromPath);
                }
            }
        }
Beispiel #2
0
        private void reviseRenameList(CCHistoryRecord renameHistoryRecord, Dictionary <string, string> renameList)
        {
            bool          needToAddToRenameList     = true;
            List <string> subItemRenameToBeModified = new List <string>();

            foreach (string renameToPath in renameList.Keys)
            {
                if (ClearCasePath.Equals(renameList[renameToPath], renameHistoryRecord.AbsoluteVobPath))
                {
                    subItemRenameToBeModified.Add(renameToPath);
                    needToAddToRenameList = false;
                    continue;
                }
                if (ClearCasePath.IsSubItem(renameList[renameToPath], renameHistoryRecord.AbsoluteVobPath))
                {
                    subItemRenameToBeModified.Add(renameToPath);
                }
            }

            foreach (string subItem in subItemRenameToBeModified)
            {
                renameList[subItem] =
                    ClearCasePath.Combine(renameHistoryRecord.AbsoluteVobPathFrom, renameList[subItem].Substring(renameHistoryRecord.AbsoluteVobPath.Length));
            }

            if (needToAddToRenameList)
            {
                renameList.Add(renameHistoryRecord.AbsoluteVobPath, renameHistoryRecord.AbsoluteVobPathFrom);
            }
        }
Beispiel #3
0
 /// <summary>
 /// Detect changes checked in by CC adapter by comparing comment.
 /// </summary>
 /// <param name="comment"></param>
 /// <returns></returns>
 internal static bool IsOurChange(CCHistoryRecord historyRecord)
 {
     // Todo, change to a more robust self-change detection.
     if (historyRecord.Comment.Contains(Microsoft.TeamFoundation.Migration.Toolkit.Constants.PlatformCommentSuffixMarker))
     {
         return(true);
     }
     return(false);
 }
Beispiel #4
0
        /// <summary>
        /// Generate a CCHistoryRecord instance from a historyRow string.
        /// </summary>
        /// <param name="historyRow">A history row string returned from query history command</param>
        /// <returns>The CCHistoryRecord created or null if the creation failed.</returns>
        public static CCHistoryRecord CreateInstance(string historyRow)
        {
            if (string.IsNullOrEmpty(historyRow))
            {
                return(null);
            }

            if (historyRow.Contains("ClearCase object not found."))
            {
                TraceManager.TraceInformation("Invalid history record - {0}", historyRow);
                return(null);
            }

            string[] historyColumns =
                historyRow.Split(new string[] { ClearCaseCommandSpec.HISTORYRECORD_COLUMNDELIMINATOR }, StringSplitOptions.None);
            if (historyColumns.Length < 7)
            {
                TraceManager.TraceInformation("Wrong numbers of columns in history record - {0}", historyRow);
                return(null);
            }
            string[] strEventId =
                historyColumns[0].Split(new string[] {
                "event", ":"
            },
                                        StringSplitOptions.RemoveEmptyEntries);
            long eventId;

            if (!long.TryParse(strEventId[0], out eventId))
            {
                TraceManager.TraceInformation("Invalid event id in history record - {0}", historyRow);
                return(null);
            }

            DateTime versionTime;

            if (!DateTime.TryParse(historyColumns[5], out versionTime))
            {
                TraceManager.TraceInformation("Invalid version time in history record - {0}", historyRow);
                return(null);
            }
            CCHistoryRecord instance = new CCHistoryRecord
            {
                EventId              = eventId,
                OperationType        = Operation.GetOperationType(historyColumns[2]),
                VersionExtendedPath  = historyColumns[1],
                OperationDescription = historyColumns[3],
                VersionTime          = versionTime,
                Comment              = historyColumns[6],
                UserComment          = historyColumns[7].Trim(new char[] { '(', ')' }),
                AbsoluteVobPath      = ClearCasePath.GetAbsoluteVobPathFromVersionExtendedPath(historyColumns[1])
            };

            return(instance);
        }
Beispiel #5
0
 /// <summary>
 /// Compare CCHistoryRecord based on eventid.
 /// </summary>
 /// <param name="obj"></param>
 /// <returns></returns>
 public int CompareTo(object obj)
 {
     if (obj is CCHistoryRecord)
     {
         CCHistoryRecord otherHistoryRecord = (CCHistoryRecord)obj;
         return(this.EventId.CompareTo(otherHistoryRecord.EventId));
     }
     else
     {
         throw new ArgumentException("Object is not a CCHistoryRecord");
     }
 }
Beispiel #6
0
        private ChangeGroup createMigrationAction(CCHistoryRecord historyRecord, Guid actionId)
        {
            string versionExtendedPath;

            if (m_clearCaseServer.UsePrecreatedView)
            {
                versionExtendedPath = historyRecord.VersionExtendedPath;
            }
            else
            {
                versionExtendedPath =
                    ClearCasePath.removeViewLocationFromVersion(historyRecord.VersionExtendedPath, m_clearCaseServer.ViewRootPath);
            }
            ChangeGroup oldChangeGroup;
            ChangeGroup currentChangeGroup = m_changeGroupService.AddMigrationActionToDeltaTable(historyRecord.EventId.ToString(CultureInfo.InvariantCulture),
                                                                                                 historyRecord.Comment,
                                                                                                 null,
                                                                                                 historyRecord.EventId,
                                                                                                 actionId,
                                                                                                 new ClearCaseMigrationItem(
                                                                                                     m_ccConfiguration.GetViewName("Analysis"),
                                                                                                     versionExtendedPath,
                                                                                                     historyRecord.IsDirectory),
                                                                                                 historyRecord.AbsoluteVobPathFrom,
                                                                                                 historyRecord.AbsoluteVobPath,
                                                                                                 null,
                                                                                                 null,
                                                                                                 historyRecord.IsDirectory ? WellKnownContentType.VersionControlledFolder.ReferenceName
                : WellKnownContentType.VersionControlledFile.ReferenceName,
                                                                                                 null,
                                                                                                 historyRecord.VersionTime,
                                                                                                 out oldChangeGroup);

            m_hwmEventId.Update(historyRecord.EventId);

            if ((oldChangeGroup != null) && (oldChangeGroup != currentChangeGroup))
            {
                oldChangeGroup.Save();
                m_changeGroupService.PromoteDeltaToPending();
                m_hwmDelta.Update(historyRecord.VersionTime);
            }
            return(currentChangeGroup);
        }
Beispiel #7
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);
        }