public void Save() { // General settings ConfigSection GeneralSection = ConfigFile.FindOrAddSection("General"); GeneralSection.Clear(); GeneralSection.SetValue("BuildAfterSync", bBuildAfterSync); GeneralSection.SetValue("RunAfterSync", bRunAfterSync); GeneralSection.SetValue("SyncPrecompiledEditor", bSyncPrecompiledEditor); GeneralSection.SetValue("OpenSolutionAfterSync", bOpenSolutionAfterSync); GeneralSection.SetValue("ShowLogWindow", bShowLogWindow); GeneralSection.SetValue("AutoResolveConflicts", bAutoResolveConflicts); GeneralSection.SetValue("IncrementalBuilds", bUseIncrementalBuilds); GeneralSection.SetValue("ShowUnreviewed", bShowUnreviewedChanges); GeneralSection.SetValue("ShowAutomated", bShowAutomatedChanges); GeneralSection.SetValue("ShowLocalTimes", bShowLocalTimes); if (LastProject != null) { GeneralSection.SetValue("LastProject", LastProject.ToConfigEntry()); } GeneralSection.SetValues("OpenProjects", OpenProjects.Select(x => x.ToConfigEntry()).ToArray()); GeneralSection.SetValue("KeepInTray", bKeepInTray); GeneralSection.SetValue("FilterIndex", FilterIndex); GeneralSection.SetValues("RecentProjects", RecentProjects.Select(x => x.ToConfigEntry()).ToArray()); GeneralSection.SetValues("SyncFilter", SyncView); GeneralSection.SetValues("SyncExcludedCategories", SyncExcludedCategories); GeneralSection.SetValue("SyncAllProjects", bSyncAllProjects); GeneralSection.SetValue("IncludeAllProjectsInSolution", bIncludeAllProjectsInSolution); GeneralSection.SetValue("SyncType", SyncType.ToString()); // Build configuration GeneralSection.SetValue("BuildConfig", CompiledEditorBuildConfig.ToString()); // Tab labels GeneralSection.SetValue("TabLabels", TabLabels.ToString()); // Editor arguments List <string> EditorArgumentList = new List <string>(); foreach (Tuple <string, bool> EditorArgument in EditorArguments) { EditorArgumentList.Add(String.Format("{0}:{1}", EditorArgument.Item2? 1 : 0, EditorArgument.Item1)); } GeneralSection.SetValues("EditorArguments", EditorArgumentList.ToArray()); GeneralSection.SetValue("EditorArgumentsPrompt", bEditorArgumentsPrompt); // Schedule settings ConfigSection ScheduleSection = ConfigFile.FindOrAddSection("Schedule"); ScheduleSection.Clear(); ScheduleSection.SetValue("Enabled", bScheduleEnabled); ScheduleSection.SetValue("Time", ScheduleTime.ToString()); ScheduleSection.SetValue("Change", ScheduleChange.ToString()); ScheduleSection.SetValue("AnyOpenProject", ScheduleAnyOpenProject); ScheduleSection.SetValues("Projects", ScheduleProjects.Select(x => x.ToConfigEntry()).ToArray()); // Window settings ConfigSection WindowSection = ConfigFile.FindOrAddSection("Window"); WindowSection.Clear(); WindowSection.SetValue("Visible", bWindowVisible); WindowSection.SetValue("State", WindowState.ToString()); if (WindowBounds != null) { WindowSection.SetValue("Bounds", FormatRectangleValue(WindowBounds.Value)); } // Current workspace settings foreach (KeyValuePair <string, UserWorkspaceSettings> Pair in WorkspaceKeyToSettings) { string CurrentWorkspaceKey = Pair.Key; UserWorkspaceSettings CurrentWorkspace = Pair.Value; ConfigSection WorkspaceSection = ConfigFile.FindOrAddSection(CurrentWorkspaceKey); WorkspaceSection.Clear(); WorkspaceSection.SetValue("CurrentProjectPath", CurrentWorkspace.CurrentProjectIdentifier); WorkspaceSection.SetValue("CurrentChangeNumber", CurrentWorkspace.CurrentChangeNumber); if (CurrentWorkspace.CurrentSyncFilterHash != null) { WorkspaceSection.SetValue("CurrentSyncFilterHash", CurrentWorkspace.CurrentSyncFilterHash); } WorkspaceSection.SetValues("AdditionalChangeNumbers", CurrentWorkspace.AdditionalChangeNumbers.Select(x => x.ToString()).ToArray()); WorkspaceSection.SetValue("LastSyncResult", CurrentWorkspace.LastSyncResult.ToString()); WorkspaceSection.SetValue("LastSyncResultMessage", EscapeText(CurrentWorkspace.LastSyncResultMessage)); WorkspaceSection.SetValue("LastSyncChangeNumber", CurrentWorkspace.LastSyncChangeNumber); if (CurrentWorkspace.LastSyncTime.HasValue) { WorkspaceSection.SetValue("LastSyncTime", CurrentWorkspace.LastSyncTime.ToString()); } if (CurrentWorkspace.LastSyncDurationSeconds > 0) { WorkspaceSection.SetValue("LastSyncDuration", CurrentWorkspace.LastSyncDurationSeconds); } WorkspaceSection.SetValue("LastBuiltChangeNumber", CurrentWorkspace.LastBuiltChangeNumber); WorkspaceSection.SetValues("ExpandedArchiveName", CurrentWorkspace.ExpandedArchiveTypes); WorkspaceSection.SetValues("SyncFilter", CurrentWorkspace.SyncView); WorkspaceSection.SetValues("SyncIncludedCategories", CurrentWorkspace.SyncIncludedCategories); WorkspaceSection.SetValues("SyncExcludedCategories", CurrentWorkspace.SyncExcludedCategories); if (CurrentWorkspace.bSyncAllProjects.HasValue) { WorkspaceSection.SetValue("SyncAllProjects", CurrentWorkspace.bSyncAllProjects.Value); } if (CurrentWorkspace.bIncludeAllProjectsInSolution.HasValue) { WorkspaceSection.SetValue("IncludeAllProjectsInSolution", CurrentWorkspace.bIncludeAllProjectsInSolution.Value); } List <ConfigObject> BisectEntryObjects = new List <ConfigObject>(); foreach (KeyValuePair <int, BisectState> BisectPair in CurrentWorkspace.ChangeNumberToBisectState) { ConfigObject BisectEntryObject = new ConfigObject(); BisectEntryObject.SetValue("Change", BisectPair.Key); BisectEntryObject.SetValue("State", BisectPair.Value.ToString()); BisectEntryObjects.Add(BisectEntryObject); } WorkspaceSection.SetValues("Bisect", BisectEntryObjects.Select(x => x.ToString()).ToArray()); } // Current project settings foreach (KeyValuePair <string, UserProjectSettings> Pair in ProjectKeyToSettings) { string CurrentProjectKey = Pair.Key; UserProjectSettings CurrentProject = Pair.Value; ConfigSection ProjectSection = ConfigFile.FindOrAddSection(CurrentProjectKey); ProjectSection.Clear(); ProjectSection.SetValues("BuildStep", CurrentProject.BuildSteps.Select(x => x.ToString()).ToArray()); if (CurrentProject.FilterType != FilterType.None) { ProjectSection.SetValue("FilterType", CurrentProject.FilterType.ToString()); } ProjectSection.SetValues("FilterBadges", CurrentProject.FilterBadges.ToArray()); } // Perforce settings ConfigSection PerforceSection = ConfigFile.FindOrAddSection("Perforce"); PerforceSection.Clear(); if (SyncOptions.NumRetries > 0) { PerforceSection.SetValue("NumRetries", SyncOptions.NumRetries); } if (SyncOptions.NumThreads > 0) { PerforceSection.SetValue("NumThreads", SyncOptions.NumThreads); } if (SyncOptions.TcpBufferSize > 0) { PerforceSection.SetValue("TcpBufferSize", SyncOptions.TcpBufferSize); } // Save the file ConfigFile.Save(FileName); }
public ConfigSection FindOrAddSection(string Name) { ConfigSection Section = FindSection(Name); if(Section == null) { Section = new ConfigSection(Name); Sections.Add(Section); } return Section; }
public UserSettings(string InFileName) { FileName = InFileName; if (File.Exists(FileName)) { ConfigFile.Load(FileName); } // General settings bBuildAfterSync = (ConfigFile.GetValue("General.BuildAfterSync", "1") != "0"); bRunAfterSync = (ConfigFile.GetValue("General.RunAfterSync", "1") != "0"); bSyncPrecompiledEditor = (ConfigFile.GetValue("General.SyncPrecompiledEditor", "0") != "0"); bOpenSolutionAfterSync = (ConfigFile.GetValue("General.OpenSolutionAfterSync", "0") != "0"); bShowLogWindow = (ConfigFile.GetValue("General.ShowLogWindow", false)); bAutoResolveConflicts = (ConfigFile.GetValue("General.AutoResolveConflicts", "1") != "0"); bUseIncrementalBuilds = ConfigFile.GetValue("General.IncrementalBuilds", true); bShowLocalTimes = ConfigFile.GetValue("General.ShowLocalTimes", false); bKeepInTray = ConfigFile.GetValue("General.KeepInTray", true); LastProjectFileName = ConfigFile.GetValue("General.LastProjectFileName", null); OtherProjectFileNames = ConfigFile.GetValues("General.OtherProjectFileNames", new string[0]); SyncFilter = ConfigFile.GetValues("General.SyncFilter", new string[0]); if (!Enum.TryParse(ConfigFile.GetValue("General.SyncType", ""), out SyncType)) { SyncType = LatestChangeType.Good; } // Build configuration string CompiledEditorBuildConfigName = ConfigFile.GetValue("General.BuildConfig", ""); if (!Enum.TryParse(CompiledEditorBuildConfigName, true, out CompiledEditorBuildConfig)) { CompiledEditorBuildConfig = BuildConfig.DebugGame; } // Editor arguments string[] Arguments = ConfigFile.GetValues("General.EditorArguments", new string[] { "0:-log", "0:-fastload" }); foreach (string Argument in Arguments) { if (Argument.StartsWith("0:")) { EditorArguments.Add(new Tuple <string, bool>(Argument.Substring(2), false)); } else if (Argument.StartsWith("1:")) { EditorArguments.Add(new Tuple <string, bool>(Argument.Substring(2), true)); } else { EditorArguments.Add(new Tuple <string, bool>(Argument, true)); } } // Window settings ConfigSection WindowSection = ConfigFile.FindSection("Window"); if (WindowSection != null) { bHasWindowSettings = true; int X = WindowSection.GetValue("X", -1); int Y = WindowSection.GetValue("Y", -1); int Width = WindowSection.GetValue("Width", -1); int Height = WindowSection.GetValue("Height", -1); WindowRectangle = new Rectangle(X, Y, Width, Height); ConfigObject ColumnWidthObject = new ConfigObject(WindowSection.GetValue("ColumnWidths", "")); foreach (KeyValuePair <string, string> ColumnWidthPair in ColumnWidthObject.Pairs) { int Value; if (int.TryParse(ColumnWidthPair.Value, out Value)) { ColumnWidths[ColumnWidthPair.Key] = Value; } } bWindowVisible = WindowSection.GetValue("Visible", true); } // Schedule settings bScheduleEnabled = ConfigFile.GetValue("Schedule.Enabled", false); if (!TimeSpan.TryParse(ConfigFile.GetValue("Schedule.Time", ""), out ScheduleTime)) { ScheduleTime = new TimeSpan(6, 0, 0); } if (!Enum.TryParse(ConfigFile.GetValue("Schedule.Change", ""), out ScheduleChange)) { ScheduleChange = LatestChangeType.Good; } }
public UserWorkspaceSettings FindOrAddWorkspace(string ClientBranchPath) { // Update the current workspace string CurrentWorkspaceKey = ClientBranchPath.Trim('/'); UserWorkspaceSettings CurrentWorkspace; if (!WorkspaceKeyToSettings.TryGetValue(CurrentWorkspaceKey, out CurrentWorkspace)) { // Create a new workspace settings object CurrentWorkspace = new UserWorkspaceSettings(); WorkspaceKeyToSettings.Add(CurrentWorkspaceKey, CurrentWorkspace); // Read the workspace settings ConfigSection WorkspaceSection = ConfigFile.FindSection(CurrentWorkspaceKey); if (WorkspaceSection == null) { string LegacyBranchAndClientKey = ClientBranchPath.Trim('/'); int SlashIdx = LegacyBranchAndClientKey.IndexOf('/'); if (SlashIdx != -1) { LegacyBranchAndClientKey = LegacyBranchAndClientKey.Substring(0, SlashIdx) + "$" + LegacyBranchAndClientKey.Substring(SlashIdx + 1); } string CurrentSync = ConfigFile.GetValue("Clients." + LegacyBranchAndClientKey, null); if (CurrentSync != null) { int AtIdx = CurrentSync.LastIndexOf('@'); if (AtIdx != -1) { int ChangeNumber; if (int.TryParse(CurrentSync.Substring(AtIdx + 1), out ChangeNumber)) { CurrentWorkspace.CurrentProjectIdentifier = CurrentSync.Substring(0, AtIdx); CurrentWorkspace.CurrentChangeNumber = ChangeNumber; } } } string LastUpdateResultText = ConfigFile.GetValue("Clients." + LegacyBranchAndClientKey + "$LastUpdate", null); if (LastUpdateResultText != null) { int ColonIdx = LastUpdateResultText.LastIndexOf(':'); if (ColonIdx != -1) { int ChangeNumber; if (int.TryParse(LastUpdateResultText.Substring(0, ColonIdx), out ChangeNumber)) { WorkspaceUpdateResult Result; if (Enum.TryParse(LastUpdateResultText.Substring(ColonIdx + 1), out Result)) { CurrentWorkspace.LastSyncChangeNumber = ChangeNumber; CurrentWorkspace.LastSyncResult = Result; } } } } CurrentWorkspace.SyncView = new string[0]; CurrentWorkspace.SyncIncludedCategories = new Guid[0]; CurrentWorkspace.SyncExcludedCategories = new Guid[0]; CurrentWorkspace.bSyncAllProjects = null; CurrentWorkspace.bIncludeAllProjectsInSolution = null; } else { CurrentWorkspace.CurrentProjectIdentifier = WorkspaceSection.GetValue("CurrentProjectPath"); CurrentWorkspace.CurrentChangeNumber = WorkspaceSection.GetValue("CurrentChangeNumber", -1); CurrentWorkspace.CurrentSyncFilterHash = WorkspaceSection.GetValue("CurrentSyncFilterHash", null); foreach (string AdditionalChangeNumberString in WorkspaceSection.GetValues("AdditionalChangeNumbers", new string[0])) { int AdditionalChangeNumber; if (int.TryParse(AdditionalChangeNumberString, out AdditionalChangeNumber)) { CurrentWorkspace.AdditionalChangeNumbers.Add(AdditionalChangeNumber); } } Enum.TryParse(WorkspaceSection.GetValue("LastSyncResult", ""), out CurrentWorkspace.LastSyncResult); CurrentWorkspace.LastSyncResultMessage = UnescapeText(WorkspaceSection.GetValue("LastSyncResultMessage")); CurrentWorkspace.LastSyncChangeNumber = WorkspaceSection.GetValue("LastSyncChangeNumber", -1); DateTime LastSyncTime; if (DateTime.TryParse(WorkspaceSection.GetValue("LastSyncTime", ""), out LastSyncTime)) { CurrentWorkspace.LastSyncTime = LastSyncTime; } CurrentWorkspace.LastSyncDurationSeconds = WorkspaceSection.GetValue("LastSyncDuration", 0); CurrentWorkspace.LastBuiltChangeNumber = WorkspaceSection.GetValue("LastBuiltChangeNumber", 0); CurrentWorkspace.ExpandedArchiveTypes = WorkspaceSection.GetValues("ExpandedArchiveName", new string[0]); CurrentWorkspace.SyncView = WorkspaceSection.GetValues("SyncFilter", new string[0]); CurrentWorkspace.SyncIncludedCategories = WorkspaceSection.GetValues("SyncIncludedCategories", new Guid[0]); CurrentWorkspace.SyncExcludedCategories = WorkspaceSection.GetValues("SyncExcludedCategories", new Guid[0]); int SyncAllProjects = WorkspaceSection.GetValue("SyncAllProjects", -1); CurrentWorkspace.bSyncAllProjects = (SyncAllProjects == 0)? (bool?)false : (SyncAllProjects == 1)? (bool?)true : (bool?)null; int IncludeAllProjectsInSolution = WorkspaceSection.GetValue("IncludeAllProjectsInSolution", -1); CurrentWorkspace.bIncludeAllProjectsInSolution = (IncludeAllProjectsInSolution == 0)? (bool?)false : (IncludeAllProjectsInSolution == 1)? (bool?)true : (bool?)null; string[] BisectEntries = WorkspaceSection.GetValues("Bisect", new string[0]); foreach (string BisectEntry in BisectEntries) { ConfigObject BisectEntryObject = new ConfigObject(BisectEntry); int ChangeNumber = BisectEntryObject.GetValue("Change", -1); if (ChangeNumber != -1) { BisectState State; if (Enum.TryParse(BisectEntryObject.GetValue("State", ""), out State)) { CurrentWorkspace.ChangeNumberToBisectState[ChangeNumber] = State; } } } } } return(CurrentWorkspace); }
public void OpenProject(string ClientBranchPath, string ClientProjectFileName) { CloseProject(); // Update the current workspace CurrentWorkspaceKey = ClientBranchPath.Trim('/'); CurrentWorkspace = new UserWorkspaceSettings(); // Read the workspace settings ConfigSection WorkspaceSection = ConfigFile.FindSection(CurrentWorkspaceKey); if (WorkspaceSection == null) { string LegacyBranchAndClientKey = ClientBranchPath.Trim('/'); int SlashIdx = LegacyBranchAndClientKey.IndexOf('/'); if (SlashIdx != -1) { LegacyBranchAndClientKey = LegacyBranchAndClientKey.Substring(0, SlashIdx) + "$" + LegacyBranchAndClientKey.Substring(SlashIdx + 1); } string CurrentSync = ConfigFile.GetValue("Clients." + LegacyBranchAndClientKey, null); if (CurrentSync != null) { int AtIdx = CurrentSync.LastIndexOf('@'); if (AtIdx != -1) { int ChangeNumber; if (int.TryParse(CurrentSync.Substring(AtIdx + 1), out ChangeNumber)) { CurrentWorkspace.CurrentProjectIdentifier = CurrentSync.Substring(0, AtIdx); CurrentWorkspace.CurrentChangeNumber = ChangeNumber; } } } string LastUpdateResultText = ConfigFile.GetValue("Clients." + LegacyBranchAndClientKey + "$LastUpdate", null); if (LastUpdateResultText != null) { int ColonIdx = LastUpdateResultText.LastIndexOf(':'); if (ColonIdx != -1) { int ChangeNumber; if (int.TryParse(LastUpdateResultText.Substring(0, ColonIdx), out ChangeNumber)) { WorkspaceUpdateResult Result; if (Enum.TryParse(LastUpdateResultText.Substring(ColonIdx + 1), out Result)) { CurrentWorkspace.LastSyncChangeNumber = ChangeNumber; CurrentWorkspace.LastSyncResult = Result; } } } } } else { CurrentWorkspace.CurrentProjectIdentifier = WorkspaceSection.GetValue("CurrentProjectPath"); CurrentWorkspace.CurrentChangeNumber = WorkspaceSection.GetValue("CurrentChangeNumber", -1); foreach (string AdditionalChangeNumberString in WorkspaceSection.GetValues("AdditionalChangeNumbers", new string[0])) { int AdditionalChangeNumber; if (int.TryParse(AdditionalChangeNumberString, out AdditionalChangeNumber)) { CurrentWorkspace.AdditionalChangeNumbers.Add(AdditionalChangeNumber); } } Enum.TryParse(WorkspaceSection.GetValue("LastSyncResult", ""), out CurrentWorkspace.LastSyncResult); CurrentWorkspace.LastSyncResultMessage = UnescapeText(WorkspaceSection.GetValue("LastSyncResultMessage")); CurrentWorkspace.LastSyncChangeNumber = WorkspaceSection.GetValue("LastSyncChangeNumber", -1); DateTime LastSyncTime; if (DateTime.TryParse(WorkspaceSection.GetValue("LastSyncTime", ""), out LastSyncTime)) { CurrentWorkspace.LastSyncTime = LastSyncTime; } CurrentWorkspace.LastSyncDurationSeconds = WorkspaceSection.GetValue("LastSyncDuration", 0); CurrentWorkspace.LastBuiltChangeNumber = WorkspaceSection.GetValue("LastBuiltChangeNumber", 0); CurrentWorkspace.ExpandedArchiveTypes = WorkspaceSection.GetValues("ExpandedArchiveName", new string[0]); } // Read the project settings CurrentProjectKey = ClientProjectFileName; CurrentProject = new UserProjectSettings(); ConfigSection ProjectSection = ConfigFile.FindOrAddSection(CurrentProjectKey); CurrentProject.BuildSteps.AddRange(ProjectSection.GetValues("BuildStep", new string[0]).Select(x => new ConfigObject(x))); }
public void Save() { // General settings ConfigSection GeneralSection = ConfigFile.FindOrAddSection("General"); GeneralSection.Clear(); GeneralSection.SetValue("BuildAfterSync", bBuildAfterSync); GeneralSection.SetValue("RunAfterSync", bRunAfterSync); GeneralSection.SetValue("SyncPrecompiledEditor", bSyncPrecompiledEditor); GeneralSection.SetValue("OpenSolutionAfterSync", bOpenSolutionAfterSync); GeneralSection.SetValue("ShowLogWindow", bShowLogWindow); GeneralSection.SetValue("AutoResolveConflicts", bAutoResolveConflicts); GeneralSection.SetValue("UseIncrementalBuilds", bUseIncrementalBuilds); GeneralSection.SetValue("ShowLocalTimes", bShowLocalTimes); GeneralSection.SetValue("LastProjectFileName", LastProjectFileName); GeneralSection.SetValue("KeepInTray", bKeepInTray); GeneralSection.SetValues("OtherProjectFileNames", OtherProjectFileNames); GeneralSection.SetValues("SyncFilter", SyncFilter); GeneralSection.SetValue("SyncType", SyncType.ToString()); // Build configuration GeneralSection.SetValue("BuildConfig", CompiledEditorBuildConfig.ToString()); // Editor arguments List <string> EditorArgumentList = new List <string>(); foreach (Tuple <string, bool> EditorArgument in EditorArguments) { EditorArgumentList.Add(String.Format("{0}:{1}", EditorArgument.Item2? 1 : 0, EditorArgument.Item1)); } GeneralSection.SetValues("EditorArguments", EditorArgumentList.ToArray()); // Schedule settings ConfigSection ScheduleSection = ConfigFile.FindOrAddSection("Schedule"); ScheduleSection.Clear(); ScheduleSection.SetValue("Enabled", bScheduleEnabled); ScheduleSection.SetValue("Time", ScheduleTime.ToString()); ScheduleSection.SetValue("Change", ScheduleChange.ToString()); // Window settings if (bHasWindowSettings) { ConfigSection WindowSection = ConfigFile.FindOrAddSection("Window"); WindowSection.Clear(); WindowSection.SetValue("X", WindowRectangle.X); WindowSection.SetValue("Y", WindowRectangle.Y); WindowSection.SetValue("Width", WindowRectangle.Width); WindowSection.SetValue("Height", WindowRectangle.Height); ConfigObject ColumnWidthsObject = new ConfigObject(); foreach (KeyValuePair <string, int> ColumnWidthPair in ColumnWidths) { ColumnWidthsObject.SetValue(ColumnWidthPair.Key, ColumnWidthPair.Value.ToString()); } WindowSection.SetValue("ColumnWidths", ColumnWidthsObject.ToString()); WindowSection.SetValue("Visible", bWindowVisible); } // Current workspace settings if (CurrentWorkspace != null) { ConfigSection WorkspaceSection = ConfigFile.FindOrAddSection(CurrentWorkspaceKey); WorkspaceSection.Clear(); WorkspaceSection.SetValue("CurrentProjectPath", CurrentWorkspace.CurrentProjectIdentifier); WorkspaceSection.SetValue("CurrentChangeNumber", CurrentWorkspace.CurrentChangeNumber); WorkspaceSection.SetValues("AdditionalChangeNumbers", CurrentWorkspace.AdditionalChangeNumbers.Select(x => x.ToString()).ToArray()); WorkspaceSection.SetValue("LastSyncResult", CurrentWorkspace.LastSyncResult.ToString()); WorkspaceSection.SetValue("LastSyncResultMessage", EscapeText(CurrentWorkspace.LastSyncResultMessage)); WorkspaceSection.SetValue("LastSyncChangeNumber", CurrentWorkspace.LastSyncChangeNumber); if (CurrentWorkspace.LastSyncTime.HasValue) { WorkspaceSection.SetValue("LastSyncTime", CurrentWorkspace.LastSyncTime.ToString()); } if (CurrentWorkspace.LastSyncDurationSeconds > 0) { WorkspaceSection.SetValue("LastSyncDuration", CurrentWorkspace.LastSyncDurationSeconds); } WorkspaceSection.SetValue("LastBuiltChangeNumber", CurrentWorkspace.LastBuiltChangeNumber); WorkspaceSection.SetValues("ExpandedArchiveName", CurrentWorkspace.ExpandedArchiveTypes); } // Current project settings if (CurrentProject != null) { ConfigSection ProjectSection = ConfigFile.FindOrAddSection(CurrentProjectKey); ProjectSection.Clear(); ProjectSection.SetValues("BuildStep", CurrentProject.BuildSteps.Select(x => x.ToString()).ToArray()); } // Save the file ConfigFile.Save(FileName); }
bool UpdateZippedBinaries() { string ZippedBinariesPath = null; // Find all the zipped binaries under this stream ConfigSection ProjectConfigSection = LatestProjectConfigFile.FindSection(SelectedProjectIdentifier); if (ProjectConfigSection != null) { ZippedBinariesPath = ProjectConfigSection.GetValue("ZippedBinariesPath", null); } // Build a new list of zipped binaries SortedList <int, string> NewChangeNumberToZippedBinaries = new SortedList <int, string>(); if (ZippedBinariesPath != null) { // Make sure the zipped binaries path exists bool bExists; if (!Perforce.FileExists(ZippedBinariesPath, out bExists, LogWriter)) { return(false); } if (bExists) { // Query all the changes to this file List <PerforceFileChangeSummary> Changes; if (!Perforce.FindFileChanges(ZippedBinariesPath, 100, out Changes, LogWriter)) { return(false); } // Build a new list of zipped binaries foreach (PerforceFileChangeSummary Change in Changes) { if (Change.Action != "purge") { string[] Tokens = Change.Description.Split(' '); if (Tokens[0].StartsWith("[CL") && Tokens[1].EndsWith("]")) { int OriginalChangeNumber; if (int.TryParse(Tokens[1].Substring(0, Tokens[1].Length - 1), out OriginalChangeNumber) && !NewChangeNumberToZippedBinaries.ContainsKey(OriginalChangeNumber)) { NewChangeNumberToZippedBinaries[OriginalChangeNumber] = String.Format("{0}#{1}", ZippedBinariesPath, Change.Revision); } } } } } } // Get the new status message string NewZippedBinariesStatus; if (ZippedBinariesPath == null) { NewZippedBinariesStatus = String.Format("Precompiled binaries are not available for {0}", SelectedProjectIdentifier); } else if (NewChangeNumberToZippedBinaries.Count == 0) { NewZippedBinariesStatus = String.Format("No valid archives found at {0}", ZippedBinariesPath); } else { NewZippedBinariesStatus = null; } // Update the new list of zipped binaries if (!ChangeNumberToZippedBinaries.SequenceEqual(NewChangeNumberToZippedBinaries) || ZippedBinariesStatus != NewZippedBinariesStatus) { ZippedBinariesStatus = NewZippedBinariesStatus; ChangeNumberToZippedBinaries = NewChangeNumberToZippedBinaries; if (OnUpdateMetadata != null && Changes.Count > 0) { OnUpdateMetadata(); } } return(true); }
bool UpdateZippedBinaries() { // Get the path to the config file string ClientConfigFileName = PerforceUtils.GetClientOrDepotDirectoryName(SelectedClientFileName) + "/Build/UnrealGameSync.ini"; // Find the most recent change to that file (if the file doesn't exist, we succeed and just get 0 changes). List <PerforceChangeSummary> ConfigFileChanges; if (!Perforce.FindChanges(ClientConfigFileName, 1, out ConfigFileChanges, LogWriter)) { return(false); } // Update the zipped binaries path if it's changed int NewZippedBinariesConfigChangeNumber = (ConfigFileChanges.Count > 0)? ConfigFileChanges[0].Number : 0; if (NewZippedBinariesConfigChangeNumber != ZippedBinariesConfigChangeNumber) { string NewZippedBinariesPath = null; if (NewZippedBinariesConfigChangeNumber != 0) { List <string> Lines; if (!Perforce.Print(ClientConfigFileName, out Lines, LogWriter)) { return(false); } ConfigFile NewConfigFile = new ConfigFile(); NewConfigFile.Parse(Lines.ToArray()); ConfigSection ProjectSection = NewConfigFile.FindSection(SelectedProjectIdentifier); if (ProjectSection != null) { NewZippedBinariesPath = ProjectSection.GetValue("ZippedBinariesPath", null); } } ZippedBinariesPath = NewZippedBinariesPath; ZippedBinariesConfigChangeNumber = NewZippedBinariesConfigChangeNumber; } SortedList <int, string> NewChangeNumberToZippedBinaries = new SortedList <int, string>(); if (ZippedBinariesPath != null) { List <PerforceFileChangeSummary> Changes; if (!Perforce.FindFileChanges(ZippedBinariesPath, 100, out Changes, LogWriter)) { return(false); } foreach (PerforceFileChangeSummary Change in Changes) { if (Change.Action != "purge") { string[] Tokens = Change.Description.Split(' '); if (Tokens[0].StartsWith("[CL") && Tokens[1].EndsWith("]")) { int OriginalChangeNumber; if (int.TryParse(Tokens[1].Substring(0, Tokens[1].Length - 1), out OriginalChangeNumber) && !NewChangeNumberToZippedBinaries.ContainsKey(OriginalChangeNumber)) { NewChangeNumberToZippedBinaries[OriginalChangeNumber] = String.Format("{0}#{1}", ZippedBinariesPath, Change.Revision); } } } } } if (!ChangeNumberToZippedBinaries.SequenceEqual(NewChangeNumberToZippedBinaries)) { ChangeNumberToZippedBinaries = NewChangeNumberToZippedBinaries; if (OnUpdateMetadata != null && Changes.Count > 0) { OnUpdateMetadata(); } } return(true); }
public UserSettings(string InFileName) { FileName = InFileName; if (File.Exists(FileName)) { ConfigFile.Load(FileName); } // General settings bBuildAfterSync = (ConfigFile.GetValue("General.BuildAfterSync", "1") != "0"); bRunAfterSync = (ConfigFile.GetValue("General.RunAfterSync", "1") != "0"); bSyncPrecompiledEditor = (ConfigFile.GetValue("General.SyncPrecompiledEditor", "0") != "0"); bOpenSolutionAfterSync = (ConfigFile.GetValue("General.OpenSolutionAfterSync", "0") != "0"); bShowLogWindow = (ConfigFile.GetValue("General.ShowLogWindow", false)); bAutoResolveConflicts = (ConfigFile.GetValue("General.AutoResolveConflicts", "1") != "0"); bUseIncrementalBuilds = ConfigFile.GetValue("General.IncrementalBuilds", true); bShowLocalTimes = ConfigFile.GetValue("General.ShowLocalTimes", false); bShowAllStreams = ConfigFile.GetValue("General.ShowAllStreams", false); bKeepInTray = ConfigFile.GetValue("General.KeepInTray", true); int.TryParse(ConfigFile.GetValue("General.FilterIndex", "0"), out FilterIndex); LastProjectFileName = ConfigFile.GetValue("General.LastProjectFileName", null); OpenProjectFileNames = ConfigFile.GetValues("General.OpenProjectFileNames", new string[0]); if (LastProjectFileName != null && !OpenProjectFileNames.Any(x => x.Equals(LastProjectFileName, StringComparison.InvariantCultureIgnoreCase))) { OpenProjectFileNames = OpenProjectFileNames.Concat(new string[] { LastProjectFileName }).ToArray(); } OtherProjectFileNames = ConfigFile.GetValues("General.OtherProjectFileNames", new string[0]); SyncView = ConfigFile.GetValues("General.SyncFilter", new string[0]); SyncExcludedCategories = ConfigFile.GetGuidValues("General.SyncExcludedCategories", new Guid[0]); if (!Enum.TryParse(ConfigFile.GetValue("General.SyncType", ""), out SyncType)) { SyncType = LatestChangeType.Good; } // Build configuration string CompiledEditorBuildConfigName = ConfigFile.GetValue("General.BuildConfig", ""); if (!Enum.TryParse(CompiledEditorBuildConfigName, true, out CompiledEditorBuildConfig)) { CompiledEditorBuildConfig = BuildConfig.DebugGame; } // Tab names string TabNamesValue = ConfigFile.GetValue("General.TabNames", ""); if (!Enum.TryParse(TabNamesValue, true, out TabLabels)) { TabLabels = TabLabels.ProjectFile; } // Editor arguments string[] Arguments = ConfigFile.GetValues("General.EditorArguments", new string[] { "0:-log", "0:-fastload" }); foreach (string Argument in Arguments) { if (Argument.StartsWith("0:")) { EditorArguments.Add(new Tuple <string, bool>(Argument.Substring(2), false)); } else if (Argument.StartsWith("1:")) { EditorArguments.Add(new Tuple <string, bool>(Argument.Substring(2), true)); } else { EditorArguments.Add(new Tuple <string, bool>(Argument, true)); } } // Window settings ConfigSection WindowSection = ConfigFile.FindSection("Window"); if (WindowSection != null) { bHasWindowSettings = true; int X = WindowSection.GetValue("X", -1); int Y = WindowSection.GetValue("Y", -1); int Width = WindowSection.GetValue("Width", -1); int Height = WindowSection.GetValue("Height", -1); WindowRectangle = new Rectangle(X, Y, Width, Height); ConfigObject ColumnWidthObject = new ConfigObject(WindowSection.GetValue("ColumnWidths", "")); foreach (KeyValuePair <string, string> ColumnWidthPair in ColumnWidthObject.Pairs) { int Value; if (int.TryParse(ColumnWidthPair.Value, out Value)) { ColumnWidths[ColumnWidthPair.Key] = Value; } } bWindowVisible = WindowSection.GetValue("Visible", true); } // Schedule settings bScheduleEnabled = ConfigFile.GetValue("Schedule.Enabled", false); if (!TimeSpan.TryParse(ConfigFile.GetValue("Schedule.Time", ""), out ScheduleTime)) { ScheduleTime = new TimeSpan(6, 0, 0); } if (!Enum.TryParse(ConfigFile.GetValue("Schedule.Change", ""), out ScheduleChange)) { ScheduleChange = LatestChangeType.Good; } // Perforce settings if (!int.TryParse(ConfigFile.GetValue("Perforce.NumRetries", "0"), out SyncOptions.NumRetries)) { SyncOptions.NumRetries = 0; } if (!int.TryParse(ConfigFile.GetValue("Perforce.NumThreads", "0"), out SyncOptions.NumThreads)) { SyncOptions.NumThreads = 0; } if (!int.TryParse(ConfigFile.GetValue("Perforce.TcpBufferSize", "0"), out SyncOptions.TcpBufferSize)) { SyncOptions.TcpBufferSize = 0; } }
bool UpdateArchives() { List <ArchiveInfo> NewArchives = new List <ArchiveInfo>(); // Find all the zipped binaries under this stream ConfigSection ProjectConfigSection = LatestProjectConfigFile.FindSection(SelectedProjectIdentifier); if (ProjectConfigSection != null) { // Legacy string LegacyEditorArchivePath = ProjectConfigSection.GetValue("ZippedBinariesPath", null); if (LegacyEditorArchivePath != null) { NewArchives.Add(new ArchiveInfo("Editor", "Editor", LegacyEditorArchivePath)); } // New style foreach (string ArchiveValue in ProjectConfigSection.GetValues("Archives", new string[0])) { ArchiveInfo Archive; if (ArchiveInfo.TryParseConfigEntry(ArchiveValue, out Archive)) { NewArchives.Add(Archive); } } // Make sure the zipped binaries path exists foreach (ArchiveInfo NewArchive in NewArchives) { bool bExists; if (!Perforce.FileExists(NewArchive.DepotPath, out bExists, LogWriter)) { return(false); } if (bExists) { // Query all the changes to this file List <PerforceFileChangeSummary> Changes; if (!Perforce.FindFileChanges(NewArchive.DepotPath, 100, out Changes, LogWriter)) { return(false); } // Build a new list of zipped binaries foreach (PerforceFileChangeSummary Change in Changes) { if (Change.Action != "purge") { string[] Tokens = Change.Description.Split(' '); if (Tokens[0].StartsWith("[CL") && Tokens[1].EndsWith("]")) { int OriginalChangeNumber; if (int.TryParse(Tokens[1].Substring(0, Tokens[1].Length - 1), out OriginalChangeNumber) && !NewArchive.ChangeNumberToFileRevision.ContainsKey(OriginalChangeNumber)) { NewArchive.ChangeNumberToFileRevision[OriginalChangeNumber] = String.Format("{0}#{1}", NewArchive.DepotPath, Change.Revision); } } } } } } } // Check if the information has changed if (!Enumerable.SequenceEqual(Archives, NewArchives)) { Archives = NewArchives; AvailableArchives = Archives.Select(x => (IArchiveInfo)x).ToList(); if (OnUpdateMetadata != null && Changes.Count > 0) { OnUpdateMetadata(); } } 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))); if (bIsEnterpriseProject) { DepotPaths.Add(String.Format("{0}/Enterprise/...", BranchClientPath)); } // Add in additional paths property ConfigSection ProjectConfigSection = LatestProjectConfigFile.FindSection("Perforce"); if (ProjectConfigSection != null) { IEnumerable <string> AdditionalPaths = ProjectConfigSection.GetValues("AdditionalPathsToSync", new string[0]); // turn into //ws/path DepotPaths.AddRange(AdditionalPaths.Select(P => string.Format("{0}/{1}", BranchClientPath, P.TrimStart('/')))); } } // 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 (ArchiveInfo Archive in Archives) { foreach (int ChangeNumber in Archive.ChangeNumberToFileRevision.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 && Archives.Any(x => x.ChangeNumberToFileRevision.Count == 0 || x.ChangeNumberToFileRevision.ContainsKey(Change.Number) || x.ChangeNumberToFileRevision.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); }