Blender SVN: New Features #273

Open
Demeter Dzadik wants to merge 13 commits from New-SVN-features into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
3 changed files with 70 additions and 14 deletions
Showing only changes of commit bf0e711d11 - Show all commits

View File

@ -456,6 +456,46 @@ class SVN_OT_resolve_conflict(May_Modifiy_Current_Blend, Operator):
file_entry.status = 'normal'
class SVN_OT_set_directory_depth(Operator):
bl_idname = "svn.set_directory_depth"
bl_label = "Set Directory Depth"
bl_description = "Set update depth of this directory"
bl_options = {'INTERNAL'}
depth: EnumProperty(
name="Depth",
description="The depth to which this directory should be updated", # For non-directory entries, this property is not used.
items=[
('INFINITY', 'Recursive (Default)', "Default update behaviour: Updates will recursively pull in any files or subdirectories not already present", 'OUTLINER', 3),
('IMMEDIATES', 'Non-Recursive', "Updates will pull in any files or subdirectories not already present; those subdirectories' will be left empty", 'PRESET', 2),
('FILES', 'Files Only', "Updates will pull in any files not already present, but not subdirectories", 'FILE', 1),
('EMPTY', 'Empty', "Updates will not pull in any files or subdirectories not already present", 'SELECT_SET', 0),
],
default='INFINITY'
)
@classmethod
def description(cls, context, properties):
depth = cls.__annotations__['depth']
desc = depth.keywords['description']
items = depth.keywords['items']
for identifier, name, item_desc, icon, num in items:
if identifier == properties.depth:
return desc + ":\n" + item_desc
def execute(self, context):
repo = context.scene.svn.get_repo(context)
active_file = repo.active_file
if not active_file.is_dir:
self.report({'ERROR'}, "Active file entry is not a directory")
return {'CANCELLED'}
active_file.depth = self.depth
return {'FINISHED'}
class SVN_OT_cleanup(SVN_Operator, Operator):
bl_idname = "svn.cleanup"
bl_label = "SVN Cleanup"
@ -499,5 +539,6 @@ registry = [
SVN_OT_trash_file,
SVN_OT_remove_file,
SVN_OT_resolve_conflict,
SVN_OT_set_directory_depth,
SVN_OT_cleanup,
]

View File

@ -48,6 +48,17 @@ class SVN_file(PropertyGroup):
options=set()
)
depth: EnumProperty(
name="Depth",
description="The depth to which this directory should be updated. If this is a file and not a directory, this value isn't used",
items=[
('EMPTY', 'empty', "Updates will not pull in any files or subdirectories not already present"),
('FILES', 'files', "Updates will pull in any files not already present, but not subdirectories"),
('IMMEDIATES', 'immediates', "Updates will pull in any files or subdirectories not already present; those subdirectories' will have depth=empty"),
('INFINITY', 'infinity', "Default update behaviour: Updates will pull in any files or subdirectories not already present; those subdirectories' will have depth-infinity"),
],
default='INFINITY'
)
status: EnumProperty(
name="Status",
description="SVN Status of the file in the local repository (aka working copy)",
@ -76,22 +87,18 @@ class SVN_file(PropertyGroup):
("SKIP_ONCE", "Skip Once", "File status is predicted by a working-copy svn file operation, like Revert. Next status update should be ignored, and this enum should be set to SKIPPED_ONCE."),
("SKIPPED_ONCE", "Skipped Once", "File status update was skipped. Next status update can be considered accurate, and this flag can be reset to NONE. Until then, operations on this file should remain disabled."),
],
description="Internal flag that notes what process set a predicted status on this file. Should be empty string when the status is not predicted but confirmed. When svn commit/update predicts a status, that status should not be overwritten until the process is finished. With instantaneous processes, a single status update should be ignored since it may be outdated",
description="Internal flag that notes what process set a predicted status on this file. Used to prevent conflicting operations while one operation is in progress",
options=set()
)
include_in_commit: BoolProperty(
name="Commit",
description="Whether this file should be included in the commit or not",
description="Whether this file should be included in the commit or not. Used by the commit operator UI",
default=False,
options=set()
)
@property
def is_outdated(self):
return self.repos_status == 'modified' and self.status == 'normal'
@property
def is_dir(self):
def is_dir(self) -> bool:
if self.exists:
return Path(self.absolute_path).is_dir()
else:
@ -152,7 +159,7 @@ class SVN_file(PropertyGroup):
return 'QUESTION'
@property
def has_default_status(self):
def has_default_status(self) -> bool:
return self.status == 'normal' and self.repos_status == 'none' and self.status_prediction_type == 'NONE'
show_in_filelist: BoolProperty(
@ -161,6 +168,8 @@ class SVN_file(PropertyGroup):
default=False
)
### File size - Update a string representation one time when file_size_KiB is set. ###
### We want to avoid re-calculating that string on every re-draw for optimization. ###
def get_file_size(self):
num = self.file_size_KiB
for unit in ("KiB", "MiB", "GiB", "TiB", "PiB", "EiB"):
@ -516,7 +525,7 @@ class SVN_repository(PropertyGroup):
)
@property
def active_file(self) -> SVN_file:
def active_file(self) -> Optional[SVN_file]:
if len(self.external_files) == 0:
return
return self.external_files[self.external_files_active_index]

View File

@ -24,23 +24,29 @@ def svn_file_list_context_menu(self: UIList, context: Context) -> None:
repo = context.scene.svn.get_repo(context)
active_file = repo.active_file
file_abs_path = repo.get_file_abspath(active_file)
layout.operator("wm.path_open",
text=f"Open Containing Folder", icon='FILE_FOLDER').filepath = Path(file_abs_path).parent.as_posix()
if active_file.name.endswith("blend"):
op = layout.operator("wm.open_mainfile",
text=f"Open {active_file.name}")
text=f"Open {active_file.name}", icon='FILE_BLEND')
op.filepath = str(file_abs_path)
op.display_file_selector = False
op.load_ui = True
op = layout.operator("wm.open_mainfile",
text=f"Open {active_file.name} (Keep UI)")
text=f"Open {active_file.name} (Keep UI)", icon='FILE_BLEND')
op.filepath = str(file_abs_path)
op.display_file_selector = False
op.load_ui = False
else:
layout.operator("wm.path_open",
text=f"Open {active_file.name}").filepath = str(file_abs_path)
layout.operator("wm.path_open",
text=f"Open Containing Folder").filepath = Path(file_abs_path).parent.as_posix()
text=f"Open {active_file.name}", icon=active_file.file_icon).filepath = str(file_abs_path)
if active_file.is_dir:
layout.operator_menu_enum('svn.set_directory_depth', 'depth', text="Set SVN Depth", icon='OUTLINER')
layout.separator()