Beispiel #1
0
 /// <summary>
 /// Utility method to get the describe record for a change. Caches it on the ChangeInfo object as necessary.
 /// </summary>
 /// <param name="Perforce">The Perforce connection</param>
 /// <param name="Change">The change to query</param>
 public DescribeRecord GetDescribeRecord(PerforceConnection Perforce, ChangeInfo Change)
 {
     if (Change.CachedDescribeRecord == null)
     {
         Change.CachedDescribeRecord = Perforce.Describe(Change.Record.Number).Data;
     }
     return(Change.CachedDescribeRecord);
 }
Beispiel #2
0
        /// <summary>
        /// Tests whether a change is a code change
        /// </summary>
        /// <param name="Perforce">The Perforce connection</param>
        /// <param name="Change">The change to query</param>
        /// <returns>True if the change is a code change</returns>
        public bool ContainsAnyFileWithExtension(PerforceConnection Perforce, ChangeInfo Change, string[] Extensions)
        {
            DescribeRecord Record = GetDescribeRecord(Perforce, Change);

            foreach (DescribeFileRecord File in Record.Files)
            {
                foreach (string Extension in Extensions)
                {
                    if (File.DepotFile.EndsWith(Extension, StringComparison.OrdinalIgnoreCase))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Beispiel #3
0
        /// <summary>
        /// Find all changes PLUS all robomerge source changes
        /// </summary>
        /// <param name="Perforce">The Perforce connection to use</param>
        /// <param name="Stream">The stream to query changes from</param>
        /// <param name="PrevChange">The first change in the range to query</param>
        /// <param name="NextChange">The last change in the range to query</param>
        /// <returns>Set of changelist numbers</returns>
        IReadOnlyList <ChangeInfo> FindChanges(PerforceConnection Perforce, string Stream, int PrevChange, int NextChange)
        {
            CachedChangeInfo CachedInfo = CachedChanges.FirstOrDefault(x => x.Stream == Stream && x.PrevChange == PrevChange && x.NextChange == NextChange);

            if (CachedInfo == null)
            {
                // Query for all the changes since then
                List <ChangesRecord> ChangeRecords = Perforce.Changes(ChangesOptions.LongOutput, null, -1, ChangeStatus.Submitted, null, String.Format("{0}/...@{1},{2}", Stream, PrevChange, NextChange)).Data.ToList();

                // Figure out all the original changelists that these were merged from, and see if any of those matches with an existing issue
                List <ChangeInfo> Changes = new List <ChangeInfo>();
                foreach (ChangesRecord ChangeRecord in ChangeRecords)
                {
                    ChangeInfo Change = new ChangeInfo();
                    Change.Record = ChangeRecord;
                    Change.SourceChanges.Add(ChangeRecord.Number);
                    Changes.Add(Change);

                    Match SourceMatch = Regex.Match(ChangeRecord.Description, "^#ROBOMERGE-SOURCE: (.*)$", RegexOptions.Multiline);
                    if (SourceMatch.Success)
                    {
                        string SourceText = SourceMatch.Groups[1].Value;
                        foreach (Match ChangeMatch in Regex.Matches(SourceText, "CL\\s*(\\d+)"))
                        {
                            int SourceChange;
                            if (int.TryParse(ChangeMatch.Groups[1].Value, out SourceChange))
                            {
                                Change.SourceChanges.Add(SourceChange);
                            }
                        }
                    }
                }

                // Create the new cached info
                CachedInfo = new CachedChangeInfo()
                {
                    Stream = Stream, PrevChange = PrevChange, NextChange = NextChange, Changes = Changes
                };
                CachedChanges.Add(CachedInfo);
            }
            return(CachedInfo.Changes);
        }