emacs-devel
[Top][All Lists]
Advanced

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

Re: A project-files implementation for Git projects


From: Tassilo Horn
Subject: Re: A project-files implementation for Git projects
Date: Tue, 10 Sep 2019 15:39:01 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Stefan Monnier <address@hidden> writes:

Hi Stefan,

>> Would that mean that I would need to add functions
>>
>>   vc-git-list-files (using: git ls-files)
>>   vc-hg-list-files (using: hg files)
>>   ...
>>
>> for all backends which support listing tracked files?
>
> For all backends for which you want to implement the feature yes.  For
> the rest, you define `vc-default-list-files` instead.

But what should this do?  From a vc list-files function I'd expect (and
document) that it lists all and only tracked files.  So should the
default implementation use find to locate all files and then check each
one if it is tracked using vc-state (or something alike)?

>> And then project-files would call (vc-call-backend backend 'list-files)
>> and if that signals vc-not-supported call cl-call-next-method?
>
> No.  If there's no vc-<backend>-list-files, then it calls
> vc-default-list-files.  No signal.
>
>> But how do I know the right backend without explicit tests?
>> vc-backend wants a file and all I have is the project's directory.
>
> IIRC, vc.el calls vc-backend with the directory name in those cases.

(vc-backend "~/Repos/el/emacs") => nil

But that's my emacs git checkout...

>> Also, I think most vc backends have a way to list tracked files but not
>> all those are faster than find is.
>
> If it's not faster, then don't bother implementing
> vc-<backend>-list-files (unless the purpose is to get a different list
> rather than to get the list faster).
>
>> So name the vc function vc-<backend>-list-files-fast and only provide
>> an implementation for Git?
>
> Sure.  But please go through the vc-call-backend mechanism so as not
> to break the abstraction.

Well, I think a vc list-files is generally useful no matter the
performance but for the usage in project-files from project.el the
performance matters a lot.

So IMO, I'd just go with a vc list-files-fast for the usage in
project.el and possibly another vc list-files where implementation are
also provided for the slower backends.

Bye,
Tassilo



reply via email to

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