Example #1
0
        public override void Initialize(bool freshlyCreated)
        {
            var lastModifiedDate = File.Exists(PROJECT_PREFERENCES_PATH)
                                ? File.GetLastWriteTime(PROJECT_PREFERENCES_PATH).Ticks
                                : 0
            ;

            if (freshlyCreated || m_ProjectPrefsLastModifiedTime != lastModifiedDate)
            {
                LoadPreferences();
            }

            if (freshlyCreated || m_RetryTextures)
            {
                LoadTextures();

                m_RetryTextures = false;

                // If WiseSVN was just added to the project, Unity won't manage to load the textures the first time. Try again next frame.
                if (FileStatusIcons[(int)VCFileStatus.Added].image == null)
                {
                    // We're using a flag as assembly reload may happen and update callback will be lost.
                    m_RetryTextures = true;

                    EditorApplication.CallbackFunction reloadTextures = null;
                    reloadTextures = () => {
                        LoadTextures();
                        m_RetryTextures           = false;
                        EditorApplication.update -= reloadTextures;
                    };

                    EditorApplication.update += reloadTextures;
                }

                Debug.Log($"Loaded WiseSVN Preferences. WiseSVN is turned {(PersonalPrefs.EnableCoreIntegration ? "on" : "off")}.");

                if (PersonalPrefs.EnableCoreIntegration)
                {
                    var svnError = WiseSVNIntegration.CheckForSVNErrors();

                    // svn: warning: W155007: '...' is not a working copy!
                    // This can be returned when project is not a valid svn checkout. (Probably)
                    if (svnError.Contains("W155007"))
                    {
                        Debug.LogError("This project is NOT under version control (not a proper SVN checkout).");

                        // System.ComponentModel.Win32Exception (0x80004005): ApplicationName='...', CommandLine='...', Native error= The system cannot find the file specified.
                        // Could not find the command executable. The user hasn't installed their CLI (Command Line Interface) so we're missing an "svn.exe" in the PATH environment.
                        // This is allowed only if there isn't ProjectPreference specified CLI path.
                    }
                    else if (svnError.Contains("0x80004005"))
                    {
                        Debug.LogError("SVN CLI (Command Line Interface) not found. You need to install it in order for the SVN integration to work properly.");

                        // Any other error.
                    }
                    else if (!string.IsNullOrEmpty(svnError))
                    {
                        Debug.LogError($"SVN command line interface returned this error:\n{svnError}");
                    }
                }
            }

            SVNContextMenusManager.SetupContextType(PersonalPrefs.ContextMenusClient);
        }
        public override void Initialize(bool freshlyCreated)
        {
            var lastModifiedDate = File.Exists(PROJECT_PREFERENCES_PATH)
                                ? File.GetLastWriteTime(PROJECT_PREFERENCES_PATH).Ticks
                                : 0
            ;

            if (freshlyCreated || m_ProjectPrefsLastModifiedTime != lastModifiedDate)
            {
                LoadPreferences();
            }

            if (freshlyCreated || m_RetryTextures)
            {
                LoadTextures();

                m_RetryTextures = false;

                // If WiseSVN was just added to the project, Unity won't manage to load the textures the first time. Try again next frame.
                if (FileStatusIcons[(int)VCFileStatus.Modified].image == null)
                {
                    // We're using a flag as assembly reload may happen and update callback will be lost.
                    m_RetryTextures = true;

                    EditorApplication.CallbackFunction reloadTextures = null;
                    reloadTextures = () => {
                        LoadTextures();
                        m_RetryTextures           = false;
                        EditorApplication.update -= reloadTextures;

                        if (FileStatusIcons[(int)VCFileStatus.Modified].image == null)
                        {
                            Debug.LogWarning("SVN overlay icons are missing.");
                        }
                    };

                    EditorApplication.update += reloadTextures;
                }

                Debug.Log($"Loaded WiseSVN Preferences. WiseSVN is turned {(PersonalPrefs.EnableCoreIntegration ? "on" : "off")}.");

                if (PersonalPrefs.EnableCoreIntegration)
                {
                    var svnError = "";
                    try {
                        svnError = WiseSVNIntegration.CheckForSVNErrors();
                    } catch (Exception ex) {
                        PersonalPrefs.EnableCoreIntegration = false;

                        Debug.LogError($"Calling SVN CLI (Command Line Interface) caused fatal error!\nDisabling WiseSVN integration. Please fix the error and restart Unity.\n{ex}\n\n");
#if UNITY_EDITOR_OSX
                        if (ex is IOException)
                        {
                            Debug.LogError($"If you installed SVN via Brew or similar, you may need to add \"/usr/local/bin\" (or wherever svn binaries can be found) to your PATH environment variable. Example:\nsudo launchctl config user path /usr/local/bin\nAlternatively, you may add relative SVN CLI path in your WiseSVN preferences (\"Assets/SVN/SVN Preferences -> Project\")\n");
                        }
#endif
                    }

                    // svn: warning: W155007: '...' is not a working copy!
                    // This can be returned when project is not a valid svn checkout. (Probably)
                    if (svnError.Contains("W155007"))
                    {
                        Debug.LogError("This project is NOT under version control (not a proper SVN checkout).");

                        // System.ComponentModel.Win32Exception (0x80004005): ApplicationName='...', CommandLine='...', Native error= The system cannot find the file specified.
                        // Could not find the command executable. The user hasn't installed their CLI (Command Line Interface) so we're missing an "svn.exe" in the PATH environment.
                        // This is allowed only if there isn't ProjectPreference specified CLI path.
                    }
                    else if (svnError.Contains("0x80004005"))
                    {
                        Debug.LogError("SVN CLI (Command Line Interface) not found. You need to install it in order for the SVN integration to work properly.");

                        // Any other error.
                    }
                    else if (!string.IsNullOrEmpty(svnError))
                    {
                        Debug.LogError($"SVN command line interface returned this error:\n{svnError}");
                    }
                }
            }

            SVNContextMenusManager.SetupContextType(PersonalPrefs.ContextMenusClient);
        }