示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
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, null));
                }

                // 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);
        }