bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#39502: [PATCH] Use one src status -a call for vc-src-dir-status-file


From: Wolfgang Scherer
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
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.1

Am 14.02.20 um 11:05 schrieb Eli Zaretskii:
>> From: Wolfgang Scherer <address@hidden>
>> 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.

Attachment: 0001-Use-one-src-status-a-call-for-vc-src-dir-status-file.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]