unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#39502: [PATCH] Use one src status -a call for vc-src-dir-status-files
@ 2020-02-07 22:52 Wolfgang Scherer
       [not found] ` <handler.39502.B.158111597418374.ack@debbugs.gnu.org>
  2020-02-08  9:39 ` bug#39502: [PATCH] Use one src status -a call for vc-src-dir-status-files Dmitry Gutov
  0 siblings, 2 replies; 13+ messages in thread
From: Wolfgang Scherer @ 2020-02-07 22:52 UTC (permalink / raw)
  To: 39502

[-- Attachment #1: Type: text/plain, Size: 253 bytes --]

While working on the ignore feature for SRC, I found that unregistered files were not displayed in vc-dir-mode.

The source code specified in a comment:

   ;; FIXME: Use one src status -a call for this

Here is a patch that implements that.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Use-one-src-status-a-call-for-vc-src-dir-status-file.patch --]
[-- Type: text/x-patch; name="0001-Use-one-src-status-a-call-for-vc-src-dir-status-file.patch", Size: 4248 bytes --]

From 5c3dd425d30ecb7f6afe4748d10f398dfda11ca8 Mon Sep 17 00:00:00 2001
From: Wolfgang Scherer <wolfgang.scherer@gmx.de>
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=UTF-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 ‘src status -a’.
---
 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
--- 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)
--
2.7.4


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* bug#39502: Acknowledgement ([PATCH] Use one src status -a call for vc-src-dir-status-files)
       [not found] ` <handler.39502.B.158111597418374.ack@debbugs.gnu.org>
@ 2020-02-08  5:35   ` Wolfgang Scherer
  0 siblings, 0 replies; 13+ messages in thread
From: Wolfgang Scherer @ 2020-02-08  5:35 UTC (permalink / raw)
  To: 39502

[-- Attachment #1: Type: text/plain, Size: 43 bytes --]

Additional recursion into sub-directories.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Use-one-src-status-a-call-for-vc-src-dir-status-file.patch --]
[-- Type: text/x-patch; name="0001-Use-one-src-status-a-call-for-vc-src-dir-status-file.patch", Size: 4719 bytes --]

From 3ccf917bab849e438998d4717176efec46df6b98 Mon Sep 17 00:00:00 2001
From: Wolfgang Scherer <wolfgang.scherer@gmx.de>
Date: Sat, 8 Feb 2020 06:15:10 +0100
Subject: [PATCH] Use one src status -a call for vc-src-dir-status-files
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-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 ‘src status -a’.
---
 lisp/vc/vc-src.el | 90 +++++++++++++++++++++++++++++++++++--------------------
 1 file changed, 58 insertions(+), 32 deletions(-)

diff --git a/lisp/vc/vc-src.el b/lisp/vc/vc-src.el
index db127ee..ca1b7d6 100644
--- a/lisp/vc/vc-src.el
+++ b/lisp/vc/vc-src.el
@@ -146,49 +146,75 @@ 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))))
-    (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.
--
2.7.4


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* bug#39502: [PATCH] Use one src status -a call for vc-src-dir-status-files
  2020-02-07 22:52 bug#39502: [PATCH] Use one src status -a call for vc-src-dir-status-files Wolfgang Scherer
       [not found] ` <handler.39502.B.158111597418374.ack@debbugs.gnu.org>
@ 2020-02-08  9:39 ` Dmitry Gutov
  2020-02-10  0:47   ` Wolfgang Scherer
  1 sibling, 1 reply; 13+ messages in thread
From: Dmitry Gutov @ 2020-02-08  9:39 UTC (permalink / raw)
  To: Wolfgang Scherer, 39502

Hi Wolfgang,

On 08.02.2020 1:52, Wolfgang Scherer wrote:
> Here is a patch that implements that.

Hopefully someone familiar with SRC can review this. If that doesn't 
happen in a reasonable amount of time, you (or someone else) can please 
go ahead and install the latest patch version on master.





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#39502: [PATCH] Use one src status -a call for vc-src-dir-status-files
  2020-02-08  9:39 ` bug#39502: [PATCH] Use one src status -a call for vc-src-dir-status-files Dmitry Gutov
@ 2020-02-10  0:47   ` Wolfgang Scherer
  2020-02-10  4:29     ` Dmitry Gutov
  0 siblings, 1 reply; 13+ messages in thread
From: Wolfgang Scherer @ 2020-02-10  0:47 UTC (permalink / raw)
  To: Dmitry Gutov, 39502

Hi Dmitry,

Am 08.02.20 um 10:39 schrieb Dmitry Gutov:
>
> On 08.02.2020 1:52, Wolfgang Scherer wrote:
>> Here is a patch that implements that.
>
> Hopefully someone familiar with SRC can review this. If that doesn't happen in a reasonable amount of time, you (or someone else) can please go ahead and install the latest patch version on master.
I am not sure what you mean by "install the latest patch version on master"?





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#39502: [PATCH] Use one src status -a call for vc-src-dir-status-files
  2020-02-10  0:47   ` Wolfgang Scherer
@ 2020-02-10  4:29     ` Dmitry Gutov
  2020-02-11  2:54       ` Wolfgang Scherer
  0 siblings, 1 reply; 13+ messages in thread
From: Dmitry Gutov @ 2020-02-10  4:29 UTC (permalink / raw)
  To: Wolfgang Scherer, 39502

On 10.02.2020 3:47, Wolfgang Scherer wrote:
> Hi Dmitry,
> 
> Am 08.02.20 um 10:39 schrieb Dmitry Gutov:
>>
>> On 08.02.2020 1:52, Wolfgang Scherer wrote:
>>> Here is a patch that implements that.
>>
>> Hopefully someone familiar with SRC can review this. If that doesn't happen in a reasonable amount of time, you (or someone else) can please go ahead and install the latest patch version on master.
> I am not sure what you mean by "install the latest patch version on master"?

You posted two versions. Maybe there will be further revisions.





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#39502: [PATCH] Use one src status -a call for vc-src-dir-status-files
  2020-02-10  4:29     ` Dmitry Gutov
@ 2020-02-11  2:54       ` Wolfgang Scherer
  2020-02-11  7:46         ` Dmitry Gutov
  2020-02-14 10:05         ` Eli Zaretskii
  0 siblings, 2 replies; 13+ messages in thread
From: Wolfgang Scherer @ 2020-02-11  2:54 UTC (permalink / raw)
  To: Dmitry Gutov, 39502


Am 10.02.20 um 05:29 schrieb Dmitry Gutov:
> On 10.02.2020 3:47, Wolfgang Scherer wrote:
>> Hi Dmitry,
>>
>> Am 08.02.20 um 10:39 schrieb Dmitry Gutov:
>>>
>>> On 08.02.2020 1:52, Wolfgang Scherer wrote:
>>>> Here is a patch that implements that.
>>>
>>> Hopefully someone familiar with SRC can review this. If that doesn't happen in a reasonable amount of time, you (or someone else) can please go ahead and install the latest patch version on master.
>> I am not sure what you mean by "install the latest patch version on master"?
>
> 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.





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#39502: [PATCH] Use one src status -a call for vc-src-dir-status-files
  2020-02-11  2:54       ` Wolfgang Scherer
@ 2020-02-11  7:46         ` Dmitry Gutov
  2020-02-14 10:05         ` Eli Zaretskii
  1 sibling, 0 replies; 13+ messages in thread
From: Dmitry Gutov @ 2020-02-11  7:46 UTC (permalink / raw)
  To: Wolfgang Scherer, 39502

On 11.02.2020 4:54, Wolfgang Scherer wrote:
> 
> Am 10.02.20 um 05:29 schrieb Dmitry Gutov:
>> On 10.02.2020 3:47, Wolfgang Scherer wrote:
>>> Hi Dmitry,
>>>
>>> Am 08.02.20 um 10:39 schrieb Dmitry Gutov:
>>>>
>>>> On 08.02.2020 1:52, Wolfgang Scherer wrote:
>>>>> Here is a patch that implements that.
>>>>
>>>> Hopefully someone familiar with SRC can review this. If that doesn't happen in a reasonable amount of time, you (or someone else) can please go ahead and install the latest patch version on master.
>>> I am not sure what you mean by "install the latest patch version on master"?
>>
>> 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.

The Emacs master branch. That's why I said "or someone else".





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#39502: [PATCH] Use one src status -a call for vc-src-dir-status-files
  2020-02-11  2:54       ` Wolfgang Scherer
  2020-02-11  7:46         ` Dmitry Gutov
@ 2020-02-14 10:05         ` Eli Zaretskii
  2020-02-15  2:44           ` Wolfgang Scherer
  2020-08-09 11:31           ` Lars Ingebrigtsen
  1 sibling, 2 replies; 13+ messages in thread
From: Eli Zaretskii @ 2020-02-14 10:05 UTC (permalink / raw)
  To: Wolfgang Scherer; +Cc: 39502, dgutov

> From: Wolfgang Scherer <Wolfgang.Scherer@gmx.de>
> Date: Tue, 11 Feb 2020 03:54:03 +0100
> 
> >> I am not sure what you mean by "install the latest patch version on master"?
> >
> > 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.)

Thanks.





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#39502: [PATCH] Use one src status -a call for vc-src-dir-status-files
  2020-02-14 10:05         ` Eli Zaretskii
@ 2020-02-15  2:44           ` Wolfgang Scherer
  2020-08-09 11:31           ` Lars Ingebrigtsen
  1 sibling, 0 replies; 13+ messages in thread
From: Wolfgang Scherer @ 2020-02-15  2:44 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 39502, dgutov

[-- Attachment #1: Type: text/plain, Size: 3325 bytes --]

Am 14.02.20 um 11:05 schrieb Eli Zaretskii:
>> From: Wolfgang Scherer <Wolfgang.Scherer@gmx.de>
>> Date: Tue, 11 Feb 2020 03:54:03 +0100
>>
>>>> I am not sure what you mean by "install the latest patch version on master"?
>>> 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)
 ;; FIXME: Use one src status -a call for this
 (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)
  (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)))))
```

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'."
                      "status" "-a" (file-relative-name file))
                   (error nil)))))))
    (when (eq 0 status)
-   [...]
+   (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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Use-one-src-status-a-call-for-vc-src-dir-status-file.patch --]
[-- Type: text/x-patch; name="0001-Use-one-src-status-a-call-for-vc-src-dir-status-file.patch", Size: 4110 bytes --]

From 11a74c8a6df8978875b3185243d8285152e73ad6 Mon Sep 17 00:00:00 2001
From: Wolfgang Scherer <wolfgang.scherer@gmx.de>
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=UTF-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 ‘src status -a’.
---
 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
--- 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-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*
@@ -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.
--
2.7.4


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* bug#39502: [PATCH] Use one src status -a call for vc-src-dir-status-files
  2020-02-14 10:05         ` Eli Zaretskii
  2020-02-15  2:44           ` Wolfgang Scherer
@ 2020-08-09 11:31           ` Lars Ingebrigtsen
  2020-08-09 14:13             ` Eli Zaretskii
  1 sibling, 1 reply; 13+ messages in thread
From: Lars Ingebrigtsen @ 2020-08-09 11:31 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 39502, Wolfgang Scherer, dgutov

Eli Zaretskii <eliz@gnu.org> writes:

>> > 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.

Eli, this was in February.  Wolfgang spun a new version of the patch
without the whitespace changes -- did you find time to test it?

SRC is not a VC I've ever used.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#39502: [PATCH] Use one src status -a call for vc-src-dir-status-files
  2020-08-09 11:31           ` Lars Ingebrigtsen
@ 2020-08-09 14:13             ` Eli Zaretskii
  2020-08-09 17:42               ` Dmitry Gutov
  0 siblings, 1 reply; 13+ messages in thread
From: Eli Zaretskii @ 2020-08-09 14:13 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 39502, Wolfgang.Scherer, dgutov

> From: Lars Ingebrigtsen <larsi@gnus.org>
> Cc: Wolfgang Scherer <Wolfgang.Scherer@gmx.de>,  39502@debbugs.gnu.org,
>   dgutov@yandex.ru
> Date: Sun, 09 Aug 2020 13:31:23 +0200
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> >> > 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.
> 
> Eli, this was in February.  Wolfgang spun a new version of the patch
> without the whitespace changes -- did you find time to test it?

I tried, but couldn't (for boring reasons unrelated to the patch).  I
don't want to block the changes, so it's okay to install them,
provided that Dmitry agrees.





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#39502: [PATCH] Use one src status -a call for vc-src-dir-status-files
  2020-08-09 14:13             ` Eli Zaretskii
@ 2020-08-09 17:42               ` Dmitry Gutov
  2020-08-09 19:50                 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 13+ messages in thread
From: Dmitry Gutov @ 2020-08-09 17:42 UTC (permalink / raw)
  To: Eli Zaretskii, Lars Ingebrigtsen; +Cc: 39502, Wolfgang.Scherer

On 09.08.2020 17:13, Eli Zaretskii wrote:
> I tried, but couldn't (for boring reasons unrelated to the patch).  I
> don't want to block the changes, so it's okay to install them,
> provided that Dmitry agrees.

Now that I've read the code more in-depth, this part looks somewhat 
objectionable:

+                  ;; Ignore all errors.
+                  (condition-case nil

But since the patch only affects SRC (and I don't know why would anybody 
use it), I'm happy to leave the decision to others.





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#39502: [PATCH] Use one src status -a call for vc-src-dir-status-files
  2020-08-09 17:42               ` Dmitry Gutov
@ 2020-08-09 19:50                 ` Lars Ingebrigtsen
  0 siblings, 0 replies; 13+ messages in thread
From: Lars Ingebrigtsen @ 2020-08-09 19:50 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: 39502, Wolfgang.Scherer

Dmitry Gutov <dgutov@yandex.ru> writes:

> On 09.08.2020 17:13, Eli Zaretskii wrote:
>> I tried, but couldn't (for boring reasons unrelated to the patch).  I
>> don't want to block the changes, so it's okay to install them,
>> provided that Dmitry agrees.
>
> Now that I've read the code more in-depth, this part looks somewhat
> objectionable:
>
> +                  ;; Ignore all errors.
> +                  (condition-case nil
>
> But since the patch only affects SRC (and I don't know why would
> anybody use it), I'm happy to leave the decision to others.

Well, it's a bit unfortunate to apply a patch that we haven't tested,
but I've now done so anyway.  I did make some white space and stylistic
changes before applying it, though -- Wolfgang, can you check whether I
messed something up there?

But I've pushed the change to Emacs 28.1 (i.e., the Emacs trunk).

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2020-08-09 19:50 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-02-07 22:52 bug#39502: [PATCH] Use one src status -a call for vc-src-dir-status-files Wolfgang Scherer
     [not found] ` <handler.39502.B.158111597418374.ack@debbugs.gnu.org>
2020-02-08  5:35   ` bug#39502: Acknowledgement ([PATCH] Use one src status -a call for vc-src-dir-status-files) Wolfgang Scherer
2020-02-08  9:39 ` bug#39502: [PATCH] Use one src status -a call for vc-src-dir-status-files Dmitry Gutov
2020-02-10  0:47   ` Wolfgang Scherer
2020-02-10  4:29     ` Dmitry Gutov
2020-02-11  2:54       ` Wolfgang Scherer
2020-02-11  7:46         ` Dmitry Gutov
2020-02-14 10:05         ` Eli Zaretskii
2020-02-15  2:44           ` Wolfgang Scherer
2020-08-09 11:31           ` Lars Ingebrigtsen
2020-08-09 14:13             ` Eli Zaretskii
2020-08-09 17:42               ` Dmitry Gutov
2020-08-09 19:50                 ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).