SVN: UX improvements #136

Merged
Demeter Dzadik merged 15 commits from Mets/blender-studio-pipeline:svn_ux_improvements into main 2023-08-01 15:39:18 +02:00
3 changed files with 20 additions and 22 deletions
Showing only changes of commit 825cfa8a96 - Show all commits

View File

@ -27,6 +27,17 @@ class SVN_addon_preferences(AddonPreferences):
repositories: CollectionProperty(type=SVN_repository) repositories: CollectionProperty(type=SVN_repository)
def init_repo_list(self):
# If we have any repository entries, make sure at least one is active.
self.sync_repo_info_file()
if self.active_repo_idx == -1 and len(self.repositories) > 0:
self.active_repo_idx = 0
elif self.active_repo_idx > len(self.repositories)-1:
self.active_repo_idx = 0
else:
self.active_repo_idx = self.active_repo_idx
def init_repo(self, context, repo_path: Path or str): def init_repo(self, context, repo_path: Path or str):
"""Attempt to initialize a repository based on a directory. """Attempt to initialize a repository based on a directory.
This means executing `svn info` in the repo_path to get the URL and root dir. This means executing `svn info` in the repo_path to get the URL and root dir.
@ -65,7 +76,7 @@ class SVN_addon_preferences(AddonPreferences):
if active_repo.authenticated: if active_repo.authenticated:
Processes.restart('Status') Processes.restart('Status')
else: else:
active_repo.authenticate(context) active_repo.authenticate()
else: else:
Processes.kill('Status') Processes.kill('Status')

View File

@ -282,10 +282,10 @@ class SVN_repository(PropertyGroup):
if get_addon_prefs(context).loading: if get_addon_prefs(context).loading:
return return
self.authenticate(context) self.authenticate()
self.update_repo_info_file(context) self.update_repo_info_file(context)
def authenticate(self, context): def authenticate(self):
self.auth_failed = False self.auth_failed = False
if self.is_valid_svn and self.is_cred_entered: if self.is_valid_svn and self.is_cred_entered:
Processes.start('Authenticate') Processes.start('Authenticate')
@ -316,7 +316,7 @@ class SVN_repository(PropertyGroup):
) )
auth_failed: BoolProperty( auth_failed: BoolProperty(
name="Authentication Failed", name="Authentication Failed",
description="Internal flag to mark whether the last entered credentials were denied by the repo", description="Internal flag to mark whether the last entered credentials were rejected by the repo",
default=False default=False
) )

View File

@ -70,14 +70,8 @@ def ensure_svn_of_current_file(_scene=None):
scene_svn = context.scene.svn scene_svn = context.scene.svn
# If we have any repository entries, make sure at least one is active. old_active_repo = prefs.active_repo
prefs.sync_repo_info_file() prefs.init_repo_list()
if prefs.active_repo_idx == -1 and len(prefs.repositories) > 0:
prefs.active_repo_idx = 0
elif prefs.active_repo_idx > len(prefs.repositories)-1:
prefs.active_repo_idx = 0
else:
prefs.active_repo_idx = prefs.active_repo_idx
# If the file is unsaved, nothing more to do. # If the file is unsaved, nothing more to do.
if not bpy.data.filepath: if not bpy.data.filepath:
@ -89,23 +83,16 @@ def ensure_svn_of_current_file(_scene=None):
if not is_in_repo: if not is_in_repo:
return return
# If we switched repos, reset auth flags and authenticate the new repo.
for repo in prefs.repositories:
# This would ideally only run when opening Blender for the first
# time, but there is no app handler for that, sadly.
repo.authenticated = False
repo.auth_failed = False
# If file is in an existing repo, we should switch over to that repo. # If file is in an existing repo, we should switch over to that repo.
for i, existing_repo in enumerate(prefs.repositories): for i, existing_repo in enumerate(prefs.repositories):
if ( existing_repo.url == scene_svn.svn_url and if ( existing_repo.url == scene_svn.svn_url and
existing_repo.directory == scene_svn.svn_directory existing_repo.directory == scene_svn.svn_directory and
existing_repo != old_active_repo
): ):
prefs.active_repo_idx = i prefs.active_repo_idx = i
break
else: else:
# If file is in a non-existing repo, initialize that repo. # If file is in a non-existing repo, initialize that repo.
repo = prefs.init_repo(context, scene_svn.svn_directory) prefs.init_repo(context, scene_svn.svn_directory)
def set_scene_svn_info(context) -> bool: def set_scene_svn_info(context) -> bool: