MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / delta_patch_node

Function delta_patch_node

src/pipeline/pipeline_delta.c:766–818  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

764}
765
766static void delta_patch_node(const cbm_gbuf_node_t *node, void *userdata) {
767 delta_patch_ctx_t *ctx = (delta_patch_ctx_t *)userdata;
768 if (ctx->failed || node->id <= ctx->max_db_id) {
769 return;
770 }
771 if (node->qualified_name) {
772 sqlite3_reset(ctx->qn_lookup);
773 sqlite3_bind_text(ctx->qn_lookup, 1, ctx->project, CBM_NOT_FOUND, SQLITE_TRANSIENT);
774 sqlite3_bind_text(ctx->qn_lookup, 2, node->qualified_name, CBM_NOT_FOUND, SQLITE_TRANSIENT);
775 if (sqlite3_step(ctx->qn_lookup) == SQLITE_ROW) {
776 /* Already on disk: an unchanged file's symbol. A node from a
777 * CHANGED file cannot appear here -- the purge removed it --
778 * so repaired files still receive fresh rows. */
779 delta_remap_put(ctx, node->id, sqlite3_column_int64(ctx->qn_lookup, 0));
780 ctx->remapped++;
781 return;
782 }
783 }
784 sqlite3_reset(ctx->node_stmt);
785 sqlite3_bind_int64(ctx->node_stmt, 1, node->id);
786 sqlite3_bind_text(ctx->node_stmt, 2, ctx->project, CBM_NOT_FOUND, SQLITE_TRANSIENT);
787 sqlite3_bind_text(ctx->node_stmt, 3, node->label, CBM_NOT_FOUND, SQLITE_TRANSIENT);
788 sqlite3_bind_text(ctx->node_stmt, 4, node->name, CBM_NOT_FOUND, SQLITE_TRANSIENT);
789 sqlite3_bind_text(ctx->node_stmt, 5, node->qualified_name, CBM_NOT_FOUND, SQLITE_TRANSIENT);
790 sqlite3_bind_text(ctx->node_stmt, 6, node->file_path ? node->file_path : "", CBM_NOT_FOUND,
791 SQLITE_TRANSIENT);
792 sqlite3_bind_int(ctx->node_stmt, 7, node->start_line);
793 sqlite3_bind_int(ctx->node_stmt, 8, node->end_line);
794 sqlite3_bind_text(ctx->node_stmt, 9, node->properties_json ? node->properties_json : "{}",
795 CBM_NOT_FOUND, SQLITE_TRANSIENT);
796 if (sqlite3_step(ctx->node_stmt) != SQLITE_DONE) {
797 ctx->failed = true;
798 char id_buf[32];
799 snprintf(id_buf, sizeof(id_buf), "%lld", (long long)node->id);
800 cbm_log_error("delta.patch_node_failed", "qn",
801 node->qualified_name ? node->qualified_name : "", "err",
802 sqlite3_errmsg(ctx->db));
803 cbm_log_error("delta.patch_node_id", "id", id_buf);
804 sqlite3_stmt *who = NULL;
805 if (sqlite3_prepare_v2(ctx->db, "SELECT label, qualified_name FROM nodes WHERE id = ?1",
806 CBM_NOT_FOUND, &who, NULL) == SQLITE_OK) {
807 sqlite3_bind_int64(who, 1, node->id);
808 if (sqlite3_step(who) == SQLITE_ROW) {
809 cbm_log_error("delta.patch_id_owner", "label",
810 (const char *)sqlite3_column_text(who, 0), "qn",
811 (const char *)sqlite3_column_text(who, 1));
812 }
813 sqlite3_finalize(who);
814 }
815 return;
816 }
817 ctx->nodes++;
818}
819
820/* An edge of a class recomputed wholesale on every run (an Image's build
821 * edges, the env join's edges): the staging graph dropped its old set, so it

Callers

nothing calls this directly

Calls 1

delta_remap_putFunction · 0.85

Tested by

no test coverage detected