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: Sat, 15 Feb 2020 03:44:40 +0100 Message-ID: <7baabba4-5874-4593-592b-7b1e8172e0f9@gmx.de> References: <2f9fe676-e135-a931-53bc-654954aead3c@gmx.de> <7a12e354-a1ee-8208-eb08-b0d7281bce39@yandex.ru> <357c1eae-5a6c-602c-db55-4be7858f9899@yandex.ru> <66c31ba7-fbb6-e287-2522-50abab0638a6@gmx.de> <837e0ppjpg.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------37A228C426548C2D7894EE2A" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="34181"; 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 Cc: 39502@debbugs.gnu.org, dgutov@yandex.ru To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Feb 15 03:45:48 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 1j2nSl-0008hw-Ij for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 15 Feb 2020 03:45:47 +0100 Original-Received: from localhost ([::1]:47592 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j2nSk-0006io-56 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 14 Feb 2020 21:45:46 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38737) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j2nS3-0006fZ-Fc for bug-gnu-emacs@gnu.org; Fri, 14 Feb 2020 21:45:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j2nS1-0006nZ-Qj for bug-gnu-emacs@gnu.org; Fri, 14 Feb 2020 21:45:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:57208) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j2nS1-0006nT-Ml for bug-gnu-emacs@gnu.org; Fri, 14 Feb 2020 21:45:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1j2nS1-00007B-L9 for bug-gnu-emacs@gnu.org; Fri, 14 Feb 2020 21:45: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: Sat, 15 Feb 2020 02:45:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 39502 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 39502-submit@debbugs.gnu.org id=B39502.1581734691411 (code B ref 39502); Sat, 15 Feb 2020 02:45:01 +0000 Original-Received: (at 39502) by debbugs.gnu.org; 15 Feb 2020 02:44:51 +0000 Original-Received: from localhost ([127.0.0.1]:34948 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j2nRr-00006Y-24 for submit@debbugs.gnu.org; Fri, 14 Feb 2020 21:44:51 -0500 Original-Received: from mout.gmx.net ([212.227.15.18]:56673) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j2nRp-00006J-M4 for 39502@debbugs.gnu.org; Fri, 14 Feb 2020 21:44:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1581734683; bh=vv5qMVc2pdZBgSBIHMhusyAAQSBNkR2nSPyMKDjSMkI=; h=X-UI-Sender-Class:Subject:To:Cc:References:From:Date:In-Reply-To; b=A5bIi6HitKax74qQdNAk7/5/ulET5tAqdcokIelO0JHY2Ubuu88b86VKOpheTvaM4 M5eiKlA3W4qh8TGTrMYMPLexEU3bSiJIh2ZzwA31+m5/F1/NYUOWzerG/uq55rTODF h/oDVR1A6PX1hZlasQfakYQKQ+Y78TAzlM+brgzo= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from sheckley.simul.de ([87.160.210.52]) by mail.gmx.com (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MJE2D-1imUa13aaR-00KkVh; Sat, 15 Feb 2020 03:44:42 +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 077E619431DD; Sat, 15 Feb 2020 03:44:40 +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+n99at9YwzTG6VBdOlBKTlRFngOjVLwCg1RGXJ6X3EjS1FKCQeXziURVpWlkD /2zY6Ayhxi62TS84VjikXrrmjXykAAaAmMVEyKKYb9L5pGlqiZz9g/K9xw1EUoZTYuaufquD v4rAGR58K/3V4CYfJLEeshMWiaXHvMmlxMznlG16/um4MvmR8B3r+cx0nOPK1JBdD2qrkNnF Mw8FB+zouLFB4Gt2IUC5IlOmZ8OQA/4qdU53CItzWsCr9Nux4L0qUlRweSmCnV8x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Qu2hb5C3FAef 82IzADV4ejAafrFKjfiv/0sVib95K+HR3SlG5n3Ww2cVJZKJClInBXtpLjl4Zw7xJxOwkKzio 9zxi1eobtHUwoG1yfKPHQdwANqOis+8H6UU/8kub36kQakS/YvDAryDJWMmpP/AwSJTkVxnSV 3oo2UzNj/0B0EZSBZNU1ODFqHO/9pKFHug7JT9l1m7k68V9voTYqaW9rE1mNvEJ/XfWhYis0y +Z3xtGBzxtamcZBcWBdp4tlpunaV9NnUkBqIaFMYQh9dgMYC7pUBw1v+Bkztm5Vv0xr6X2NXj y8cfmfW2ORDsgK4b0Sm42fk7JtXtmbCspWY63RFjdjQW8LHe5ZUnA9lcfDtrRWjj3yRKZ9e1G kcV+MOhPlRXZn+NpZ5T+1OFyqwqpKB+uEMeA+rtWZ2oRYnTjnTcFrb2J6hPhSR1qqs6JBpTx 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:176074 Archived-At: This is a multi-part message in MIME format. --------------37A228C426548C2D7894EE2A Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Am 14.02.20 um 11:05 schrieb Eli Zaretskii: >> From: Wolfgang Scherer >> Date: Tue, 11 Feb 2020 03:54:03 +0100 >> >>>> I am not sure what you mean by "install the latest patch version on m= aster"? >>> You posted two versions. Maybe there will be further revisions. >> I am not planning on any :-). But I am still not sure, which master you= mean. I have no write access to the repository. > Can you describe a simple use case to test your patch, and tell what > are the differences between the situation before and after the patch? > Then I will try the changes, and install them if I see no problems. > > (I'm asking for details because at least part of the changes are > simply white-space changes, and it isn't easy to identify the part(s) > that really change the code workings.) Sorry, I have a whitespace cleaner command that I keep using unconciously. The use case is to have a SRC repository with another SRC sub-repositoy, which in turn contains a further SRC repository. When entering *vc-dir-mode* with `M-x vc-dir` in the topmost repository, the status of all files in all 3 respositories should be shown. OK, the change is not so hard to understand when you know the sequence of events. At First, only *vc-src--parse-state* used a call to `src status -a` to inquire about a single FILE. *vc-src-dir-status-files* used *vc-expand-dirs* to get the status for all files. There was a comment saying it should be fixed by using one call to `src status -a` instead: ```elisp (defun vc-src-dir-status-files (dir files update-function) =C2=A0;; FIXME: Use one src status -a call for this =C2=A0(if (not files) (setq files (vc-expand-dirs (list dir) 'SRC))) ``` The difference is, that the call to `src status -a` provides a more detailed status for all files in a directory with just a single call. This is faster and helps managing the ignore files better. The first step was to extract the status parser as *vc-src--parse-state* for reuse in *vc-srv-dir-status-files*: ```elisp (defun vc-src--parse-state (out) =C2=A0 (when (null (string-match "does not exist or is unreadable" out)) =C2=A0=C2=A0=C2=A0 (let ((state (aref out 0))) =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (cond =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ;; FIXME: What to do about L code? =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ((eq state ?.) 'up-to-date) =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ((eq state ?A) 'added) =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ((eq state ?M) 'edited) =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ((eq state ?I) 'ignored) =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ((eq state ?R) 'removed) =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ((eq state ?!) 'missing) =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ((eq state ??) 'unregistered) =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (t 'up-to-date))))) ``` The code in *vc-src-state* was replaced by a single call to *vc-src--parse-state*: ```diff @@ -163,32 +177,44 @@ For a description of possible values, see `vc-check-= master-templates'." =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 "status" "-a" (file= -relative-name file)) =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (error nil))))))) =C2=A0=C2=A0=C2=A0 (when (eq 0 status) -=C2=A0=C2=A0 [...] +=C2=A0=C2=A0 (vc-src--parse-state out)))) ``` The last diff is a complete refactoring of *vc-src-dir-status-files* to parse directories recursively, so there is no common code. The user visible changes are just that unregistered and ignored files are also shown. Everything else is necessarily identical. I have attached a new patch with minimal whitespace changes. --------------37A228C426548C2D7894EE2A 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 11a74c8a6df8978875b3185243d8285152e73ad6 Mon Sep 17 00:00:00 2001 From: Wolfgang Scherer Date: Sat, 15 Feb 2020 03:42:52 +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 recursive calls to =E2=80=98src status -a=E2= =80=99. =2D-- lisp/vc/vc-src.el | 70 ++++++++++++++++++++++++++++++++++++++------------= ----- 1 file changed, 48 insertions(+), 22 deletions(-) diff --git a/lisp/vc/vc-src.el b/lisp/vc/vc-src.el index db127ee..fce93ef 100644 =2D-- a/lisp/vc/vc-src.el +++ b/lisp/vc/vc-src.el @@ -146,6 +146,20 @@ For a description of possible values, see `vc-check-m= aster-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* @@ -163,32 +177,44 @@ For a description of possible values, see `vc-check-= master-templates'." "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)))) - (funcall update-function 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)))))) + dlist) + (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))) + (if (file-directory-p frel) + (push frel dlist) + (when (not (eq state 'up-to-date)) + (push (list frel state) result))) + )) + (dolist (drel dlist) + (let* ((dresult (vc-src-dir-status-files (expand-file-name drel) = nil #'identity))) + (dolist (dres dresult) + (push (list (concat (file-name-as-directory drel) (car dres))= (cadr dres)) result))) + ) + (funcall update-function result)))) (defun vc-src-command (buffer file-or-list &rest flags) "A wrapper around `vc-do-command' for use in vc-src.el. =2D- 2.7.4 --------------37A228C426548C2D7894EE2A--