From fe97283ddb298424c1579a055f285df58efd45d3 Mon Sep 17 00:00:00 2001 From: blinry Date: Wed, 13 Jan 2021 13:30:08 +0100 Subject: [PATCH] Performance: don't create trees and blobs, only update repos once --- scenes/level.gd | 3 --- scenes/main.gd | 2 +- scenes/main.tscn | 10 ++-------- scenes/repository.gd | 20 +++++++++++--------- scripts/gitconfig | 2 ++ 5 files changed, 16 insertions(+), 21 deletions(-) diff --git a/scenes/level.gd b/scenes/level.gd index aa4b247..72d7d2f 100644 --- a/scenes/level.gd +++ b/scenes/level.gd @@ -112,9 +112,6 @@ func construct(): continue game.global_shell.run("git remote add %s '%s'" % [r2, repos[r2].path]) - # Allow receiving a push of the checked-out branch. - game.global_shell.run("git config receive.denyCurrentBranch ignore") - for r in repos: var repo = repos[r] game.global_shell.cd(repo.path) diff --git a/scenes/main.gd b/scenes/main.gd index 0bc4c8c..98b179a 100644 --- a/scenes/main.gd +++ b/scenes/main.gd @@ -102,7 +102,7 @@ func load_level(level_id): terminal.clear() terminal.find_node("TextEditor").close() - update_repos() + #update_repos() # Unmute the audio after a while, so that player can hear pop sounds for # nodes they create. diff --git a/scenes/main.tscn b/scenes/main.tscn index 88a3f4c..39bd18b 100644 --- a/scenes/main.tscn +++ b/scenes/main.tscn @@ -179,11 +179,8 @@ size_flags_vertical = 3 margin_right = 633.0 margin_bottom = 60.0 rect_min_size = Vector2( 0, 60 ) -size_flags_vertical = 3 -size_flags_stretch_ratio = 0.0 custom_fonts/normal_font = ExtResource( 7 ) text = "Level name here!" -fit_content_height = true __meta__ = { "_edit_use_anchors_": false } @@ -191,14 +188,12 @@ __meta__ = { [node name="Text" type="Control" parent="Rows/Columns/RightSide/LevelInfo/LevelPanel"] margin_top = 65.0 margin_right = 633.0 -margin_bottom = 464.0 +margin_bottom = 264.0 size_flags_vertical = 3 [node name="LevelDescription" type="RichTextLabel" parent="Rows/Columns/RightSide/LevelInfo/LevelPanel/Text"] anchor_right = 1.0 anchor_bottom = 1.0 -margin_left = 0.943848 -margin_right = 0.943848 size_flags_vertical = 3 bbcode_enabled = true bbcode_text = "Level description here!" @@ -220,11 +215,10 @@ __meta__ = { } [node name="Goals" type="VBoxContainer" parent="Rows/Columns/RightSide/LevelInfo/LevelPanel"] -margin_top = 469.0 +margin_top = 269.0 margin_right = 633.0 margin_bottom = 469.0 size_flags_vertical = 3 -size_flags_stretch_ratio = 0.0 [node name="FileBrowser" parent="Rows/Columns/RightSide" instance=ExtResource( 5 )] anchor_right = 0.0 diff --git a/scenes/repository.gd b/scenes/repository.gd index ad052e0..2a2e555 100644 --- a/scenes/repository.gd +++ b/scenes/repository.gd @@ -46,6 +46,7 @@ func there_is_a_git(): return shell.run("test -d .git && echo yes || echo no") == "yes\n" func update_everything(): + print("update_everything()") if there_is_a_git(): update_head() update_refs() @@ -65,8 +66,8 @@ func set_path(new_path): for o in objects.values(): o.queue_free() objects = {} - if is_inside_tree(): - update_everything() +# if is_inside_tree(): +# update_everything() func get_path(): return path @@ -91,7 +92,11 @@ func update_objects(): continue var type = object_type(o) - + + if simplified_view: + if type == "tree" or type == "blob": + continue + var n = node.instance() n.id = o n.type = object_type(o) @@ -106,7 +111,7 @@ func update_objects(): n.content = n.content.replacen("\t", " ") "commit": var c = {} - c[commit_tree(o)] = "" + #c[commit_tree(o)] = "" for p in commit_parents(o): c[p] = "" n.children = c @@ -121,10 +126,6 @@ func update_objects(): nodes.add_child(n) objects[o] = n - if simplified_view: - if type == "tree" or type == "blob": - n.hide() - func update_node_positions(): if there_is_a_git(): var graph_text = shell.run("git log --graph --oneline --all --no-abbrev") @@ -226,7 +227,8 @@ func update_head(): n.children = {ref_target("HEAD"): ""} func all_objects(): - var obj = git("cat-file --batch-check='%(objectname)' --batch-all-objects", true) + #var obj = git("cat-file --batch-check='%(objectname)' --batch-all-objects", true) + var obj = git("cat-file --batch-check='%(objectname) %(objecttype)' --batch-all-objects | grep '\\(tag\\|commit\\)$' | cut -f1 -d' '", true) var dict = {} for o in obj: dict[o] = "" diff --git a/scripts/gitconfig b/scripts/gitconfig index 3a6e394..19a86ae 100644 --- a/scripts/gitconfig +++ b/scripts/gitconfig @@ -10,3 +10,5 @@ decorate = true [advice] detachedHead = false +[receive] + denyCurrentBranch = ignore