From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Spencer Baugh Newsgroups: gmane.emacs.bugs Subject: bug#63470: [PATCH] Use faster option for running vc-hg status Date: Tue, 16 May 2023 16:39:49 -0400 Message-ID: References: <83h6shbaiv.fsf@gnu.org> <83bkiobwsu.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26674"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Dmitry Gutov , 63470@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue May 16 22:40:15 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pz1Sx-0006l2-BS for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 16 May 2023 22:40:15 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pz1Sl-0008HW-TT; Tue, 16 May 2023 16:40:03 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pz1Sk-0008H9-NW for bug-gnu-emacs@gnu.org; Tue, 16 May 2023 16:40:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pz1Sk-0007ee-E6 for bug-gnu-emacs@gnu.org; Tue, 16 May 2023 16:40:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pz1Sk-0007ry-3j for bug-gnu-emacs@gnu.org; Tue, 16 May 2023 16:40:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Spencer Baugh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 16 May 2023 20:40:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63470 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 63470-submit@debbugs.gnu.org id=B63470.168426959630234 (code B ref 63470); Tue, 16 May 2023 20:40:02 +0000 Original-Received: (at 63470) by debbugs.gnu.org; 16 May 2023 20:39:56 +0000 Original-Received: from localhost ([127.0.0.1]:48174 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pz1Se-0007rZ-5f for submit@debbugs.gnu.org; Tue, 16 May 2023 16:39:56 -0400 Original-Received: from mxout5.mail.janestreet.com ([64.215.233.18]:54357) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pz1Sc-0007rH-Lx for 63470@debbugs.gnu.org; Tue, 16 May 2023 16:39:55 -0400 In-Reply-To: <83bkiobwsu.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 13 May 2023 08:54:57 +0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:261815 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> Date: Fri, 12 May 2023 23:10:05 +0300 >> Cc: 63470@debbugs.gnu.org >> From: Dmitry Gutov >> >> On 12/05/2023 22:57, Spencer Baugh wrote: >> > >> > I could add a user option to revert to the old behavior, if you want. >> >> We could cache it like we do with vc-git--program-version. That's a >> simple memoization that doesn't take the host into account (though that >> could be implemented, too). > > Yes, that'd be a good-enough solution. > >> But it'd really make things easier if we're just allowed to rely on some >> new enough versions of Git and Hg. > > It isn't easy to be backward-compatible, but we should strive at doing > that. OK, revised backwards-compatible patch attached. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Use-faster-option-for-running-vc-hg-status-Bug-63470.patch >From 69d4a14dc37759ebc20196be00f0b1a6a139e6fd Mon Sep 17 00:00:00 2001 From: Spencer Baugh Date: Fri, 12 May 2023 15:28:06 -0400 Subject: [PATCH] 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 status.relative=1 to make paths relative when available. --- lisp/vc/vc-hg.el | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el index 78231a0c954..bc7787d8c6c 100644 --- a/lisp/vc/vc-hg.el +++ b/lisp/vc/vc-hg.el @@ -1377,17 +1377,28 @@ vc-hg-after-dir-status ;; Follows vc-exec-after. (declare-function vc-set-async-update "vc-dispatcher" (process-buffer)) +(defvar vc-hg--program-version nil) + +(defun vc-hg--program-version () + (or vc-hg--program-version + (setq vc-hg--program-version + (with-temp-buffer + (condition-case _ (vc-hg-command t 0 nil "version") + (error "0") + (:success + (goto-char (point-min)) + (re-search-forward "Mercurial Distributed SCM (version \\([0-9][0-9.]+\\)") + (string-trim-right (match-string 1) "\\."))))))) + (defun vc-hg-dir-status-files (dir files update-function) ;; XXX: We can't pass DIR directly to 'hg status' because that ;; returns all ignored files if FILES is non-nil (bug#22481). (let ((default-directory dir)) - ;; TODO: Use "--config 'status.relative=1'" instead of "re:" - ;; when we're allowed to depend on Mercurial 4.2+ - ;; (it's a bit faster). - (vc-hg-command (current-buffer) 'async files - "status" "re:" "-I" "." - (concat "-mardu" (if files "i")) - "-C")) + (apply #'vc-hg-command (current-buffer) 'async files + "status" (concat "-mardu" (if files "i")) "-C" + (if (version<= "4.2" (vc-hg--program-version)) + '("--config" "status.relative=1") + '("re:" "-I" ".")))) (vc-run-delayed (vc-hg-after-dir-status update-function))) -- 2.30.2 --=-=-=--