refactor: repository api clean
This commit is contained in:
parent
98553ba00c
commit
fc4fb088bb
@ -1 +1 @@
|
|||||||
Subproject commit 207c3f44e0d31587bcf538ae74d5c6fe2139c1f9
|
Subproject commit 6c3c18c2ec6c9bd0af3bec74a3bc0e54803d076d
|
@ -85,8 +85,8 @@ def initialize_session():
|
|||||||
logging.info("Intializing the scene")
|
logging.info("Intializing the scene")
|
||||||
# Step 1: Constrect nodes
|
# Step 1: Constrect nodes
|
||||||
logging.info("Instantiating nodes")
|
logging.info("Instantiating nodes")
|
||||||
for node in session.repository.list_ordered():
|
for node in session.repository.index_sorted:
|
||||||
node_ref = session.repository.nodes.get(node)
|
node_ref = session.repository.graph.get(node)
|
||||||
if node_ref is None:
|
if node_ref is None:
|
||||||
logging.error(f"Can't construct node {node}")
|
logging.error(f"Can't construct node {node}")
|
||||||
elif node_ref.state == FETCHED:
|
elif node_ref.state == FETCHED:
|
||||||
@ -97,7 +97,7 @@ def initialize_session():
|
|||||||
|
|
||||||
# Step 2: Load nodes
|
# Step 2: Load nodes
|
||||||
logging.info("Applying nodes")
|
logging.info("Applying nodes")
|
||||||
for node in session.repository.list_ordered():
|
for node in session.repository.index_sorted:
|
||||||
porcelain.apply(session.repository, node)
|
porcelain.apply(session.repository, node)
|
||||||
|
|
||||||
logging.info("Registering timers")
|
logging.info("Registering timers")
|
||||||
@ -598,14 +598,14 @@ class SessionApply(bpy.types.Operator):
|
|||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
logging.debug(f"Running apply on {self.target}")
|
logging.debug(f"Running apply on {self.target}")
|
||||||
try:
|
try:
|
||||||
node_ref = session.repository.nodes.get(self.target)
|
node_ref = session.repository.graph.get(self.target)
|
||||||
porcelain.apply(session.repository,
|
porcelain.apply(session.repository,
|
||||||
self.target,
|
self.target,
|
||||||
force=True,
|
force=True,
|
||||||
force_dependencies=self.reset_dependencies)
|
force_dependencies=self.reset_dependencies)
|
||||||
impl = session.repository.rdp.get_implementation(node_ref.instance)
|
impl = session.repository.rdp.get_implementation(node_ref.instance)
|
||||||
if impl.bl_reload_parent:
|
if impl.bl_reload_parent:
|
||||||
for parent in session.repository.get_parents(self.target):
|
for parent in session.repository.graph.get_parents(self.target):
|
||||||
logging.debug(f"Refresh parent {parent}")
|
logging.debug(f"Refresh parent {parent}")
|
||||||
|
|
||||||
porcelain.apply(session.repository,
|
porcelain.apply(session.repository,
|
||||||
@ -801,7 +801,7 @@ class SessionLoadSaveOperator(bpy.types.Operator, ImportHelper):
|
|||||||
repo.loads(self.filepath)
|
repo.loads(self.filepath)
|
||||||
utils.clean_scene()
|
utils.clean_scene()
|
||||||
|
|
||||||
nodes = [repo.nodes.get(n) for n in repo.list_ordered()]
|
nodes = [repo.graph.get(n) for n in repo.index_sorted]
|
||||||
|
|
||||||
# Step 1: Construct nodes
|
# Step 1: Construct nodes
|
||||||
for node in nodes:
|
for node in nodes:
|
||||||
@ -847,9 +847,9 @@ classes = (
|
|||||||
|
|
||||||
|
|
||||||
def update_external_dependencies():
|
def update_external_dependencies():
|
||||||
nodes_ids = [n.uuid for n in session.repository.nodes.values() if n.data['type_id'] in ['WindowsPath', 'PosixPath']]
|
nodes_ids = [n.uuid for n in session.repository.graph.values() if n.data['type_id'] in ['WindowsPath', 'PosixPath']]
|
||||||
for node_id in nodes_ids:
|
for node_id in nodes_ids:
|
||||||
node = session.repository.nodes.get(node_id)
|
node = session.repository.graph.get(node_id)
|
||||||
if node and node.owner in [session.id, RP_COMMON]:
|
if node and node.owner in [session.id, RP_COMMON]:
|
||||||
porcelain.commit(session.repository, node_id)
|
porcelain.commit(session.repository, node_id)
|
||||||
porcelain.push(session.repository,'origin', node_id)
|
porcelain.push(session.repository,'origin', node_id)
|
||||||
@ -861,7 +861,7 @@ def sanitize_deps_graph(remove_nodes: bool = False):
|
|||||||
if session and session.state == STATE_ACTIVE:
|
if session and session.state == STATE_ACTIVE:
|
||||||
start = utils.current_milli_time()
|
start = utils.current_milli_time()
|
||||||
rm_cpt = 0
|
rm_cpt = 0
|
||||||
for node in session.repository.nodes.values():
|
for node in session.repository.graph.values():
|
||||||
node.instance = session.repository.rdp.resolve(node.data)
|
node.instance = session.repository.rdp.resolve(node.data)
|
||||||
if node is None \
|
if node is None \
|
||||||
or (node.state == UP and not node.instance):
|
or (node.state == UP and not node.instance):
|
||||||
@ -922,7 +922,7 @@ def depsgraph_evaluation(scene):
|
|||||||
# Is the object tracked ?
|
# Is the object tracked ?
|
||||||
if update.id.uuid:
|
if update.id.uuid:
|
||||||
# Retrieve local version
|
# Retrieve local version
|
||||||
node = session.repository.nodes.get(update.id.uuid)
|
node = session.repository.graph.get(update.id.uuid)
|
||||||
check_common = session.repository.rdp.get_implementation(update.id).bl_check_common
|
check_common = session.repository.rdp.get_implementation(update.id).bl_check_common
|
||||||
# Check our right on this update:
|
# Check our right on this update:
|
||||||
# - if its ours or ( under common and diff), launch the
|
# - if its ours or ( under common and diff), launch the
|
||||||
|
@ -109,8 +109,8 @@ class SessionListenTimer(Timer):
|
|||||||
class ApplyTimer(Timer):
|
class ApplyTimer(Timer):
|
||||||
def execute(self):
|
def execute(self):
|
||||||
if session and session.state == STATE_ACTIVE:
|
if session and session.state == STATE_ACTIVE:
|
||||||
for node in session.repository.nodes.keys():
|
for node in session.repository.graph.keys():
|
||||||
node_ref = session.repository.nodes.get(node)
|
node_ref = session.repository.graph.get(node)
|
||||||
|
|
||||||
if node_ref.state == FETCHED:
|
if node_ref.state == FETCHED:
|
||||||
try:
|
try:
|
||||||
@ -121,7 +121,7 @@ class ApplyTimer(Timer):
|
|||||||
else:
|
else:
|
||||||
impl = session.repository.rdp.get_implementation(node_ref.instance)
|
impl = session.repository.rdp.get_implementation(node_ref.instance)
|
||||||
if impl.bl_reload_parent:
|
if impl.bl_reload_parent:
|
||||||
for parent in session.repository.get_parents(node):
|
for parent in session.repository.graph.get_parents(node):
|
||||||
logging.debug("Refresh parent {node}")
|
logging.debug("Refresh parent {node}")
|
||||||
porcelain.apply(session.repository,
|
porcelain.apply(session.repository,
|
||||||
parent.uuid,
|
parent.uuid,
|
||||||
@ -152,7 +152,7 @@ class DynamicRightSelectTimer(Timer):
|
|||||||
|
|
||||||
# if an annotation exist and is tracked
|
# if an annotation exist and is tracked
|
||||||
if annotation_gp and annotation_gp.uuid:
|
if annotation_gp and annotation_gp.uuid:
|
||||||
registered_gp = session.repository.nodes.get(annotation_gp.uuid)
|
registered_gp = session.repository.graph.get(annotation_gp.uuid)
|
||||||
if is_annotating(bpy.context):
|
if is_annotating(bpy.context):
|
||||||
# try to get the right on it
|
# try to get the right on it
|
||||||
if registered_gp.owner == RP_COMMON:
|
if registered_gp.owner == RP_COMMON:
|
||||||
@ -165,7 +165,7 @@ class DynamicRightSelectTimer(Timer):
|
|||||||
affect_dependencies=False)
|
affect_dependencies=False)
|
||||||
|
|
||||||
if registered_gp.owner == settings.username:
|
if registered_gp.owner == settings.username:
|
||||||
gp_node = session.repository.nodes.get(annotation_gp.uuid)
|
gp_node = session.repository.graph.get(annotation_gp.uuid)
|
||||||
porcelain.commit(session.repository, gp_node.uuid)
|
porcelain.commit(session.repository, gp_node.uuid)
|
||||||
porcelain.push(session.repository, 'origin', gp_node.uuid)
|
porcelain.push(session.repository, 'origin', gp_node.uuid)
|
||||||
|
|
||||||
@ -187,7 +187,7 @@ class DynamicRightSelectTimer(Timer):
|
|||||||
|
|
||||||
# change old selection right to common
|
# change old selection right to common
|
||||||
for obj in obj_common:
|
for obj in obj_common:
|
||||||
node = session.repository.nodes.get(obj)
|
node = session.repository.graph.get(obj)
|
||||||
|
|
||||||
if node and (node.owner == settings.username or node.owner == RP_COMMON):
|
if node and (node.owner == settings.username or node.owner == RP_COMMON):
|
||||||
recursive = True
|
recursive = True
|
||||||
@ -204,7 +204,7 @@ class DynamicRightSelectTimer(Timer):
|
|||||||
|
|
||||||
# change new selection to our
|
# change new selection to our
|
||||||
for obj in obj_ours:
|
for obj in obj_ours:
|
||||||
node = session.repository.nodes.get(obj)
|
node = session.repository.graph.get(obj)
|
||||||
|
|
||||||
if node and node.owner == RP_COMMON:
|
if node and node.owner == RP_COMMON:
|
||||||
recursive = True
|
recursive = True
|
||||||
@ -233,9 +233,9 @@ class DynamicRightSelectTimer(Timer):
|
|||||||
|
|
||||||
# Fix deselection until right managment refactoring (with Roles concepts)
|
# Fix deselection until right managment refactoring (with Roles concepts)
|
||||||
if len(current_selection) == 0 :
|
if len(current_selection) == 0 :
|
||||||
owned_keys = [k for k, v in session.repository.nodes.items() if v.owner==settings.username]
|
owned_keys = [k for k, v in session.repository.graph.items() if v.owner==settings.username]
|
||||||
for key in owned_keys:
|
for key in owned_keys:
|
||||||
node = session.repository.nodes.get(key)
|
node = session.repository.graph.get(key)
|
||||||
try:
|
try:
|
||||||
porcelain.unlock(session.repository,
|
porcelain.unlock(session.repository,
|
||||||
key,
|
key,
|
||||||
|
@ -438,7 +438,7 @@ class SESSION_PT_presence(bpy.types.Panel):
|
|||||||
def draw_property(context, parent, property_uuid, level=0):
|
def draw_property(context, parent, property_uuid, level=0):
|
||||||
settings = get_preferences()
|
settings = get_preferences()
|
||||||
runtime_settings = context.window_manager.session
|
runtime_settings = context.window_manager.session
|
||||||
item = session.repository.nodes.get(property_uuid)
|
item = session.repository.graph.get(property_uuid)
|
||||||
type_id = item.data.get('type_id')
|
type_id = item.data.get('type_id')
|
||||||
area_msg = parent.row(align=True)
|
area_msg = parent.row(align=True)
|
||||||
|
|
||||||
@ -548,13 +548,13 @@ class SESSION_PT_repository(bpy.types.Panel):
|
|||||||
row = box.row()
|
row = box.row()
|
||||||
|
|
||||||
# Properties
|
# Properties
|
||||||
owned_nodes = [k for k, v in session.repository.nodes.items() if v.owner==settings.username]
|
owned_nodes = [k for k, v in session.repository.graph.items() if v.owner==settings.username]
|
||||||
|
|
||||||
filtered_node = owned_nodes if runtime_settings.filter_owned else session.repository.nodes.keys()
|
filtered_node = owned_nodes if runtime_settings.filter_owned else session.repository.graph.keys()
|
||||||
|
|
||||||
if runtime_settings.filter_name:
|
if runtime_settings.filter_name:
|
||||||
for node_id in filtered_node:
|
for node_id in filtered_node:
|
||||||
node_instance = session.repository.nodes.get(node_id)
|
node_instance = session.repository.graph.get(node_id)
|
||||||
name = node_instance.data.get('name')
|
name = node_instance.data.get('name')
|
||||||
if runtime_settings.filter_name not in name:
|
if runtime_settings.filter_name not in name:
|
||||||
filtered_node.remove(node_id)
|
filtered_node.remove(node_id)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user