diff options
| author | Spencer Baugh | 2023-05-12 15:28:06 -0400 |
|---|---|---|
| committer | Dmitry Gutov | 2023-05-23 01:27:16 +0300 |
| commit | d4ff1d74209e97730c52ddd50c4d643c79087a33 (patch) | |
| tree | 548a5198ceba168c8088223d5842c5862675ad3a | |
| parent | f33b301c29380cb0b295e1343e59c0faaf6ab621 (diff) | |
| download | emacs-d4ff1d74209e97730c52ddd50c4d643c79087a33.tar.gz emacs-d4ff1d74209e97730c52ddd50c4d643c79087a33.zip | |
Use faster option for running vc-hg status (Bug#63470)
In modern Mercurial, removing the "re:" "-I" "." options provides a
10x-20x speedup because it allows the Rust implementation of "hg
status" to be used.
* lisp/vc/vc-hg.el (vc-hg--program-version): Add.
(vc-hg-dir-status-files): Use --config commands.status.relative=1 to
make paths relative when available.
| -rw-r--r-- | lisp/vc/vc-hg.el | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el index 78480fd8062..182d76882bb 100644 --- a/lisp/vc/vc-hg.el +++ b/lisp/vc/vc-hg.el | |||
| @@ -1372,17 +1372,28 @@ REV is the revision to check out into WORKFILE." | |||
| 1372 | ;; Follows vc-exec-after. | 1372 | ;; Follows vc-exec-after. |
| 1373 | (declare-function vc-set-async-update "vc-dispatcher" (process-buffer)) | 1373 | (declare-function vc-set-async-update "vc-dispatcher" (process-buffer)) |
| 1374 | 1374 | ||
| 1375 | (defvar vc-hg--program-version nil) | ||
| 1376 | |||
| 1377 | (defun vc-hg--program-version () | ||
| 1378 | (or vc-hg--program-version | ||
| 1379 | (setq vc-hg--program-version | ||
| 1380 | (with-temp-buffer | ||
| 1381 | (condition-case _ (vc-hg-command t 0 nil "version") | ||
| 1382 | (error "0") | ||
| 1383 | (:success | ||
| 1384 | (goto-char (point-min)) | ||
| 1385 | (re-search-forward "Mercurial Distributed SCM (version \\([0-9][0-9.]+\\)") | ||
| 1386 | (string-trim-right (match-string 1) "\\."))))))) | ||
| 1387 | |||
| 1375 | (defun vc-hg-dir-status-files (dir files update-function) | 1388 | (defun vc-hg-dir-status-files (dir files update-function) |
| 1376 | ;; XXX: We can't pass DIR directly to 'hg status' because that | 1389 | ;; XXX: We can't pass DIR directly to 'hg status' because that |
| 1377 | ;; returns all ignored files if FILES is non-nil (bug#22481). | 1390 | ;; returns all ignored files if FILES is non-nil (bug#22481). |
| 1378 | (let ((default-directory dir)) | 1391 | (let ((default-directory dir)) |
| 1379 | ;; TODO: Use "--config 'status.relative=1'" instead of "re:" | 1392 | (apply #'vc-hg-command (current-buffer) 'async files |
| 1380 | ;; when we're allowed to depend on Mercurial 4.2+ | 1393 | "status" (concat "-mardu" (if files "i")) "-C" |
| 1381 | ;; (it's a bit faster). | 1394 | (if (version<= "4.2" (vc-hg--program-version)) |
| 1382 | (vc-hg-command (current-buffer) 'async files | 1395 | '("--config" "commands.status.relative=1") |
| 1383 | "status" "re:" "-I" "." | 1396 | '("re:" "-I" ".")))) |
| 1384 | (concat "-mardu" (if files "i")) | ||
| 1385 | "-C")) | ||
| 1386 | (vc-run-delayed | 1397 | (vc-run-delayed |
| 1387 | (vc-hg-after-dir-status update-function))) | 1398 | (vc-hg-after-dir-status update-function))) |
| 1388 | 1399 | ||