Subject: bug#79024: 31.0.50; Multiple working trees support for VC

From: Sean Whitton <[email-masked]>
Date: Sat, 16 Aug 2025 12:46:04 +0100

Hello,

On Thu 14 Aug 2025 at 06:10pm +03, Eli Zaretskii wrote:

>> From: Sean Whitton <[email-masked]>
>> Cc: [email-masked],  [email-masked]
>> Date: Thu, 14 Aug 2025 14:43:10 +0100
>>
>> > The vc-test-hg07-other-working-trees test still fails, but in a
>> > different place now:
>> >
>> >   Test vc-test-hg07-other-working-trees condition:
>> >       (error
>> >        "Failed (status 255): hg --config ui.report_untrusted=0 --config=extensions.share= commit -A -l c:/Users/EliZ/AppData/Local/Temp/hg-msgjR8Sup foo")
>> >
>> > Any ideas?
>>
>> Hmm, I recently changed vc-do-command to print command output for
>> failing commands.  I assume there's nothing showing up?
>
> Do you mean this:
>
>   Checking in foo...
>   abort: no username supplied
>   (use 'hg config --edit' to set your username)

Looks like the problem is determining the committer identity.

I think the attached patch will fix this.  I've tested it locally and it
does result in the test commits having the [email-masked] identity.
Could you test it on Windows?  Thanks.

>> I would suggest trying this manually something like this (translated to
>> Windows speak)
>>
>>     mkdir foo
>>     cd foo
>>     hg init
>>     echo foo >bar
>>     hg add bar
>>     echo msg >../tmp
>>     hg --config ui.report_untrusted=0 --config=extensions.share= commit
>>     -A -l ../tmp bar
>
> This works here, and the last command exits with zero status.  Does
> the above really faithfully reproduces what the test does?

It reproduces it in terms of commands but I guess that hg's identity
autodetection works differently from the test's temporary directory than
it does from the more ordinary directory where you tried these commands.

-- 
Sean Whitton
>From a68f4d515026323f1f15683450e28376f8e387b7 Mon Sep 17 00:00:00 2001
From: Sean Whitton <[email-masked]>
Date: Sat, 16 Aug 2025 12:40:23 +0100
Subject: [PATCH] vc-test--with-author-identity: Handle Mercurial

* test/lisp/vc/vc-tests/vc-tests.el (vc-hg-global-switches):
Declare.
(vc-test--with-author-identity): Handle Mercurial.
---
 test/lisp/vc/vc-tests/vc-tests.el | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/test/lisp/vc/vc-tests/vc-tests.el b/test/lisp/vc/vc-tests/vc-tests.el
index 81789814350..02be0e722e4 100644
--- a/test/lisp/vc/vc-tests/vc-tests.el
+++ b/test/lisp/vc/vc-tests/vc-tests.el
@@ -584,20 +584,26 @@ vc-test--rename-file
         (ignore-errors
           (run-hooks 'vc-test--cleanup-hook))))))
 
+(defvar vc-hg-global-switches)
+
 (defmacro vc-test--with-author-identity (backend &rest body)
   (declare (indent 1) (debug t))
-  `(let ((process-environment process-environment))
+  `(let ((process-environment process-environment)
+         (vc-hg-global-switches vc-hg-global-switches))
      ;; git tries various approaches to guess a user name and email,
      ;; which can fail depending on how the system is configured.
      ;; Eg if the user account has no GECOS, git commit can fail with
      ;; status 128 "fatal: empty ident name".
      (when (memq ,backend '(Bzr Git))
-       (setq process-environment (cons "EMAIL=[email-masked]"
-                                       process-environment)))
+       (push "EMAIL=[email-masked]" process-environment))
      (when (eq ,backend 'Git)
        (setq process-environment (append '("GIT_AUTHOR_NAME=A"
                                            "GIT_COMMITTER_NAME=C")
                                          process-environment)))
+
+     ;; Mercurial fails to autodetect an identity on MS-Windows.
+     (when (eq ,backend 'Hg)
+       (push "--config=ui.username=[email-masked]" vc-hg-global-switches))
      ,@body))
 
 (declare-function log-edit-done "vc/log-edit")
-- 
2.47.2