From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52182) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dcYM8-0006z8-Lc for guix-patches@gnu.org; Tue, 01 Aug 2017 10:41:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dcYM2-00016y-SN for guix-patches@gnu.org; Tue, 01 Aug 2017 10:41:08 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:34385) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dcYM2-00016H-OH for guix-patches@gnu.org; Tue, 01 Aug 2017 10:41:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dcYM2-0007Kg-EZ for guix-patches@gnu.org; Tue, 01 Aug 2017 10:41:02 -0400 Subject: [bug#27907] [PATCH] graph: Provide access to the package record in the emit Resent-Message-ID: Received: from eggs.gnu.org ([2001:4830:134:3::10]:51647) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dcYLE-0006iv-3S for guix-patches@gnu.org; Tue, 01 Aug 2017 10:40:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dcYLB-0000Uh-Dk for guix-patches@gnu.org; Tue, 01 Aug 2017 10:40:12 -0400 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:56839) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dcYLB-0000UQ-9N for guix-patches@gnu.org; Tue, 01 Aug 2017 10:40:09 -0400 Received: from [143.121.198.177] (port=44040 helo=cog147) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1dcYLA-00079a-Rj for guix-patches@gnu.org; Tue, 01 Aug 2017 10:40:09 -0400 From: Roel Janssen Date: Tue, 01 Aug 2017 16:40:05 +0200 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 27907@debbugs.gnu.org --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-graph-Provide-access-to-the-package-record-in-the-em.patch >From 0243051f4a650f729e20645606d45d7138f2aa8c Mon Sep 17 00:00:00 2001 From: Roel Janssen Date: Tue, 1 Aug 2017 16:30:02 +0200 Subject: [PATCH] graph: Provide access to the package record in the emit functions. * guix/graph.scm (export-graph): Pass the node to the emit functions, instead of the node's label. --- guix/graph.scm | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/guix/graph.scm b/guix/graph.scm index d7fd5f3..0219787 100644 --- a/guix/graph.scm +++ b/guix/graph.scm @@ -22,6 +22,7 @@ #:use-module (guix monads) #:use-module (guix records) #:use-module (guix sets) + #:use-module (guix packages) #:use-module (rnrs io ports) #:use-module (srfi srfi-1) #:use-module (srfi srfi-9) @@ -170,9 +171,9 @@ typically returned by 'node-edges' or 'node-back-edges'." name)) (define (emit-epilogue port) (display "\n}\n" port)) -(define (emit-node id label port) +(define (emit-node id node port) (format port " \"~a\" [label = \"~a\", shape = box, fontname = Helvetica];~%" - id label)) + id (package-full-name node))) (define (emit-edge id1 id2 port) (format port " \"~a\" -> \"~a\" [color = ~a];~%" id1 id2 (pop-color id1))) @@ -213,11 +214,11 @@ var nodes = {}, (format port "" (search-path %load-path "graph.js"))) -(define (emit-d3js-node id label port) +(define (emit-d3js-node id node port) (format port "\ nodes[\"~a\"] = {\"id\": \"~a\", \"label\": \"~a\", \"index\": nodeArray.length}; nodeArray.push(nodes[\"~a\"]);~%" - id id label id)) + id id (package-full-name node) id)) (define (emit-d3js-edge id1 id2 port) (format port "links.push({\"source\": \"~a\", \"target\": \"~a\"});~%" @@ -241,9 +242,9 @@ nodeArray.push(nodes[\"~a\"]);~%" (define (emit-cypher-epilogue port) (format port "")) -(define (emit-cypher-node id label port) +(define (emit-cypher-node id node port) (format port "MERGE (p:Package { id: ~s }) SET p.name = ~s;~%" - id label )) + id (package-name node))) (define (emit-cypher-edge id1 id2 port) (format port "MERGE (a:Package { id: ~s });~%" id1) @@ -296,7 +297,7 @@ true, draw reverse arrows." (ids (mapm %store-monad node-identifier dependencies))) - (emit-node id (node-label head) port) + (emit-node id head port) (for-each (lambda (dependency dependency-id) (if reverse-edges? (emit-edge dependency-id id port) -- 2.7.4 --=-=-= Content-Type: text/plain Dear Guix, I would like to expand the Cypher back-end and in the long run add a SPARQL graph back-end to GNU Guix. For this, I will need to have access to the package records inside the emit-* functions. This patch makes this change by essentially changing the "label" parameter of the emit-* functions passed as "(node-label head)" into a "node" parameter, passed as "head". The rest of the patch adapts the current emit-* functions to this change. I tested the Graphviz, D3js, and Cypher back-ends, and all seem to work as before. Is it OK to apply this change? Kind regards, Roel Janssen --=-=-=--