From: Dmitry Gutov <dgutov@yandex.ru>
To: emacs-devel@gnu.org
Subject: Re: A project-files implementation for Git projects
Date: Mon, 30 Sep 2019 03:09:19 +0300 [thread overview]
Message-ID: <4be972f9-45a3-f2aa-f532-d7b8fbe054fd@yandex.ru> (raw)
In-Reply-To: <87h84x1zoa.fsf@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 2296 bytes --]
Hi Tassilo,
On 27.09.2019 19:17, Tassilo Horn wrote:
> I have to admit that I've lost track over what we're actually trying to
> do exactly. My main motivation was just to get a faster project-files
> implementation for the Git repo I have at work. I've now fixed that on
> my end using a simple caching approach which is good enough for me ATM.
I'm attaching a working patch that will probably need tweaks later. I'm
not sure how to handle attribution best. If you like it, you can simply
commit it under your name (up to now, I've mostly done the rearranging
and some minor tweaks).
> So I think that your current idea is to:
>
> - No general VC list-files operation since we can come up with good
> versions just for Git and Hg anyway. Fine with me.
Great. I think we should start with that that either way. And when some
other application arises that could use a VC 'ls-files' command we
should see whether we can extract something that satisfies both. Maybe
the minimum supported Git version will make it easier for us too then.
> - I'm not sure if we're on the same board when it comes to ignores.
>
> If you want me to implement something I fear you have to explain the
> ignore story again. I don't know what you imply by renaming the
> parameter from EXTRA-IGNORES to ALL-IGNORES. Do you mean that the
> patterns in .{git,hg}ignore (and $XDG_CONFIG_HOME/git/ignore,
> $GIT_DIR/info/exclude) should be part of the ALL-IGNORES list (in
> addition to project-vc-ignores) and parsed from those files?
Good point, I forgot about those (and also about per-directory gitignore
files). ALL-IGNORES would be a nice semantics for a VC 'ls-files'
command, but if we're not doing that now, we don't have to try to fit
that approach.
Still, there could be a performance problem with outputting all ignored
files and then parsing out only a part of them. Could you try the new
feature with a test repository from
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=22481?
> Processing
> 3 files in the case of Git and handling 3 ignore syntaxes (regexp, glob,
> rootglob) in the case of Hg doesn't sound too appealing to me.
Speaking of syntaxes, I was curious which one is used by Mercurial's
--exclude. But it seems to accept globs okay, including ones rooted with
'./'.
[-- Attachment #2: vc-list-files.diff --]
[-- Type: text/x-patch, Size: 2709 bytes --]
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 4693d07fa8..bbb6310323 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -277,6 +277,66 @@ project-try-vc
(funcall project-vc-external-roots-function)))
(project-roots project)))
+(cl-defmethod project-files ((project (head vc)) &optional dirs)
+ (cl-mapcan
+ (lambda (dir)
+ (let (backend)
+ (if (and (file-equal-p dir (cdr project))
+ (setq backend (vc-responsible-backend dir))
+ (cond
+ ((eq backend 'Hg))
+ ((and (eq backend 'Git)
+ (or
+ (not project-vc-ignores)
+ (version<= "1.9" (vc-git--program-version)))))))
+ (project-vc-list-files dir backend project-vc-ignores)
+ (project--files-in-directory
+ dir
+ (project--dir-ignores project dir)))))
+ (or dirs (project-roots project))))
+
+(defun project-vc-list-files (dir backend extra-ignores)
+ (pcase backend
+ (`Git
+ (let ((default-directory dir)
+ (args '("-z")))
+ (when t ;include-unregistered
+ (setq args (append args '("-c" "-o" "--exclude-standard"))))
+ (when extra-ignores
+ (setq args (append args
+ (cons "--"
+ (mapcar
+ (lambda (i)
+ (if (string-match "\\./" i)
+ (format ":!/:%s" (substring i 2))
+ (format ":!:%s" i)))
+ extra-ignores)))))
+ (mapcar
+ #'expand-file-name
+ (split-string
+ (apply #'vc-git--run-command-string nil "ls-files" args)
+ "\0" t))))
+ (`Hg
+ (let ((default-directory dir)
+ args
+ files)
+ (when t ;include-unregistered
+ (setq args (nconc args '("--all"))))
+ (when extra-ignores
+ (setq args (nconc args
+ (mapcan
+ (lambda (i)
+ (list "--exclude" i))
+ (copy-list extra-ignores)))))
+ (with-temp-buffer
+ (apply #'vc-hg-command t 0 "."
+ "status" args)
+ (goto-char (point-min))
+ (while (re-search-forward "^[?C]\s+\\(.*\\)$" nil t)
+ (setq files (cons (expand-file-name (match-string 1))
+ files))))
+ (nreverse files)))))
+
(cl-defmethod project-ignores ((project (head vc)) dir)
(let* ((root (cdr project))
backend)
next prev parent reply other threads:[~2019-09-30 0:09 UTC|newest]
Thread overview: 94+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-06 9:19 A project-files implementation for Git projects Tassilo Horn
2019-09-06 12:52 ` Stefan Monnier
2019-09-10 6:25 ` Tassilo Horn
2019-09-10 12:56 ` Stefan Monnier
2019-09-10 13:39 ` Tassilo Horn
2019-09-10 13:56 ` Stefan Monnier
2019-09-11 11:00 ` Tassilo Horn
2019-09-11 20:01 ` Tassilo Horn
2019-09-13 20:38 ` Tassilo Horn
2019-09-14 0:29 ` Dmitry Gutov
2019-09-14 16:26 ` Tassilo Horn
2019-09-15 18:56 ` Dmitry Gutov
2019-09-16 2:27 ` Eli Zaretskii
2019-09-16 3:36 ` Dmitry Gutov
2019-09-16 15:25 ` Eli Zaretskii
2019-09-17 10:46 ` Dmitry Gutov
2019-09-17 12:03 ` Eli Zaretskii
2019-09-17 12:55 ` Dmitry Gutov
2019-09-17 13:14 ` Eli Zaretskii
2019-09-19 15:33 ` Dmitry Gutov
2019-09-19 17:29 ` Eli Zaretskii
2019-09-20 11:25 ` Dmitry Gutov
2019-09-20 12:59 ` Eli Zaretskii
2019-09-20 13:28 ` Dmitry Gutov
2019-09-20 13:45 ` Stefan Monnier
2019-09-20 13:54 ` Dmitry Gutov
2019-09-20 14:12 ` Michael Albinus
2019-09-20 14:30 ` Eli Zaretskii
2019-09-20 14:51 ` Dmitry Gutov
2019-09-20 15:04 ` Michael Albinus
2019-09-22 9:23 ` Dmitry Gutov
2019-09-20 14:55 ` Michael Albinus
2019-09-20 15:55 ` Eli Zaretskii
2019-09-20 15:01 ` Stefan Monnier
2019-09-20 15:59 ` Eli Zaretskii
2019-09-20 17:32 ` Stefan Monnier
2019-09-20 17:49 ` Eli Zaretskii
2019-09-20 18:04 ` Stefan Monnier
2019-09-20 14:23 ` Eli Zaretskii
2019-09-20 14:48 ` Dmitry Gutov
2019-09-16 13:32 ` Tassilo Horn
2019-09-17 11:06 ` Dmitry Gutov
2019-09-18 17:15 ` Tassilo Horn
2019-09-19 16:01 ` Dmitry Gutov
2019-09-22 8:56 ` Tassilo Horn
2019-09-22 9:37 ` Dmitry Gutov
2019-09-23 7:42 ` Tassilo Horn
2019-09-23 12:22 ` Dmitry Gutov
2019-09-27 16:17 ` Tassilo Horn
2019-09-30 0:09 ` Dmitry Gutov [this message]
2019-09-30 0:25 ` Stefan Monnier
2019-09-30 6:50 ` Dmitry Gutov
2019-09-30 17:09 ` Stefan Monnier
2019-10-01 8:19 ` Dmitry Gutov
2019-10-01 12:31 ` Stefan Monnier
2019-10-01 13:10 ` Stefan Monnier
2019-10-01 23:38 ` Dmitry Gutov
2019-10-03 9:25 ` Felician Nemeth
2019-10-03 10:32 ` Dmitry Gutov
2019-10-03 11:15 ` Felician Nemeth
2019-10-03 12:31 ` Dmitry Gutov
2019-10-03 14:39 ` Felician Nemeth
2019-10-03 14:42 ` Dmitry Gutov
2019-10-03 15:10 ` Felician Nemeth
2019-10-03 15:15 ` Dmitry Gutov
2019-10-01 8:11 ` Dmitry Gutov
2019-10-03 8:33 ` Tassilo Horn
2019-10-03 13:19 ` Dmitry Gutov
2019-10-03 17:15 ` Tassilo Horn
2019-10-03 22:49 ` Dmitry Gutov
2019-10-04 7:47 ` Tassilo Horn
2019-10-04 7:58 ` Tassilo Horn
2019-10-04 13:16 ` Dmitry Gutov
2019-10-04 8:49 ` Tassilo Horn
2019-10-04 12:57 ` Dmitry Gutov
2019-10-04 13:59 ` Tassilo Horn
2019-10-04 15:24 ` Dmitry Gutov
2019-10-04 12:16 ` Stefan Monnier
2019-10-04 13:08 ` Dmitry Gutov
2019-10-03 7:41 ` Tassilo Horn
2019-10-03 12:33 ` Dmitry Gutov
2019-10-03 12:51 ` Tassilo Horn
2019-10-04 5:52 ` Co-authoring and attribution in commit message (was: A project-files implementation for Git projects) Kévin Le Gouguec
2019-10-04 8:33 ` Co-authoring and attribution in commit message Dmitry Gutov
2019-10-04 21:36 ` Karl Fogel
2019-10-05 6:55 ` Eli Zaretskii
2019-10-03 23:02 ` A project-files implementation for Git projects Dmitry Gutov
2019-09-14 0:33 ` Dmitry Gutov
2019-09-14 16:43 ` Tassilo Horn
2019-09-15 8:29 ` Dmitry Gutov
2019-09-15 9:06 ` Dmitry Gutov
2019-09-10 13:57 ` Robert Pluim
2019-09-10 14:24 ` Dmitry Gutov
2019-09-10 14:41 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4be972f9-45a3-f2aa-f532-d7b8fbe054fd@yandex.ru \
--to=dgutov@yandex.ru \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).