Subject: bug#68117: closed (Re: bug#68117: [PATCH] vc-hg-annotate-time extracts incorrect dates)

From: [email-masked] (GNU bug Tracking System)
Date: Mon, 01 Jan 2024 17:58:02 +0000

Your bug report

#68117: [PATCH] vc-hg-annotate-time extracts incorrect dates

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].

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

Subject: Re: bug#68117: [PATCH] vc-hg-annotate-time extracts incorrect dates
From: Dmitry Gutov <[email-masked]>
To: Kjetil Ørbekk <[email-masked]>, [email-masked]
Date: Mon, 1 Jan 2024 19:56:56 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Version: 30.1

On 29/12/2023 16:21, Kjetil Ørbekk wrote:
> Hi,
> 
> I noticed that vc-hg-annotate-time constructs a timestamp based on
> incorrect strings. E.g., the date "2014-11-28" is interpreted as year
> 2014, day -1, month 1.
> 
> Please see the attached patch for a fix.

Thanks! Installed.

Subject: [PATCH] vc-hg-annotate-time extracts incorrect dates
From: Kjetil Ørbekk <[email-masked]>
To: [email-masked]
Date: Fri, 29 Dec 2023 09:21:52 -0500
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi,

I noticed that vc-hg-annotate-time constructs a timestamp based on
incorrect strings. E.g., the date "2014-11-28" is interpreted as year
2014, day -1, month 1.

Please see the attached patch for a fix.

-- 
Kjetil

>From 47274868e458f92073eb75bb48f6e34564f020e5 Mon Sep 17 00:00:00 2001
From: Kjetil Orbekk <[email-masked]>
Date: Fri, 29 Dec 2023 08:59:23 -0500
Subject: [PATCH] Fix vg-hg-annotate-time bug

* lisp/vc/vc-hg.el (vc-hg-annotate-time): Fix extraction of timestamp
from string.
* test/lisp/vc/vc-hg-tests.el (vc-hg-annotate-time): Test that the
correct timestamp is found.

Copyright-paperwork-exempt: yes
---
 lisp/vc/vc-hg.el            | 4 ++--
 test/lisp/vc/vc-hg-tests.el | 4 +++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el
index d6dadb7..10be29c 100644
--- a/lisp/vc/vc-hg.el
+++ b/lisp/vc/vc-hg.el
@@ -584,8 +584,8 @@ vc-hg-annotate-time
     (vc-annotate-convert-time
      (let ((str (match-string-no-properties 2)))
        (encode-time 0 0 0
-                    (string-to-number (substring str 6 8))
-                    (string-to-number (substring str 4 6))
+                    (string-to-number (substring str 8 10))
+                    (string-to-number (substring str 5 7))
                     (string-to-number (substring str 0 4)))))))
 
 (defun vc-hg-annotate-extract-revision-at-line ()
diff --git a/test/lisp/vc/vc-hg-tests.el b/test/lisp/vc/vc-hg-tests.el
index 89d518b..43bb922 100644
--- a/test/lisp/vc/vc-hg-tests.el
+++ b/test/lisp/vc/vc-hg-tests.el
@@ -53,6 +53,8 @@ vc-hg-annotate-extract-revision-at-line-with-both
 (ert-deftest vc-hg-annotate-time ()
   (with-temp-buffer
     (save-excursion (insert "philringnalda 218075 2014-11-28 CLOBBER:"))
-    (should (floatp (vc-hg-annotate-time)))))
+    (should (equal (vc-hg-annotate-time)
+                   (vc-annotate-convert-time
+                    (encode-time 0 0 0 28 11 2014))))))
 
 ;;; vc-hg-tests.el ends here
-- 
2.42.0