SVN: UX improvements #136
@ -27,6 +27,17 @@ class SVN_addon_preferences(AddonPreferences):
|
||||
|
||||
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):
|
||||
"""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.
|
||||
@ -65,7 +76,7 @@ class SVN_addon_preferences(AddonPreferences):
|
||||
if active_repo.authenticated:
|
||||
Processes.restart('Status')
|
||||
else:
|
||||
active_repo.authenticate(context)
|
||||
active_repo.authenticate()
|
||||
else:
|
||||
Processes.kill('Status')
|
||||
|
||||
|
@ -282,10 +282,10 @@ class SVN_repository(PropertyGroup):
|
||||
if get_addon_prefs(context).loading:
|
||||
return
|
||||
|
||||
self.authenticate(context)
|
||||
self.authenticate()
|
||||
self.update_repo_info_file(context)
|
||||
|
||||
def authenticate(self, context):
|
||||
def authenticate(self):
|
||||
self.auth_failed = False
|
||||
if self.is_valid_svn and self.is_cred_entered:
|
||||
Processes.start('Authenticate')
|
||||
@ -316,7 +316,7 @@ class SVN_repository(PropertyGroup):
|
||||
)
|
||||
auth_failed: BoolProperty(
|
||||
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
|
||||
)
|
||||
|
||||
|
@ -70,14 +70,8 @@ def ensure_svn_of_current_file(_scene=None):
|
||||
|
||||
scene_svn = context.scene.svn
|
||||
|
||||
# If we have any repository entries, make sure at least one is active.
|
||||
prefs.sync_repo_info_file()
|
||||
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
|
||||
old_active_repo = prefs.active_repo
|
||||
prefs.init_repo_list()
|
||||
|
||||
# If the file is unsaved, nothing more to do.
|
||||
if not bpy.data.filepath:
|
||||
@ -89,23 +83,16 @@ def ensure_svn_of_current_file(_scene=None):
|
||||
if not is_in_repo:
|
||||
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.
|
||||
for i, existing_repo in enumerate(prefs.repositories):
|
||||
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
|
||||
break
|
||||
else:
|
||||
# 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:
|
||||
|
Loading…
Reference in New Issue
Block a user