From patchwork Thu May 6 07:50:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: M X-Patchwork-Id: 29146 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id CB6C327BC82; Thu, 6 May 2021 08:52:15 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,T_DKIM_INVALID,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 9427227BC81 for ; Thu, 6 May 2021 08:52:11 +0100 (BST) Received: from localhost ([::1]:41862 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1leYnq-0001aU-Py for patchwork@mira.cbaines.net; Thu, 06 May 2021 03:52:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40748) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leYni-0001ZA-Kf for guix-patches@gnu.org; Thu, 06 May 2021 03:52:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:53635) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1leYni-00072M-CM for guix-patches@gnu.org; Thu, 06 May 2021 03:52:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1leYni-0002GI-Bb for guix-patches@gnu.org; Thu, 06 May 2021 03:52:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#48120] [PATCH] Teach etc/committer.scm.in some stuff References: In-Reply-To: Resent-From: Maxime Devos Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 06 May 2021 07:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48120 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 48120@debbugs.gnu.org Received: via spool by 48120-submit@debbugs.gnu.org id=B48120.16202874738654 (code B ref 48120); Thu, 06 May 2021 07:52:02 +0000 Received: (at 48120) by debbugs.gnu.org; 6 May 2021 07:51:13 +0000 Received: from localhost ([127.0.0.1]:36945 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1leYmq-0002FV-Qv for submit@debbugs.gnu.org; Thu, 06 May 2021 03:51:12 -0400 Received: from xavier.telenet-ops.be ([195.130.132.52]:47878) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1leYmk-0002Ec-J6 for 48120@debbugs.gnu.org; Thu, 06 May 2021 03:51:07 -0400 Received: from ptr-bvsjgyjmffd7q9timvx.18120a2.ip6.access.telenet.be ([IPv6:2a02:1811:8c09:9d00:aaf1:9810:a0b8:a55d]) by xavier.telenet-ops.be with bizsmtp id 1Kr02500A0mfAB401Kr0wF; Thu, 06 May 2021 09:51:00 +0200 Message-ID: <039cd7066fe774cb6c3faad5e745da158d865485.camel@telenet.be> From: Maxime Devos Date: Thu, 06 May 2021 09:50:53 +0200 User-Agent: Evolution 3.34.2 MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r21; t=1620287460; bh=e5qJffcaIUJGsno6MDZ0w9Hj8YRDQ3gOCbbUDCcV5/k=; h=Subject:From:To:Date; b=r1gVgKH2t1mvIBGcpfCLIUWWd8ImAIyPRfbuhejQg+6a6+UAGdgUkKPLknAOuBphR hSyNKZ1M/exGrMItwnoti7nm2+XuEGCVy3YCh6NoolxX+zenjkqMMFtEiqL4Up74lS oQ7veS9Mwxa5+GYsUSBPTnK7K7pnwkh0EGADs9GN26YPW5uP6tpAcElfDRFqyn0shx AKKILE9TQf4h3p3F4+mOGsyHVP3pvfwqimsO1AIM7d9Hy54hsywM7ZL/ynHM8Ez9tZ 5kwUMKkMgw3IK1Qd0KhW1Iy69M3lHYGEnU1cNBQ71K+NRKTmUU7y+30gB31kjSlUr2 gf90eu6WFmlXw== X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches New patch series, handling more edge cases. It needs some changes in how it wraps lines now there is a break-string procedure, but I don't have time to work on this currently so I'll just submit it as-is for now. Greetings, Maxime. From 5f0313c01121a0a1e7f39f447425b5a8b70fb8c0 Mon Sep 17 00:00:00 2001 From: Maxime Devos Date: Sat, 1 May 2021 12:19:05 +0200 Subject: [PATCH 11/11] etc: committer: Handle substitute-keyword-arguments. * etc/committer.scm.in (keyword-list->alist): Rename to ... (keyword-list->alist/list): ..., and document the input format. While we're at it, correct the arguments to 'warning'. (keyword-list->alist/possibly-quoted): New procedure, removing 'quote', 'quasiquote' and supporting 'substitute-keyword-arguments'. (pairwise-foreach-keyword): Use new procedure. (unwrap-list): Also remove 'quote' and 'quasiquote' when in a 'let', 'let*' form. Does not strictly belong in this commit, but it was required for my test case. (change-commit-message/one-pass)[get-values/list]: Remove ... (change-commit-message/one-pass)[get-values/no-unquote]: ... and replace with this. (change-commit-message/one-pass): Use new procedure get-values/no-unquote instead of get-values/list. --- etc/committer.scm.in | 41 ++++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/etc/committer.scm.in b/etc/committer.scm.in index c056de912c..7c63e38e8a 100755 --- a/etc/committer.scm.in +++ b/etc/committer.scm.in @@ -207,18 +207,34 @@ corresponding to the top-level definition containing the staged changes." (+ (lines-to-first-change hunk) (hunk-new-line-number hunk)))))) -(define (keyword-list->alist kwlist) +;; Input: a list of keywords and the corresponding values, +;; without an exterior quote, quasiquote or list. +(define (keyword-list->alist/list kwlist) (match kwlist (() '()) (((? keyword? k) object . rest) `((,k . ,object) . ,(keyword-list->alist rest))) - (_ (warning (G_ "cannot interpret as keyword argument list: ‘~a’~%") '()) + (_ (warning (G_ "cannot interpret as keyword argument list: ‘~a’~%") kwlist) + '()))) + +;; Input: an expression representing a list of keywords and the corresponding +;; values, including any exterior quote, quasiquote or list. +(define (keyword-list->alist/possibly-quoted list-sexp) + (match list-sexp + (((or 'quote 'quasiquote) l) + (keyword-list->alist/list l)) + ((substitute-keyword-arguments _ (((? keyword? k) _) l) ...) + (map (lambda (key value) + (cons key (unwrap-list value))) + k l)) + (_ (warning (G_ "cannot interpret as keyword argument list: ‘~a’~%") + list-sexp) '()))) (define (pairwise-foreach-keyword proc . arguments) "Apply PROC with each keyword argument and corresponding values in ARGUMENTS. If a value is not present in a argument, pass #f instead." - (let* ((alists (map keyword-list->alist arguments)) + (let* ((alists (map keyword-list->alist/possibly-quoted arguments)) (keywords (delete-duplicates (apply append (map (cut map car <>) alists)) eq?))) @@ -301,12 +317,13 @@ Return false if all changes could be explained and truth otherwise." ;; '(x ...) -> (x ...) ;; `(x ...) -> (x ...) ;; (list x ...) -> (x ...) +;; and remove let and let* bindings (define (unwrap-list list) (case (car list) ((quasiquote quote) (second list)) ((list) (cdr list)) ;; Hopefully the bindings weren't important ... - ((let let*) (last list)) + ((let let*) (unwrap-list (last list))) (else (error "I can't interpret that as a list!")))) (define* (change-commit-message/one-pass @@ -322,14 +339,12 @@ SUMMARY: first using a ‘void port’, then with the ‘real’ output port." (() '()) ((first . rest) (map cadadr first)))) - ;; Like get-values, but also allow quote and do not treat - ;; the value of the field as an alist. - (define (get-values/list expr field) - (match ((sxpath `(// ,field ,(node-or (sxpath '(quasiquote)) - (sxpath '(quote))))) expr) + ;; Like get-values, but do not remove the exterior quasiquote + ;; or quote. + (define (get-values/no-unquote expr field) + (match ((sxpath `(// ,field *)) expr) (() '()) - ((first . rest) - (second first)))) + ((first . rest) first))) (define (listify items) (match items ((one) one) @@ -444,8 +459,8 @@ SUMMARY: first using a ‘void port’, then with the ‘real’ output port." (_ (format port "[arguments]<#:phases>: Update.~%")))) ;; There were some unexplained changes. (else (format port "[arguments]<~a>: Update.~%" keyword))))) - (let ((old-arguments (or (get-values/list old 'arguments) '())) - (new-arguments (or (get-values/list new 'arguments) '()))) + (let ((old-arguments (get-values/no-unquote old 'arguments)) + (new-arguments (get-values/no-unquote new 'arguments))) (pairwise-foreach-keyword explain-argument old-arguments new-arguments))) -- 2.31.1