public bool TryGetChangeType(int Number, out PerforceChangeType Type) { lock (this) { return(ChangeTypes.TryGetValue(Number, out Type)); } }
public bool UpdateChangeTypes() { // Get the minimum change we need to query bool bRequiresUpdate; lock (this) { bRequiresUpdate = Changes.Any(x => !ChangeTypes.ContainsKey(x.Number)); } // If there's something to check for, find all the content changes after this changelist if (bRequiresUpdate) { string[] CodeExtensions = { ".cs", ".h", ".cpp" }; // Find all the content changes in this range. Include a few extra changes in case there have been more changes submitted since the last query (it seems -m is much faster than specifying a changelist range) List <PerforceChangeSummary> CodeChanges; if (!Perforce.FindChanges(CodeExtensions.Select(Extension => String.Format("{0}/...{1}", BranchClientPath, Extension)), CurrentMaxChanges + 10, out CodeChanges, LogWriter)) { return(false); } // Update the change types HashSet <int> CodeChangeNumbers = new HashSet <int>(CodeChanges.Select(x => x.Number)); lock (this) { foreach (PerforceChangeSummary Change in Changes) { if (!ChangeTypes.ContainsKey(Change.Number)) { PerforceChangeType Type = CodeChangeNumbers.Contains(Change.Number)? PerforceChangeType.Code : PerforceChangeType.Content; ChangeTypes.Add(Change.Number, Type); } } } // Find the last submitted code change by the current user int NewLastCodeChangeByCurrentUser = -1; foreach (PerforceChangeSummary Change in Changes) { if (String.Compare(Change.User, Perforce.UserName, StringComparison.InvariantCultureIgnoreCase) == 0) { PerforceChangeType Type; if (ChangeTypes.TryGetValue(Change.Number, out Type) && Type == PerforceChangeType.Code) { NewLastCodeChangeByCurrentUser = Math.Max(NewLastCodeChangeByCurrentUser, Change.Number); } } } LastCodeChangeByCurrentUser = NewLastCodeChangeByCurrentUser; // Notify the main window that we've got an update if (OnUpdateMetadata != null) { OnUpdateMetadata(); } } return(true); }