mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-09 21:53:40 +00:00
Operator to view selected object Git history #3096
A new BlenderBIM > Git History side-panel to show the raw Git log for the step entity of the selected object
This commit is contained in:
@@ -30,6 +30,7 @@ classes = (
|
|||||||
operator.DisplayUncommitted,
|
operator.DisplayUncommitted,
|
||||||
operator.Fetch,
|
operator.Fetch,
|
||||||
operator.Merge,
|
operator.Merge,
|
||||||
|
operator.ObjectLog,
|
||||||
operator.Push,
|
operator.Push,
|
||||||
operator.RefreshGit,
|
operator.RefreshGit,
|
||||||
operator.SwitchRevision,
|
operator.SwitchRevision,
|
||||||
@@ -38,6 +39,7 @@ classes = (
|
|||||||
prop.IfcGitProperties,
|
prop.IfcGitProperties,
|
||||||
ui.IFCGIT_PT_panel,
|
ui.IFCGIT_PT_panel,
|
||||||
ui.COMMIT_UL_List,
|
ui.COMMIT_UL_List,
|
||||||
|
ui.IFCGIT_PT_revision_inspector,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -278,3 +278,26 @@ class Fetch(bpy.types.Operator):
|
|||||||
remote = repo.remotes[props.select_remote]
|
remote = repo.remotes[props.select_remote]
|
||||||
remote.fetch()
|
remote.fetch()
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
class ObjectLog(bpy.types.Operator):
|
||||||
|
"""Displays Git log of selected object"""
|
||||||
|
|
||||||
|
bl_label = "Selected Object History"
|
||||||
|
bl_idname = "ifcgit.object_log"
|
||||||
|
bl_options = {"REGISTER"}
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def poll(cls, context):
|
||||||
|
if not context.active_object:
|
||||||
|
cls.poll_message_set("No Active Object")
|
||||||
|
elif not context.active_object.BIMObjectProperties.ifc_definition_id:
|
||||||
|
cls.poll_message_set("Active Object doesn't have an IFC definition")
|
||||||
|
else:
|
||||||
|
return True
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
|
||||||
|
step_id = context.active_object.BIMObjectProperties.ifc_definition_id
|
||||||
|
core.entity_log(tool.IfcGit, tool.Ifc, step_id, self)
|
||||||
|
return {"FINISHED"}
|
||||||
|
|||||||
@@ -202,3 +202,32 @@ class COMMIT_UL_List(bpy.types.UIList):
|
|||||||
else:
|
else:
|
||||||
layout.label(text=refs + commit.message, icon="DECORATE_ANIMATE")
|
layout.label(text=refs + commit.message, icon="DECORATE_ANIMATE")
|
||||||
layout.label(text=time.strftime("%c", time.localtime(commit.committed_date)))
|
layout.label(text=time.strftime("%c", time.localtime(commit.committed_date)))
|
||||||
|
|
||||||
|
|
||||||
|
class IFCGIT_PT_revision_inspector(bpy.types.Panel):
|
||||||
|
"""Tool panel to interact with revision history"""
|
||||||
|
|
||||||
|
bl_idname = "IFCGIT_PT_revision_inspector"
|
||||||
|
bl_label = "Git History"
|
||||||
|
bl_options = {"DEFAULT_CLOSED"}
|
||||||
|
bl_space_type = "VIEW_3D"
|
||||||
|
bl_region_type = "UI"
|
||||||
|
bl_category = "BlenderBIM"
|
||||||
|
|
||||||
|
def draw(self, context):
|
||||||
|
|
||||||
|
if not IfcGitData.is_loaded:
|
||||||
|
IfcGitData.load()
|
||||||
|
|
||||||
|
layout = self.layout
|
||||||
|
|
||||||
|
if not IfcGitData.data["git_exe"]:
|
||||||
|
row = layout.row()
|
||||||
|
row.label(text="Git is not installed", icon="ERROR")
|
||||||
|
return
|
||||||
|
|
||||||
|
row = layout.row()
|
||||||
|
row.operator(
|
||||||
|
"ifcgit.object_log",
|
||||||
|
icon="TEXT",
|
||||||
|
)
|
||||||
|
|||||||
@@ -71,3 +71,10 @@ def merge_branch(ifcgit, ifc, operator):
|
|||||||
path_ifc = ifc.get_path()
|
path_ifc = ifc.get_path()
|
||||||
ifcgit.config_ifcmerge()
|
ifcgit.config_ifcmerge()
|
||||||
ifcgit.execute_merge(path_ifc, operator)
|
ifcgit.execute_merge(path_ifc, operator)
|
||||||
|
|
||||||
|
|
||||||
|
def entity_log(ifcgit, ifc, step_id, operator):
|
||||||
|
path_ifc = ifc.get_path()
|
||||||
|
log_text = ifcgit.entity_log(path_ifc, step_id)
|
||||||
|
# ERROR is only way to display a multi-line message
|
||||||
|
operator.report({"ERROR"}, log_text)
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ class IfcGit:
|
|||||||
bpy.data.orphans_purge(do_recursive=True)
|
bpy.data.orphans_purge(do_recursive=True)
|
||||||
|
|
||||||
bpy.ops.bim.load_project(filepath=path_ifc)
|
bpy.ops.bim.load_project(filepath=path_ifc)
|
||||||
bpy.ops.object.select_all(action='DESELECT')
|
bpy.ops.object.select_all(action="DESELECT")
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def branches_by_hexsha(cls, repo):
|
def branches_by_hexsha(cls, repo):
|
||||||
@@ -312,7 +312,7 @@ class IfcGit:
|
|||||||
def colourise(cls, step_ids):
|
def colourise(cls, step_ids):
|
||||||
area = next(area for area in bpy.context.screen.areas if area.type == "VIEW_3D")
|
area = next(area for area in bpy.context.screen.areas if area.type == "VIEW_3D")
|
||||||
area.spaces[0].shading.color_type = "OBJECT"
|
area.spaces[0].shading.color_type = "OBJECT"
|
||||||
bpy.ops.object.select_all(action='DESELECT')
|
bpy.ops.object.select_all(action="DESELECT")
|
||||||
|
|
||||||
for obj in bpy.context.visible_objects:
|
for obj in bpy.context.visible_objects:
|
||||||
if not obj.BIMObjectProperties.ifc_definition_id:
|
if not obj.BIMObjectProperties.ifc_definition_id:
|
||||||
@@ -422,6 +422,21 @@ class IfcGit:
|
|||||||
cls.load_project(path_ifc)
|
cls.load_project(path_ifc)
|
||||||
cls.refresh_revision_list(path_ifc)
|
cls.refresh_revision_list(path_ifc)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def entity_log(cls, path_ifc, step_id):
|
||||||
|
"""Raw git log for this entity"""
|
||||||
|
repo = IfcGitRepo.repo
|
||||||
|
if not repo:
|
||||||
|
return "No repository found :("
|
||||||
|
relpath_ifc = os.path.relpath(path_ifc, repo.working_dir)
|
||||||
|
# regex only returns first match
|
||||||
|
query = "/^#" + str(step_id) + "[ =]/,/;/:" + relpath_ifc
|
||||||
|
try:
|
||||||
|
logtext = repo.git.log("-L", query, "-s")
|
||||||
|
except:
|
||||||
|
logtext = "No Git history found :("
|
||||||
|
return logtext
|
||||||
|
|
||||||
|
|
||||||
class IfcGitRepo:
|
class IfcGitRepo:
|
||||||
repo = None
|
repo = None
|
||||||
|
|||||||
Reference in New Issue
Block a user