Subject: bug#74243: closed (Re: bug#74243: [PATCH] Speed up vc-hg-state by treating ignored files as unregistered)

From: [email-masked] (GNU bug Tracking System)
Date: Fri, 29 Nov 2024 23:46:02 +0000

Your bug report

#74243: [PATCH] Speed up vc-hg-state by treating ignored files as unregistered

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
74243: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=74243
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#74243: [PATCH] Speed up vc-hg-state by treating ignored files as unregistered
From: Sean Whitton <[email-masked]>
To: Spencer Baugh <[email-masked]>
Cc: [email-masked], Dmitry Gutov <[email-masked]>
Date: Sat, 30 Nov 2024 07:45:27 +0800
List-Id: <debbugs-submit.debbugs.gnu.org>

Hello,

On Fri 29 Nov 2024 at 07:43am -05, Spencer Baugh via "Bug reports for GNU Emacs, the Swiss army knife of text editors" wrote:

> On Fri, Nov 29, 2024, 3:17 AM Sean Whitton <[email-masked]> wrote:
>
>  Spencer, do you mind if I close this bug?  It's clear that we could be
>  doing something better here, but given the news from Hg upstream, we
>  probably don't want to make changes along the lines of your original
>  patch.
>
> Agreed, go ahead.

Coolio, thanks.

-- 
Sean Whitton

Subject: [PATCH] Speed up vc-hg-state by treating ignored files as unregistered
From: Spencer Baugh <[email-masked]>
To: [email-masked]
Date: Thu, 07 Nov 2024 12:41:47 -0500
List-Id: <debbugs-submit.debbugs.gnu.org>

Tags: patch

The most significant slow component of "hg status" is parsing the
.hgignore file.  If we pass -mardc instead of -A to hg status, hg
doesn't list ignored or untracked files, so it skips parsing the
.hgignore.  On my large repo, this brings "hg status" from 140ms to
20ms.

For vc-hg-state, the distinction doesn't matter: nothing using the
output of vc-hg-state has significantly different behavior for ignored
files vs unregistered files:
- vc-dir-clean-files and vc-dir-recompute-file-state call vc-hg-state,
  but will never see an ignored file anyway since vc-dir shouldn't list
  ignored files for hg.
- vc-next-action checks 'ignored, but it's OK to take the
  'unregistered path instead; it will either fail when calling hg, or
  succeed.
- Other users of vc-state don't differ between 'ignored and
  'unregistered

* lisp/vc/vc-hg.el (vc-hg-state-slow): Treat ignored files as
unregistered.

In GNU Emacs 29.2.50 (build 6, x86_64-pc-linux-gnu, X toolkit, cairo
 version 1.15.12, Xaw scroll bars) of 2024-11-06 built on
 igm-qws-u22796a
Repository revision: 18ed746717c1c80e5cc9d9dc85b6e1f4013a1cec
Repository branch: emacs-29
Windowing system distributor 'The X.Org Foundation', version 11.0.12011000
System Description: Rocky Linux 8.10 (Green Obsidian)

Configured using:
 'configure --with-x-toolkit=lucid --without-gpm --without-gconf
 --without-selinux --without-imagemagick --with-modules --with-gif=no
 --with-tree-sitter --with-native-compilation=aot
 PKG_CONFIG_PATH=/usr/local/home/garnish/libtree-sitter/0.22.6-1/lib/pkgconfig/'

>From 591dd8d7d5e23fd03696f9a536d7f40e77ea2de4 Mon Sep 17 00:00:00 2001
From: Spencer Baugh <[email-masked]>
Date: Thu, 7 Nov 2024 12:28:49 -0500
Subject: [PATCH] Speed up vc-hg-state by treating ignored files as
 unregistered

The most significant slow component of "hg status" is parsing the
.hgignore file.  If we pass -mardc instead of -A to hg status, hg
doesn't list ignored or untracked files, so it skips parsing the
.hgignore.  On my large repo, this brings "hg status" from 140ms to
20ms.

For vc-hg-state, the distinction doesn't matter: nothing using the
output of vc-hg-state has significantly different behavior for ignored
files vs unregistered files:
- vc-dir-clean-files and vc-dir-recompute-file-state call vc-hg-state,
  but will never see an ignored file anyway since vc-dir shouldn't list
  ignored files for hg.
- vc-next-action checks 'ignored, but it's OK to take the
  'unregistered path instead; it will either fail when calling hg, or
  succeed.
- Other users of vc-state don't differ between 'ignored and
  'unregistered

* lisp/vc/vc-hg.el (vc-hg-state-slow): Treat ignored files as
unregistered.
---
 lisp/vc/vc-hg.el | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el
index 856bea66a6f..2dbd1285318 100644
--- a/lisp/vc/vc-hg.el
+++ b/lisp/vc/vc-hg.el
@@ -245,7 +245,7 @@ vc-hg-state-slow
                          "--config" "ui.report_untrusted=0"
 			 "--config" "alias.status=status"
 			 "--config" "defaults.status="
-			 "status" "-A" (file-relative-name file)))
+			 "status" "-mardc" (file-relative-name file)))
                     ;; Some problem happened.  E.g. We can't find an `hg'
                     ;; executable.
                     (error nil)))))))
@@ -260,12 +260,12 @@ vc-hg-state-slow
 	 ((eq state ?=) 'up-to-date)
 	 ((eq state ?A) 'added)
 	 ((eq state ?M) 'edited)
-	 ((eq state ?I) 'ignored)
 	 ((eq state ?R) 'removed)
 	 ((eq state ?!) 'missing)
-	 ((eq state ??) 'unregistered)
 	 ((eq state ?C) 'up-to-date) ;; Older mercurial versions use this.
-	 (t 'up-to-date))))))
+         ;; Ignored or untracked files don't show up; they're both
+         ;; treated as unregistered.
+	 (t 'unregistered))))))
 
 (defun vc-hg-working-revision (_file)
   "Hg-specific version of `vc-working-revision'."
-- 
2.39.3