Esempio n. 1
0
 public bool TryGetChangeDetails(int Number, out PerforceChangeDetails Details)
 {
     lock (this)
     {
         return(ChangeDetails.TryGetValue(Number, out Details));
     }
 }
Esempio n. 2
0
        public bool UpdateChangeTypes()
        {
            // Find the changes we need to query
            List <int> QueryChangeNumbers = new List <int>();

            lock (this)
            {
                foreach (PerforceChangeSummary Change in Changes)
                {
                    if (!ChangeDetails.ContainsKey(Change.Number))
                    {
                        QueryChangeNumbers.Add(Change.Number);
                    }
                }
            }

            // Update them in batches
            foreach (int QueryChangeNumber in QueryChangeNumbers)
            {
                string[] CodeExtensions = { ".cs", ".h", ".cpp", ".inl", ".usf", ".ush", ".uproject", ".uplugin" };

                // If there's something to check for, find all the content changes after this changelist
                PerforceDescribeRecord DescribeRecord;
                if (Perforce.Describe(QueryChangeNumber, out DescribeRecord, LogWriter))
                {
                    // Create the details object
                    PerforceChangeDetails Details = new PerforceChangeDetails();
                    Details.Description = DescribeRecord.Description;

                    // Check whether the files are code or content
                    foreach (PerforceDescribeFileRecord File in DescribeRecord.Files)
                    {
                        if (CodeExtensions.Any(Extension => File.DepotFile.EndsWith(Extension, StringComparison.InvariantCultureIgnoreCase)))
                        {
                            Details.bContainsCode = true;
                        }
                        else
                        {
                            Details.bContainsContent = true;
                        }
                    }

                    // Update the type of this change
                    lock (this)
                    {
                        if (!ChangeDetails.ContainsKey(QueryChangeNumber))
                        {
                            ChangeDetails.Add(QueryChangeNumber, Details);
                        }
                    }

                    // Reload the config file if it changes
                    if (DescribeRecord.Files.Any(x => x.DepotFile.EndsWith("/UnrealGameSync.ini", StringComparison.InvariantCultureIgnoreCase)))
                    {
                        UpdateProjectConfigFile();
                    }
                }

                // 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)
                    {
                        PerforceChangeDetails Details;
                        if (ChangeDetails.TryGetValue(Change.Number, out Details) && Details.bContainsCode)
                        {
                            NewLastCodeChangeByCurrentUser = Math.Max(NewLastCodeChangeByCurrentUser, Change.Number);
                        }
                    }
                }
                LastCodeChangeByCurrentUser = NewLastCodeChangeByCurrentUser;

                // Notify the main window that we've got an update
                if (OnUpdateMetadata != null)
                {
                    OnUpdateMetadata();
                }
            }

            if (LocalConfigFiles.Any(x => File.GetLastWriteTimeUtc(x.Key) != x.Value))
            {
                UpdateProjectConfigFile();
                if (OnUpdateMetadata != null)
                {
                    OnUpdateMetadata();
                }
            }

            return(true);
        }
Esempio n. 3
0
        public bool UpdateChangeTypes()
        {
            // Find the changes we need to query
            List <int> QueryChangeNumbers = new List <int>();

            lock (this)
            {
                foreach (PerforceChangeSummary Change in Changes)
                {
                    if (!ChangeDetails.ContainsKey(Change.Number))
                    {
                        QueryChangeNumbers.Add(Change.Number);
                    }
                }
            }

            // Update them in batches
            foreach (int QueryChangeNumber in QueryChangeNumbers)
            {
                // Skip this stuff if the user wants us to query for more changes
                if (PendingMaxChanges != CurrentMaxChanges)
                {
                    break;
                }

                // If there's something to check for, find all the content changes after this changelist
                PerforceDescribeRecord DescribeRecord;
                if (Perforce.Describe(QueryChangeNumber, out DescribeRecord, LogWriter))
                {
                    // Create the details object
                    PerforceChangeDetails Details = new PerforceChangeDetails(DescribeRecord);
                    lock (this)
                    {
                        if (!ChangeDetails.ContainsKey(QueryChangeNumber))
                        {
                            ChangeDetails.Add(QueryChangeNumber, Details);
                        }
                    }

                    // Reload the config file if it changes
                    if (DescribeRecord.Files.Any(x => x.DepotFile.EndsWith("/UnrealGameSync.ini", StringComparison.InvariantCultureIgnoreCase)))
                    {
                        UpdateProjectConfigFile();
                    }
                }

                // 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)
                    {
                        PerforceChangeDetails Details;
                        if (ChangeDetails.TryGetValue(Change.Number, out Details) && Details.bContainsCode)
                        {
                            NewLastCodeChangeByCurrentUser = Math.Max(NewLastCodeChangeByCurrentUser, Change.Number);
                        }
                    }
                }
                LastCodeChangeByCurrentUser = NewLastCodeChangeByCurrentUser;

                // Notify the main window that we've got an update
                if (OnUpdateMetadata != null)
                {
                    OnUpdateMetadata();
                }
            }

            if (LocalConfigFiles.Any(x => File.GetLastWriteTimeUtc(x.Key) != x.Value))
            {
                UpdateProjectConfigFile();
                if (OnUpdateMetadata != null)
                {
                    OnUpdateMetadata();
                }
            }

            return(true);
        }