PerforceChangeSummary TryParseChangeSummary(string Line) { string[] Tokens = Line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (Tokens.Length == 7 && Tokens[0] == "Change" && Tokens[2] == "on" && Tokens[5] == "by") { PerforceChangeSummary Change = new PerforceChangeSummary(); if (int.TryParse(Tokens[1], out Change.Number) && DateTime.TryParse(Tokens[3] + " " + Tokens[4], out Change.Date)) { int UserClientIdx = Tokens[6].IndexOf('@'); if (UserClientIdx != -1) { Change.User = Tokens[6].Substring(0, UserClientIdx); Change.Client = Tokens[6].Substring(UserClientIdx + 1); return(Change); } } } return(null); }
public bool FindChanges(IEnumerable <string> Filters, int MaxResults, out List <PerforceChangeSummary> Changes, TextWriter Log) { string Arguments = "changes -s submitted -t -L"; if (MaxResults > 0) { Arguments += String.Format(" -m {0}", MaxResults); } foreach (string Filter in Filters) { Arguments += String.Format(" \"{0}\"", Filter); } List <string> Lines; if (!RunCommand(Arguments, out Lines, CommandOptions.None, Log)) { Changes = null; return(false); } Changes = new List <PerforceChangeSummary>(); for (int Idx = 0; Idx < Lines.Count; Idx++) { PerforceChangeSummary Change = TryParseChangeSummary(Lines[Idx]); if (Change == null) { Log.WriteLine("Couldn't parse description from '{0}'", Lines[Idx]); } else { StringBuilder Description = new StringBuilder(); for (; Idx + 1 < Lines.Count; Idx++) { if (Lines[Idx + 1].Length == 0) { Description.AppendLine(); } else if (Lines[Idx + 1].StartsWith("\t")) { Description.AppendLine(Lines[Idx + 1].Substring(1)); } else { break; } } Change.Description = Description.ToString().Trim(); Changes.Add(Change); } } Changes = Changes.GroupBy(x => x.Number).Select(x => x.First()).OrderByDescending(x => x.Number).ToList(); if (MaxResults >= 0 && MaxResults < Changes.Count) { Changes.RemoveRange(MaxResults, Changes.Count - MaxResults); } return(true); }
bool ShouldShowChange(PerforceChangeSummary Change) { if(String.Compare(Change.User, "buildmachine", true) == 0 && Change.Description.IndexOf("lightmaps", StringComparison.InvariantCultureIgnoreCase) == -1) { return false; } return true; }
private void CloseProject() { UpdateTimer.Stop(); BuildList.Items.Clear(); BuildList.Groups.Clear(); SelectedFileName = null; SelectedProjectIdentifier = null; BranchDirectoryName = null; EditorTargetName = null; if(NotificationWindow != null) { NotificationWindow.Dispose(); NotificationWindow = null; } if(PerforceMonitor != null) { PerforceMonitor.Dispose(); PerforceMonitor = null; } if(Workspace != null) { Workspace.Dispose(); Workspace = null; } if(EventMonitor != null) { EventMonitor.Dispose(); EventMonitor = null; } ListIndexToChangeIndex = new List<int>(); SortedChangeNumbers = new List<int>(); NumChanges = 0; ContextMenuChange = null; HoverItem = -1; PendingSelectedChangeNumber = -1; NotifiedBuildTypeToChangeNumber = new Dictionary<string,int>(); SyncLog.CloseFile(); SyncLog.Clear(); UpdateBuildSteps(); StatusPanel.SetProjectLogo(null); UpdateStatusPanel(); Taskbar.SetState(Handle, TaskbarState.NoProgress); }
private void BuildList_MouseClick(object Sender, MouseEventArgs Args) { if(Args.Button == MouseButtons.Left) { ListViewHitTestInfo HitTest = BuildList.HitTest(Args.Location); if(HitTest.Item != null) { PerforceChangeSummary Change = (PerforceChangeSummary)HitTest.Item.Tag; if(Workspace.PendingChangeNumber == Change.Number) { Rectangle SubItemRect = HitTest.Item.SubItems[StatusColumn.Index].Bounds; if(Workspace.IsBusy()) { Rectangle CancelRect = new Rectangle(SubItemRect.Right - 16, SubItemRect.Top, 16, SubItemRect.Height); Rectangle InfoRect = new Rectangle(SubItemRect.Right - 32, SubItemRect.Top, 16, SubItemRect.Height); if(CancelRect.Contains(Args.Location)) { CancelWorkspaceUpdate(); } else if(InfoRect.Contains(Args.Location) && !Splitter.IsLogVisible()) { ToggleLogVisibility(); } } else { Rectangle HappyRect = new Rectangle(SubItemRect.Right - 32, SubItemRect.Top, 16, SubItemRect.Height); Rectangle FrownRect = new Rectangle(SubItemRect.Right - 16, SubItemRect.Top, 16, SubItemRect.Height); if(HappyRect.Contains(Args.Location)) { EventMonitor.PostEvent(Change.Number, EventType.Good); BuildList.Invalidate(); } else if(FrownRect.Contains(Args.Location)) { EventMonitor.PostEvent(Change.Number, EventType.Bad); BuildList.Invalidate(); } } } else { Rectangle SyncBadgeRectangle = GetSyncBadgeRectangle(HitTest.Item.SubItems[StatusColumn.Index].Bounds); if(SyncBadgeRectangle.Contains(Args.Location) && CanSyncChange(Change.Number)) { StartSync(Change.Number); } } if(CISColumn.Index < HitTest.Item.SubItems.Count && HitTest.Item.SubItems[CISColumn.Index] == HitTest.SubItem) { EventSummary Summary = EventMonitor.GetSummaryForChange(Change.Number); if(Summary != null) { Tuple<BuildData, Rectangle>[] Badges = LayoutBadges(Summary.Builds, HitTest.SubItem.Bounds); for(int Idx = 0; Idx < Badges.Length; Idx++) { if(Badges[Idx].Item2.Contains(Args.Location)) { Process.Start(Badges[Idx].Item1.Url); break; } } } } } } else if(Args.Button == MouseButtons.Right) { ListViewHitTestInfo HitTest = BuildList.HitTest(Args.Location); if(HitTest.Item != null && HitTest.Item.Tag != null) { ContextMenuChange = (PerforceChangeSummary)HitTest.Item.Tag; BuildListContextMenu_WithdrawReview.Visible = (EventMonitor.GetReviewByCurrentUser(ContextMenuChange.Number) != null); BuildListContextMenu_StartInvestigating.Visible = !EventMonitor.IsUnderInvestigationByCurrentUser(ContextMenuChange.Number); BuildListContextMenu_FinishInvestigating.Visible = EventMonitor.IsUnderInvestigation(ContextMenuChange.Number); string CommentText; bool bHasExistingComment = EventMonitor.GetCommentByCurrentUser(ContextMenuChange.Number, out CommentText); BuildListContextMenu_LeaveComment.Visible = !bHasExistingComment; BuildListContextMenu_EditComment.Visible = bHasExistingComment; bool bIsBusy = Workspace.IsBusy(); bool bIsCurrentChange = (ContextMenuChange.Number == Workspace.CurrentChangeNumber); BuildListContextMenu_Sync.Visible = !bIsBusy; BuildListContextMenu_Sync.Font = new Font(SystemFonts.MenuFont, bIsCurrentChange? FontStyle.Regular : FontStyle.Bold); BuildListContextMenu_SyncContentOnly.Visible = !bIsBusy && ShouldSyncPrecompiledEditor; BuildListContextMenu_SyncOnlyThisChange.Visible = !bIsBusy && !bIsCurrentChange && ContextMenuChange.Number > Workspace.CurrentChangeNumber && Workspace.CurrentChangeNumber != -1; BuildListContextMenu_Build.Visible = !bIsBusy && bIsCurrentChange && !ShouldSyncPrecompiledEditor && OptionsContextMenu_UseIncrementalBuilds.Checked; BuildListContextMenu_Rebuild.Visible = !bIsBusy && bIsCurrentChange && !ShouldSyncPrecompiledEditor; BuildListContextMenu_GenerateProjectFiles.Visible = !bIsBusy && bIsCurrentChange; BuildListContextMenu_LaunchEditor.Visible = !bIsBusy && ContextMenuChange.Number == Workspace.CurrentChangeNumber; BuildListContextMenu_LaunchEditor.Font = new Font(SystemFonts.MenuFont, FontStyle.Bold); BuildListContextMenu_OpenVisualStudio.Visible = !bIsBusy && bIsCurrentChange; BuildListContextMenu_Cancel.Visible = bIsBusy; EventSummary Summary = EventMonitor.GetSummaryForChange(ContextMenuChange.Number); bool bStarred = (Summary != null && Summary.LastStarReview != null && Summary.LastStarReview.Type == EventType.Starred); BuildListContextMenu_AddStar.Visible = !bStarred; BuildListContextMenu_RemoveStar.Visible = bStarred; bool bIsTimeColumn = (HitTest.Item.SubItems.IndexOf(HitTest.SubItem) == TimeColumn.Index); BuildListContextMenu_TimeZoneSeparator.Visible = bIsTimeColumn; BuildListContextMenu_ShowLocalTimes.Visible = bIsTimeColumn; BuildListContextMenu_ShowLocalTimes.Checked = Settings.bShowLocalTimes; BuildListContextMenu_ShowServerTimes.Visible = bIsTimeColumn; BuildListContextMenu_ShowServerTimes.Checked = !Settings.bShowLocalTimes; BuildListContextMenu.Show(BuildList, Args.Location); } } }
PerforceChangeSummary TryParseChangeSummary(string Line) { string[] Tokens = Line.Split(new char[]{ ' ' }, StringSplitOptions.RemoveEmptyEntries); if(Tokens.Length == 7 && Tokens[0] == "Change" && Tokens[2] == "on" && Tokens[5] == "by") { PerforceChangeSummary Change = new PerforceChangeSummary(); if(int.TryParse(Tokens[1], out Change.Number) && DateTime.TryParse(Tokens[3] + " " + Tokens[4], out Change.Date)) { int UserClientIdx = Tokens[6].IndexOf('@'); if(UserClientIdx != -1) { Change.User = Tokens[6].Substring(0, UserClientIdx); Change.Client = Tokens[6].Substring(UserClientIdx + 1); return Change; } } } return null; }