Subject: bug#34949: 27.0.50; Docstring of `vc-deduce-fileset' incomplete

From: Dmitry Gutov <[email-masked]>
Date: Wed, 19 Feb 2020 00:27:12 +0200

On 18.02.2020 1:42, Juri Linkov wrote:

> The difficultly comes from the need to get a VC state from every marked file
> and to confirm that all marked files are in the same state.

Makes sense, that was my second guess.

> So I implemented this in vc-dired-deduce-fileset whose basic
> algorithm was taken from vc-dir-deduce-fileset.
> 
> Now with this patch state changing VC operations are supported on marked
> _files_ in dired.

TBH, I'm not sure this is a win (we have VC-Dir for a reason), but if 
you really want to be able to do that in Dired, why not. Please feel 
free to install this.

> However, the need for the OBSERVER arg still remains because this patch
> doesn't support state changing VC operations on marked _directories_ in dired.
> It raises the error in this case:
> 
>    State changing VC operations on directories not supported in `dired-mode'
> 
> State changing VC operations could be supported on directories as well,
> but there are several possibilities to choose from, and I can't decide:
> 
> 1. On a marked directory get a state from all its files
>     (probably this variant makes no sense)
> 
> 2. On a marked directory get only files with a "modified" state
>     (i.e. edited/added/removed)

You can check out what diff-hl-dired does in this regard (and it does 
use the dir-status-files command), though you would need to do something 
else than its merging logic.

That still leaves the downside (compared to VC-Dir) of being unable to 
select individual files in subdirectories, but that's not fixable, I guess.

> But the latter is not easy to implement because the needed functionality
> is missing in VC, because the only VC method that is suitable for this is
> 'dir-status-files' to get VC files from a directory but it's too tightly
> integrated with vc-dir and can't be easily separated, i.e. there is
> no easy way to do something like:
> 
>    (with-temp-buffer
>      (vc-call-backend
>       (vc-responsible-backend default-directory) 'dir-status-files default-directory nil
>       (lambda (entries &optional more-to-come)
>         (message "! %S" entries))))

I think the only possible problem here is that lambda is invoked 
asynchronously. But we can sleep while waiting for it.