[darcs-users] vc-darcs.el records changes without the fullname unlike darcs itself (with a PATCH)

Ivan Zakharyaschev imz at altlinux.org
Tue Dec 15 04:53:52 UTC 2015


Another problem I've noticed with the vc-darcs.el from jch@ is that it
doesn't use the author's fullname when recording changes.

This has been discovered thanks to a warning by "darcs amend".

Let's have a look how the code of vc-darcs.el could be fixed. (I'll
post if I come up with something.)

Here is an example session demonstrating the problem:

~/tests $ mkdir test-darcs
~/tests $ cd test-darcs/
~/tests/test-darcs $ darcs init
Repository initialized.
~/tests/test-darcs $ echo a > a
~/tests/test-darcs $ darcs add a
Adding 'a'
~/tests/test-darcs $ darcs rec
addfile ./a
Shall I record this change? (1/2)  [ynW...], or ? for more options: y
hunk ./a 1
-
+a
Shall I record this change? (2/2)  [ynW...], or ? for more options: y
Do you want to record these changes? [Yglqk...], or ? for more options: y
Finished recording patch 'A.'
~/tests/test-darcs $

(On the last step above, there is another minor problem -- probably caused
by vc-darcs.el, since I didn't experience it before starting to use
vc-darcs.el:

Emacs is started to edit the message (as before), but the buffer
(named something like _DARCS_PATCH:...) is read-only. I had to do
C-x C-q to be able to edit it.)

Now, let's use Emacs VC to make and record a change:

edit the file in Emacs, and C-x v v

Then, I tried to amend the last change:

~/tests/test-darcs $ echo c > a
~/tests/test-darcs $ darcs amend
patch 81d803550190efdbf33b3b0e61915ea30bcda416
Author: imz at altlinux.org
Date:   Tue Dec 15 06:24:57 MSK 2015
   * B.
Shall I amend this patch? [yNjk...], or ? for more options: y
hunk ./a 1
-b
-
+c
Shall I record this change? (1/1)  [ynW...], or ? for more options: y
Do you want to record these changes? [Yglqk...], or ? for more options: y
You're not imz at altlinux.org! Amend anyway? withSignalsHandled: Interrupted!
interrupt
~/tests/test-darcs $

You see, there is a warning. And here is the reason:

~/tests/test-darcs $ darcs log
patch 81d803550190efdbf33b3b0e61915ea30bcda416
Author: imz at altlinux.org
Date:   Tue Dec 15 06:24:57 MSK 2015
   * B.

patch d3d9ad100dffc3ece9c042712c87750b04cf941c
Author: Ivan Zakharyaschev <imz at altlinux.org>
Date:   Tue Dec 15 06:18:27 MSK 2015
   * A.
~/tests/test-darcs $

The last recorded change (with Emacs VC) doesn't have the fullname.

Let's have a look at the code of `vc-darcs-checkin':

     ...
     (vc-darcs-do-command 'record 'async files "-a" "--pipe")
     (with-current-buffer (get-buffer "*vc*")
       (process-send-string nil
                            (format "%s\n%s\n%s\n%s"
                                    date vc-darcs-mail-address patch-name log))
       (process-send-eof))))

It refers only to `vc-darcs-mail-address', which is:

vc-darcs-mail-address is a variable defined in `vc-darcs.el'.
Its value is "imz at altlinux.org"

Documentation:
*The email address to use in darcs.

There is no fullname here.

It's defined like this:

(defcustom vc-darcs-mail-address
   (or (getenv "DARCS_EMAIL")
       (getenv "EMAIL")
       (if (string-match "<" user-mail-address)
           user-mail-address
           (format "%s <%s>"
                   (user-full-name) user-mail-address)))
   "*The email address to use in darcs."
   :type '(choice string (const nil))
   :group 'vc-darcs)

So it makes an attempt to insert the fullname, but in my case it fails.

Well, I have it written down in ~/.darcs/author, that why darcs knows it:

Ivan Zakharyaschev <imz at altlinux.org>

And "finger" (after I've just installed it) also knows it:

$ /usr/bin/finger imz | head -1
Login: imz            			Name: Ivan Zakharyaschev

And even (user-full-name) evaluates correctly.

So, the reason is that EMAIL environment variable is set to just the
plain address (without the fullname). I'm not sure, but that may be
because Git (or perhars darcs) expects it to be that way, so I've set
it like this.

If that is a common possibility, I think that the value of EMAIL in
the above code should be treated similarly to `user-mail-address'
(with a check for "<").

Hence, the suggested fix:

diff -rN -u old-vc-darcs/vc-darcs.el new-vc-darcs/vc-darcs.el
--- old-vc-darcs/vc-darcs.el	2015-12-15 07:47:00.563953863 +0300
+++ new-vc-darcs/vc-darcs.el	2015-12-15 07:47:00.563953863 +0300
@@ -97,12 +97,13 @@
    :group 'vc-darcs)

  (defcustom vc-darcs-mail-address
-  (or (getenv "DARCS_EMAIL")
-      (getenv "EMAIL")
-      (if (string-match "<" user-mail-address)
-          user-mail-address
-          (format "%s <%s>"
-                  (user-full-name) user-mail-address)))
+  (let ((addr (or (getenv "DARCS_EMAIL")
+		  (getenv "EMAIL")
+		  user-mail-address)))
+    (if (string-match "<" addr)
+	addr
+      (format "%s <%s>"
+	      (user-full-name) addr)))
    "*The email address to use in darcs."
    :type '(choice string (const nil))
    :group 'vc-darcs)

Best regards,
Ivan


More information about the darcs-users mailing list