bool UpdateChanges() { // Get the current status of the build int MaxChanges; int OldestChangeNumber = -1; int NewestChangeNumber = -1; HashSet <int> CurrentChangelists; SortedSet <int> PrevPromotedChangelists; lock (this) { MaxChanges = PendingMaxChanges; if (Changes.Count > 0) { NewestChangeNumber = Changes.First().Number; OldestChangeNumber = Changes.Last().Number; } CurrentChangelists = new HashSet <int>(Changes.Select(x => x.Number)); PrevPromotedChangelists = new SortedSet <int>(PromotedChangeNumbers); } // Build a full list of all the paths to sync List <string> DepotPaths = new List <string>(); if (SelectedClientFileName.EndsWith(".uprojectdirs", StringComparison.InvariantCultureIgnoreCase)) { DepotPaths.Add(String.Format("{0}/...", BranchClientPath)); } else { DepotPaths.Add(String.Format("{0}/*", BranchClientPath)); DepotPaths.Add(String.Format("{0}/Engine/...", BranchClientPath)); DepotPaths.Add(String.Format("{0}/...", PerforceUtils.GetClientOrDepotDirectoryName(SelectedClientFileName))); if (bIsEnterpriseProject) { DepotPaths.Add(String.Format("{0}/Enterprise/...", BranchClientPath)); } } // Read any new changes List <PerforceChangeSummary> NewChanges; if (MaxChanges > CurrentMaxChanges) { if (!Perforce.FindChanges(DepotPaths, MaxChanges, out NewChanges, LogWriter)) { return(false); } } else { if (!Perforce.FindChanges(DepotPaths.Select(DepotPath => String.Format("{0}@>{1}", DepotPath, NewestChangeNumber)), -1, out NewChanges, LogWriter)) { return(false); } } // Remove anything we already have NewChanges.RemoveAll(x => CurrentChangelists.Contains(x.Number)); // Update the change ranges if (NewChanges.Count > 0) { OldestChangeNumber = Math.Max(OldestChangeNumber, NewChanges.Last().Number); NewestChangeNumber = Math.Min(NewestChangeNumber, NewChanges.First().Number); } // If we are using zipped binaries, make sure we have every change since the last zip containing them. This is necessary for ensuring that content changes show as // syncable in the workspace view if there have been a large number of content changes since the last code change. int MinZippedChangeNumber = -1; foreach (int ChangeNumber in ChangeNumberToZippedBinaries.Keys) { if (ChangeNumber > MinZippedChangeNumber && ChangeNumber <= OldestChangeNumber) { MinZippedChangeNumber = ChangeNumber; } } if (MinZippedChangeNumber != -1 && MinZippedChangeNumber < OldestChangeNumber) { List <PerforceChangeSummary> ZipChanges; if (Perforce.FindChanges(DepotPaths.Select(DepotPath => String.Format("{0}@{1},{2}", DepotPath, MinZippedChangeNumber, OldestChangeNumber - 1)), -1, out ZipChanges, LogWriter)) { NewChanges.AddRange(ZipChanges); } } // Fixup any ROBOMERGE authors const string RoboMergePrefix = "#ROBOMERGE-AUTHOR:"; foreach (PerforceChangeSummary Change in NewChanges) { if (Change.Description.StartsWith(RoboMergePrefix)) { int StartIdx = RoboMergePrefix.Length; while (StartIdx < Change.Description.Length && Change.Description[StartIdx] == ' ') { StartIdx++; } int EndIdx = StartIdx; while (EndIdx < Change.Description.Length && !Char.IsWhiteSpace(Change.Description[EndIdx])) { EndIdx++; } if (EndIdx > StartIdx) { Change.User = Change.Description.Substring(StartIdx, EndIdx - StartIdx); Change.Description = "ROBOMERGE: " + Change.Description.Substring(EndIdx).TrimStart(); } } } // Process the new changes received if (NewChanges.Count > 0 || MaxChanges < CurrentMaxChanges) { // Insert them into the builds list lock (this) { Changes.UnionWith(NewChanges); if (Changes.Count > MaxChanges) { // Remove changes to shrink it to the max requested size, being careful to avoid removing changes that would affect our ability to correctly // show the availability for content changes using zipped binaries. SortedSet <PerforceChangeSummary> TrimmedChanges = new SortedSet <PerforceChangeSummary>(new PerforceChangeSorter()); foreach (PerforceChangeSummary Change in Changes) { TrimmedChanges.Add(Change); if (TrimmedChanges.Count >= MaxChanges && (ChangeNumberToZippedBinaries.Count == 0 || ChangeNumberToZippedBinaries.ContainsKey(Change.Number) || ChangeNumberToZippedBinaries.First().Key > Change.Number)) { break; } } Changes = TrimmedChanges; } CurrentMaxChanges = MaxChanges; } // Find the last submitted change by the current user int NewLastChangeByCurrentUser = -1; foreach (PerforceChangeSummary Change in Changes) { if (String.Compare(Change.User, Perforce.UserName, StringComparison.InvariantCultureIgnoreCase) == 0) { NewLastChangeByCurrentUser = Math.Max(NewLastChangeByCurrentUser, Change.Number); } } LastChangeByCurrentUser = NewLastChangeByCurrentUser; // Notify the main window that we've got more data if (OnUpdate != null) { OnUpdate(); } } return(true); }
bool UpdateChanges() { // Get the current status of the build int MaxChanges; int OldestChangeNumber = -1; int NewestChangeNumber = -1; HashSet <int> CurrentChangelists; SortedSet <int> PrevPromotedChangelists; lock (this) { MaxChanges = PendingMaxChanges; if (Changes.Count > 0) { NewestChangeNumber = Changes.First().Number; OldestChangeNumber = Changes.Last().Number; } CurrentChangelists = new HashSet <int>(Changes.Select(x => x.Number)); PrevPromotedChangelists = new SortedSet <int>(PromotedChangeNumbers); } // Build a full list of all the paths to sync List <string> DepotPaths = new List <string>(); if (SelectedClientFileName.EndsWith(".uprojectdirs", StringComparison.InvariantCultureIgnoreCase)) { DepotPaths.Add(String.Format("{0}/...", BranchClientPath)); } else { DepotPaths.Add(String.Format("{0}/*", BranchClientPath)); DepotPaths.Add(String.Format("{0}/Engine/...", BranchClientPath)); DepotPaths.Add(String.Format("{0}/...", PerforceUtils.GetClientOrDepotDirectoryName(SelectedClientFileName))); } // Read any new changes List <PerforceChangeSummary> NewChanges; if (MaxChanges > CurrentMaxChanges) { if (!Perforce.FindChanges(DepotPaths, MaxChanges, out NewChanges, LogWriter)) { return(false); } } else { if (!Perforce.FindChanges(DepotPaths.Select(DepotPath => String.Format("{0}@>{1}", DepotPath, NewestChangeNumber)), -1, out NewChanges, LogWriter)) { return(false); } } // Remove anything we already have NewChanges.RemoveAll(x => CurrentChangelists.Contains(x.Number)); // Update the change ranges if (NewChanges.Count > 0) { OldestChangeNumber = Math.Max(OldestChangeNumber, NewChanges.Last().Number); NewestChangeNumber = Math.Min(NewestChangeNumber, NewChanges.First().Number); } // Fixup any ROBOMERGE authors const string RoboMergePrefix = "#ROBOMERGE-AUTHOR:"; foreach (PerforceChangeSummary Change in NewChanges) { if (Change.Description.StartsWith(RoboMergePrefix)) { int StartIdx = RoboMergePrefix.Length; while (StartIdx < Change.Description.Length && Change.Description[StartIdx] == ' ') { StartIdx++; } int EndIdx = StartIdx; while (EndIdx < Change.Description.Length && !Char.IsWhiteSpace(Change.Description[EndIdx])) { EndIdx++; } if (EndIdx > StartIdx) { Change.User = Change.Description.Substring(StartIdx, EndIdx - StartIdx); Change.Description = "ROBOMERGE: " + Change.Description.Substring(EndIdx).TrimStart(); } } } // Process the new changes received if (NewChanges.Count > 0 || MaxChanges < CurrentMaxChanges) { // Insert them into the builds list lock (this) { Changes.UnionWith(NewChanges); while (Changes.Count > MaxChanges) { Changes.Remove(Changes.Last()); } CurrentMaxChanges = MaxChanges; } // Find the last submitted change by the current user int NewLastChangeByCurrentUser = -1; foreach (PerforceChangeSummary Change in Changes) { if (String.Compare(Change.User, Perforce.UserName, StringComparison.InvariantCultureIgnoreCase) == 0) { NewLastChangeByCurrentUser = Math.Max(NewLastChangeByCurrentUser, Change.Number); } } LastChangeByCurrentUser = NewLastChangeByCurrentUser; // Notify the main window that we've got more data if (OnUpdate != null) { OnUpdate(); } } return(true); }
bool UpdateChanges() { // Get the current status of the build int MaxChanges; int OldestChangeNumber = -1; int NewestChangeNumber = -1; HashSet <int> CurrentChangelists; SortedSet <int> PrevPromotedChangelists; lock (this) { MaxChanges = PendingMaxChanges; if (Changes.Count > 0) { NewestChangeNumber = Changes.First().Number; OldestChangeNumber = Changes.Last().Number; } CurrentChangelists = new HashSet <int>(Changes.Select(x => x.Number)); PrevPromotedChangelists = new SortedSet <int>(PromotedChangeNumbers); } // Build a full list of all the paths to sync List <string> DepotPaths = new List <string>(); if (SelectedClientFileName.EndsWith(".uprojectdirs", StringComparison.InvariantCultureIgnoreCase)) { DepotPaths.Add(String.Format("{0}/...", BranchClientPath)); } else { DepotPaths.Add(String.Format("{0}/*", BranchClientPath)); DepotPaths.Add(String.Format("{0}/Engine/...", BranchClientPath)); DepotPaths.Add(String.Format("{0}/...", PerforceUtils.GetClientOrDepotDirectoryName(SelectedClientFileName))); } // Read any new changes List <PerforceChangeSummary> NewChanges; if (MaxChanges > CurrentMaxChanges) { if (!Perforce.FindChanges(DepotPaths, MaxChanges, out NewChanges, LogWriter)) { return(false); } } else { if (!Perforce.FindChanges(DepotPaths.Select(DepotPath => String.Format("{0}@>{1}", DepotPath, NewestChangeNumber)), -1, out NewChanges, LogWriter)) { return(false); } } // Remove anything we already have NewChanges.RemoveAll(x => CurrentChangelists.Contains(x.Number)); // Update the change ranges if (NewChanges.Count > 0) { OldestChangeNumber = Math.Max(OldestChangeNumber, NewChanges.Last().Number); NewestChangeNumber = Math.Min(NewestChangeNumber, NewChanges.First().Number); } // Insert them into the builds list if (NewChanges.Count > 0 || MaxChanges < CurrentMaxChanges) { lock (this) { Changes.UnionWith(NewChanges); while (Changes.Count > MaxChanges) { Changes.Remove(Changes.Last()); } CurrentMaxChanges = MaxChanges; } if (OnUpdate != null) { OnUpdate(); } } return(true); }