Blender SVN: New Features #273
@ -456,6 +456,46 @@ class SVN_OT_resolve_conflict(May_Modifiy_Current_Blend, Operator):
|
|||||||
file_entry.status = 'normal'
|
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):
|
class SVN_OT_cleanup(SVN_Operator, Operator):
|
||||||
bl_idname = "svn.cleanup"
|
bl_idname = "svn.cleanup"
|
||||||
bl_label = "SVN Cleanup"
|
bl_label = "SVN Cleanup"
|
||||||
@ -499,5 +539,6 @@ registry = [
|
|||||||
SVN_OT_trash_file,
|
SVN_OT_trash_file,
|
||||||
SVN_OT_remove_file,
|
SVN_OT_remove_file,
|
||||||
SVN_OT_resolve_conflict,
|
SVN_OT_resolve_conflict,
|
||||||
|
SVN_OT_set_directory_depth,
|
||||||
SVN_OT_cleanup,
|
SVN_OT_cleanup,
|
||||||
]
|
]
|
||||||
|
@ -48,6 +48,17 @@ class SVN_file(PropertyGroup):
|
|||||||
options=set()
|
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(
|
status: EnumProperty(
|
||||||
name="Status",
|
name="Status",
|
||||||
description="SVN Status of the file in the local repository (aka working copy)",
|
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."),
|
("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."),
|
("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()
|
options=set()
|
||||||
)
|
)
|
||||||
include_in_commit: BoolProperty(
|
include_in_commit: BoolProperty(
|
||||||
name="Commit",
|
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,
|
default=False,
|
||||||
options=set()
|
options=set()
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_outdated(self):
|
def is_dir(self) -> bool:
|
||||||
return self.repos_status == 'modified' and self.status == 'normal'
|
|
||||||
|
|
||||||
@property
|
|
||||||
def is_dir(self):
|
|
||||||
if self.exists:
|
if self.exists:
|
||||||
return Path(self.absolute_path).is_dir()
|
return Path(self.absolute_path).is_dir()
|
||||||
else:
|
else:
|
||||||
@ -152,7 +159,7 @@ class SVN_file(PropertyGroup):
|
|||||||
return 'QUESTION'
|
return 'QUESTION'
|
||||||
|
|
||||||
@property
|
@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'
|
return self.status == 'normal' and self.repos_status == 'none' and self.status_prediction_type == 'NONE'
|
||||||
|
|
||||||
show_in_filelist: BoolProperty(
|
show_in_filelist: BoolProperty(
|
||||||
@ -161,6 +168,8 @@ class SVN_file(PropertyGroup):
|
|||||||
default=False
|
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):
|
def get_file_size(self):
|
||||||
num = self.file_size_KiB
|
num = self.file_size_KiB
|
||||||
for unit in ("KiB", "MiB", "GiB", "TiB", "PiB", "EiB"):
|
for unit in ("KiB", "MiB", "GiB", "TiB", "PiB", "EiB"):
|
||||||
@ -516,7 +525,7 @@ class SVN_repository(PropertyGroup):
|
|||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def active_file(self) -> SVN_file:
|
def active_file(self) -> Optional[SVN_file]:
|
||||||
if len(self.external_files) == 0:
|
if len(self.external_files) == 0:
|
||||||
return
|
return
|
||||||
return self.external_files[self.external_files_active_index]
|
return self.external_files[self.external_files_active_index]
|
||||||
|
@ -24,23 +24,29 @@ def svn_file_list_context_menu(self: UIList, context: Context) -> None:
|
|||||||
repo = context.scene.svn.get_repo(context)
|
repo = context.scene.svn.get_repo(context)
|
||||||
active_file = repo.active_file
|
active_file = repo.active_file
|
||||||
file_abs_path = repo.get_file_abspath(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"):
|
if active_file.name.endswith("blend"):
|
||||||
op = layout.operator("wm.open_mainfile",
|
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.filepath = str(file_abs_path)
|
||||||
op.display_file_selector = False
|
op.display_file_selector = False
|
||||||
op.load_ui = True
|
op.load_ui = True
|
||||||
op = layout.operator("wm.open_mainfile",
|
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.filepath = str(file_abs_path)
|
||||||
op.display_file_selector = False
|
op.display_file_selector = False
|
||||||
op.load_ui = False
|
op.load_ui = False
|
||||||
|
|
||||||
else:
|
else:
|
||||||
layout.operator("wm.path_open",
|
layout.operator("wm.path_open",
|
||||||
text=f"Open {active_file.name}").filepath = str(file_abs_path)
|
text=f"Open {active_file.name}", icon=active_file.file_icon).filepath = str(file_abs_path)
|
||||||
layout.operator("wm.path_open",
|
|
||||||
text=f"Open Containing Folder").filepath = Path(file_abs_path).parent.as_posix()
|
if active_file.is_dir:
|
||||||
|
layout.operator_menu_enum('svn.set_directory_depth', 'depth', text="Set SVN Depth", icon='OUTLINER')
|
||||||
|
|
||||||
layout.separator()
|
layout.separator()
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user