Пример #1
0
        // Executed in a worker thread.
        protected override GuidStatusDatasBind[] GatherDataInThread()
        {
            var statusOptions = new SVNStatusDataOptions()
            {
                Depth          = SVNStatusDataOptions.SearchDepth.Infinity,
                RaiseError     = false,
                Timeout        = WiseSVNIntegration.ONLINE_COMMAND_TIMEOUT * 2,
                Offline        = !SVNPreferencesManager.Instance.DownloadRepositoryChanges && !SVNPreferencesManager.Instance.ProjectPrefs.EnableAutoLocking,
                FetchLockOwner = true,
            };

            // Will get statuses of all added / modified / deleted / conflicted / unversioned files. Only normal files won't be listed.
            var statuses = WiseSVNIntegration.GetStatuses("Assets", statusOptions)
#if UNITY_2018_4_OR_NEWER
                           .Concat(WiseSVNIntegration.GetStatuses("Packages", statusOptions))
#endif
                           .Where(s => s.Status != VCFileStatus.Missing)
                           .ToList();

            for (int i = 0, count = statuses.Count; i < count; ++i)
            {
                var statusData = statuses[i];

                // Statuses for entries under unversioned directories are not returned. Add them manually.
                if (statusData.Status == VCFileStatus.Unversioned && Directory.Exists(statusData.Path))
                {
                    try {
                        var paths = Directory.EnumerateFileSystemEntries(statusData.Path, "*", SearchOption.AllDirectories)
                                    .Where(path => !WiseSVNIntegration.IsHiddenPath(path))
                        ;

                        statuses.AddRange(paths
                                          .Select(path => path.Replace(WiseSVNIntegration.ProjectRoot, ""))
                                          .Select(path => new SVNStatusData()
                        {
                            Status = VCFileStatus.Unversioned, Path = path, LockDetails = LockDetails.Empty
                        })
                                          );
                    } catch (Exception) {
                        // Files must have changed while scanning. Nothing we can do.
                    }
                }
            }

            // HACK: the base class works with the DataType for pending data. Guid won't be used.
            return(statuses
                   .Where(s => statuses.Count < SanityStatusesLimit ||                  // Include everything when below the limit
                          s.Status == VCFileStatus.Added ||
                          s.Status == VCFileStatus.Modified ||
                          s.Status == VCFileStatus.Conflicted
                          )
                   .Select(s => new GuidStatusDatasBind()
            {
                MergedStatusData = s
            })
                   .ToArray());
        }
Пример #2
0
        //
        //=============================================================================
        //
        #region Invalidate Database

        internal void PostProcessAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets)
        {
            if (!IsActive)
            {
                return;
            }

            if (deletedAssets.Length > 0 || movedAssets.Length > 0)
            {
                InvalidateDatabase();
                return;
            }

            // It will probably be faster.
            if (importedAssets.Length > 10)
            {
                InvalidateDatabase();
                return;
            }

            foreach (var path in importedAssets)
            {
                // ProjectSettings, Packages are imported too but we're not interested.
                if (!path.StartsWith("Assets", StringComparison.Ordinal))
                {
                    continue;
                }

                var  statusData = WiseSVNIntegration.GetStatus(path);
                bool isMeta     = false;

                // If status is normal but asset was imported, maybe the meta changed. Use that status instead.
                if (statusData.Status == VCFileStatus.Normal && !statusData.IsConflicted)
                {
                    statusData = WiseSVNIntegration.GetStatus(path + ".meta");
                    isMeta     = true;
                }

                var guid = AssetDatabase.AssetPathToGUID(path);

                // Conflicted file got reimported? F**k this, just refresh.
                if (statusData.IsConflicted)
                {
                    SetStatusData(guid, statusData, true, isMeta);
                    InvalidateDatabase();
                    return;
                }


                if (statusData.Status == VCFileStatus.Normal)
                {
                    // Check if just switched to normal from something else.
                    var knownStatusData = GetKnownStatusData(guid);
                    // Normal might be present in the database if it is locked.
                    if (knownStatusData.Status != VCFileStatus.None && knownStatusData.Status != VCFileStatus.Normal)
                    {
                        RemoveStatusData(guid);
                        InvalidateDatabase();
                        return;
                    }

                    continue;
                }

                // Every time the user saves a file it will get reimported. If we already know it is modified, don't refresh every time.
                bool changed = SetStatusData(guid, statusData, true, isMeta);

                if (changed)
                {
                    InvalidateDatabase();
                    return;
                }
            }
        }
Пример #3
0
        // Executed in a worker thread.
        private void GatherSVNStatuses()
        {
            try {
                var statusOptions = new SVNStatusDataOptions()
                {
                    Depth          = SVNStatusDataOptions.SearchDepth.Infinity,
                    RaiseError     = false,
                    Timeout        = WiseSVNIntegration.COMMAND_TIMEOUT * 2,
                    Offline        = !SVNPreferencesManager.Instance.DownloadRepositoryChanges,
                    FetchLockOwner = true,
                };

                // Will get statuses of all added / modified / deleted / conflicted / unversioned files. Only normal files won't be listed.
                var statuses = WiseSVNIntegration.GetStatuses("Assets", statusOptions)
                               // Deleted svn file can still exist for some reason. Need to show it as deleted.
                               // If file doesn't exists, skip it as we can't show it anyway.
                               .Where(s => s.Status != VCFileStatus.Deleted || File.Exists(s.Path))
                               .Where(s => s.Status != VCFileStatus.Missing)
                               .ToList();

                for (int i = 0, count = statuses.Count; i < count; ++i)
                {
                    var statusData = statuses[i];

                    // Statuses for entries under unversioned directories are not returned. Add them manually.
                    if (statusData.Status == VCFileStatus.Unversioned && Directory.Exists(statusData.Path))
                    {
                        var paths = Directory.EnumerateFileSystemEntries(statusData.Path, "*", SearchOption.AllDirectories)
                                    .Where(path => !WiseSVNIntegration.IsHiddenPath(path))
                        ;

                        statuses.AddRange(paths
                                          .Select(path => path.Replace(WiseSVNIntegration.ProjectRoot, ""))
                                          .Select(path => new SVNStatusData()
                        {
                            Status = VCFileStatus.Unversioned, Path = path, LockDetails = LockDetails.Empty
                        })
                                          );
                    }
                }

                if (PendingUpdate == false)
                {
                    throw new Exception("SVN thread finished work but the update is over?");
                }

                m_PendingStatuses = statuses.ToArray();
            }
            // Most probably the assembly got reloaded and the thread was aborted.
            catch (System.Threading.ThreadAbortException) {
                System.Threading.Thread.ResetAbort();

                // Should always be true.
                if (PendingUpdate)
                {
                    m_PendingStatuses = new SVNStatusData[0];
                }
            } catch (Exception ex) {
                Debug.LogException(ex);

                // Should always be true.
                if (PendingUpdate)
                {
                    m_PendingStatuses = new SVNStatusData[0];
                }
            }
        }