From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Wolfgang Scherer Newsgroups: gmane.emacs.bugs Subject: bug#39502: [PATCH] Use one src status -a call for vc-src-dir-status-files Date: Fri, 7 Feb 2020 23:52:45 +0100 Message-ID: <2f9fe676-e135-a931-53bc-654954aead3c@gmx.de> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------388C5D07AC57D95D935C4275" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="76784"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.1 To: 39502@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Feb 07 23:53:39 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1j0CVH-000Jtl-6V for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 07 Feb 2020 23:53:39 +0100 Original-Received: from localhost ([::1]:35978 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j0CVG-000898-2K for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 07 Feb 2020 17:53:38 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56666) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j0CUh-00088v-Bm for bug-gnu-emacs@gnu.org; Fri, 07 Feb 2020 17:53:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j0CUg-0002Tq-4E for bug-gnu-emacs@gnu.org; Fri, 07 Feb 2020 17:53:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:44432) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j0CUg-0002Te-0o for bug-gnu-emacs@gnu.org; Fri, 07 Feb 2020 17:53:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1j0CUf-0004mj-Tx for bug-gnu-emacs@gnu.org; Fri, 07 Feb 2020 17:53:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Wolfgang Scherer Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 07 Feb 2020 22:53:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 39502 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: Emacs Bugs Original-Received: via spool by submit@debbugs.gnu.org id=B.158111597418374 (code B ref -1); Fri, 07 Feb 2020 22:53:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 7 Feb 2020 22:52:54 +0000 Original-Received: from localhost ([127.0.0.1]:50405 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j0CUY-0004mI-2a for submit@debbugs.gnu.org; Fri, 07 Feb 2020 17:52:54 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:41877) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j0CUW-0004mA-47 for submit@debbugs.gnu.org; Fri, 07 Feb 2020 17:52:53 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56629) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j0CUU-00088P-Hx for bug-gnu-emacs@gnu.org; Fri, 07 Feb 2020 17:52:51 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j0CUT-0002LT-4o for bug-gnu-emacs@gnu.org; Fri, 07 Feb 2020 17:52:50 -0500 Original-Received: from mout.gmx.net ([212.227.17.22]:42343) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j0CUS-0002K2-N1 for bug-gnu-emacs@gnu.org; Fri, 07 Feb 2020 17:52:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1581115966; bh=CJ8tMKmX/SYGgjFdU2DG/GOP8RZo0ulAaAbTsKjB5EU=; h=X-UI-Sender-Class:To:From:Subject:Date; b=bNt3sb5YpMMXKdhWEtAjxYzOAMqQDK33L2qvI/Bh/2MvyepRsj+6HFbf1hafMkVCV tKWCeTIZviOnxqZ92Tmviv5ccaAOk3vkZPfel6VVPNuqnUgux+Erh9p2XEgZols90W prxOy831qV0Xg4/rWtGhRZL1n7hstX6oqJCe45e8= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from sheckley.simul.de ([87.160.210.52]) by mail.gmx.com (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1N2mBQ-1jeeaA0CFQ-0138s3 for ; Fri, 07 Feb 2020 23:52:46 +0100 Original-Received: from [127.0.0.1] (sheckley.simul.de [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by sheckley.simul.de (Postfix) with ESMTPSA id A3E7419431CB for ; Fri, 7 Feb 2020 23:52:45 +0100 (CET) Openpgp: preference=signencrypt Autocrypt: addr=Wolfgang.Scherer@gmx.de; prefer-encrypt=mutual; keydata= xsDiBEb46IgRBACMHOAb1KNo1Ylk+ebri+4R+bG4tyKlqBlrpv8D9/ZwRdXSGt+0DyCHoaAd 7KW7noHapLe87DunABOjKG4nqTGv+dRiWuUBlp3I4aYRFDVa3Da+XnIYkMHKqhK59VEHQCdp Km42nuLS7TS+n99at9YwzTG6VBdOlBKTlRFngOjVLwCg1RGXJ6X3EjS1FKCQeX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LP05JQO7BcMAvFrUcRfsNU0aSfuId6BXQE4I6YMYwlYzZITGUHnU smxSP0MUKzlzGDM7CNEkzBaGEDA7n1nnkzvVSHnDuIt/LdZHRZWvI3Acsde0ONFbK1cdiX1dJ MyGk1gC8SK54wC8F5sCTovfzHtN+9V4xGCbHKPGM3vP+aLFaFalrskAL18v3jC2uMB8NAiEqY y+Xk2O5L8tMUyPn+RMDY1RXyfpEkx/8SMJbt8UxnftsYRgv4e60vQCUULajJpVjDdpPHwC/Dc IVRSFr3+eFWjA8uXBOLClIfFWTY0YkIm8CSGAuBGkEHsMg57PZMTKHnV0u3EF770GmQTGUYy3 ziqhgU91kFx7ePd5W3F6afd36nUfOgGpRUTFCKeqltUABkoIWeuQBtbTr+jFJCK5qzTl3eGCP pcULSJvdWmeNY4DSlcN8PIwKtRnovf3i/97g+yLB1T9zsgaTL9YLL7adb2irPc0URSBVtr5jP ILheBcVblGry9nA0PG2wRCDgSbco4cexWHkyuXylZLJbxhoBXWAVWA/r/f7ovYPZhuccQzP+I gTk0jgGchHJNPTgKpf2+QbZwZtDB8si2xuYx77AkZZjXulpkwYM7WW6Q0pKfR4fZU7yh87nK X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:175763 Archived-At: This is a multi-part message in MIME format. --------------388C5D07AC57D95D935C4275 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable While working on the ignore feature for SRC, I found that unregistered fil= es were not displayed in vc-dir-mode. The source code specified in a comment: =C2=A0=C2=A0 ;; FIXME: Use one src status -a call for this Here is a patch that implements that. --------------388C5D07AC57D95D935C4275 Content-Type: text/x-patch; name="0001-Use-one-src-status-a-call-for-vc-src-dir-status-file.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename*0="0001-Use-one-src-status-a-call-for-vc-src-dir-status-file.pa"; filename*1="tch" =46rom 5c3dd425d30ecb7f6afe4748d10f398dfda11ca8 Mon Sep 17 00:00:00 2001 From: Wolfgang Scherer Date: Fri, 7 Feb 2020 23:46:48 +0100 Subject: [PATCH] Use one src status -a call for vc-src-dir-status-files MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit lisp/vc/vc-src.el: (vc-src--parse-state) new function. (vc-src-state) use vc-src--parse-state. (vc-src-dir-status-files) use a single call to =E2=80=98src status -a=E2= =80=99. =2D-- lisp/vc/vc-src.el | 80 ++++++++++++++++++++++++++++++++++----------------= ----- 1 file changed, 49 insertions(+), 31 deletions(-) diff --git a/lisp/vc/vc-src.el b/lisp/vc/vc-src.el index db127ee..8f0836f 100644 =2D-- a/lisp/vc/vc-src.el +++ b/lisp/vc/vc-src.el @@ -146,48 +146,66 @@ For a description of possible values, see `vc-check-= master-templates'." (progn (defun vc-src-registered (f) (vc-default-registered 'src f))) +(defun vc-src--parse-state (out) + (when (null (string-match "does not exist or is unreadable" out)) + (let ((state (aref out 0))) + (cond + ;; FIXME: What to do about L code? + ((eq state ?.) 'up-to-date) + ((eq state ?A) 'added) + ((eq state ?M) 'edited) + ((eq state ?I) 'ignored) + ((eq state ?R) 'removed) + ((eq state ?!) 'missing) + ((eq state ??) 'unregistered) + (t 'up-to-date))))) + (defun vc-src-state (file) "SRC-specific version of `vc-state'." (let* ((status nil) (default-directory (file-name-directory file)) (out - (with-output-to-string - (with-current-buffer - standard-output - (setq status - ;; Ignore all errors. - (condition-case nil - (process-file - vc-src-program nil t nil - "status" "-a" (file-relative-name file)) - (error nil))))))) + (with-output-to-string + (with-current-buffer + standard-output + (setq status + ;; Ignore all errors. + (condition-case nil + (process-file + vc-src-program nil t nil + "status" "-a" (file-relative-name file)) + (error nil))))))) (when (eq 0 status) - (when (null (string-match "does not exist or is unreadable" out)) - (let ((state (aref out 0))) - (cond - ;; FIXME: What to do about A and L codes? - ((eq state ?.) 'up-to-date) - ((eq state ?A) 'added) - ((eq state ?M) 'edited) - ((eq state ?I) 'ignored) - ((eq state ?R) 'removed) - ((eq state ?!) 'missing) - ((eq state ??) 'unregistered) - (t 'up-to-date))))))) + (vc-src--parse-state out)))) (autoload 'vc-expand-dirs "vc") (defun vc-src-dir-status-files (dir files update-function) - ;; FIXME: Use one src status -a call for this - (if (not files) (setq files (vc-expand-dirs (list dir) 'SRC))) - (let ((result nil)) - (dolist (file files) - (let ((state (vc-state file)) - (frel (file-relative-name file))) - (when (and (eq (vc-backend file) 'SRC) - (not (eq state 'up-to-date))) - (push (list frel state) result)))) + (let* + ((result nil) + (status nil) + (default-directory (or dir default-directory)) + (out + (with-output-to-string + (with-current-buffer + standard-output + (setq status + ;; Ignore all errors. + (condition-case nil + (apply + #'process-file vc-src-program nil t nil + "status" "-a" + (mapcar (lambda (f) (file-relative-name f)) files)= ) + (error nil))))))) + (when (eq 0 status) + (dolist (line (split-string out "[\n\r]" t)) + (let* ((pair (split-string line "[\t]" t)) + (state (vc-src--parse-state (car pair))) + (frel (cadr pair))) + (when (not (eq state 'up-to-date)) + (push (list frel state) result)) + ))) (funcall update-function result))) (defun vc-src-command (buffer file-or-list &rest flags) =2D- 2.7.4 --------------388C5D07AC57D95D935C4275--