bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#13547: svn annotate - incorrect previous/next revision


From: Lars Ingebrigtsen
Subject: bug#13547: svn annotate - incorrect previous/next revision
Date: Thu, 15 Jul 2021 11:01:13 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Lars Ljung <lars@matholka.se> writes:

>> Thanks. I guess the drawback here is, that will contact the svn
>> repository, which may be on a remote server, so could be slow.
>> 
>> It seems this is used by vc-annotate, vc-rollback, and vc-diff. 
>
> Yes, it will be slower. But as far as I know there is no other way to
> get the previous/next revision of a file.

I haven't used svn in many years, so I don't have much of an opinion
here.  I've respun the patch for Emacs 28; included below.

Anybody got an opinion here?

diff --git a/lisp/vc/vc-svn.el b/lisp/vc/vc-svn.el
index c30920dd15..0cc7bda1ba 100644
--- a/lisp/vc/vc-svn.el
+++ b/lisp/vc/vc-svn.el
@@ -248,23 +248,29 @@ vc-svn-working-revision
 ;; vc-svn-mode-line-string doesn't exist because the default implementation
 ;; works just fine.
 
-(defun vc-svn-previous-revision (_file rev)
-  (let ((newrev (1- (string-to-number rev))))
-    (when (< 0 newrev)
-      (number-to-string newrev))))
+(defun vc-svn-previous-revision (file rev)
+  (if file
+      (with-temp-buffer
+       (let (process-file-side-effects)
+         (vc-svn-command t 0 file "log" "-q" "--limit" "2"
+                         (format "-r%s:1" rev)))
+       (let ((revision-list '()))
+         (while (re-search-backward "^r\\([0-9]+\\)" nil t)
+           (push (match-string 1) revision-list))
+         (cadr revision-list)))
+    (let ((newrev (1- (string-to-number rev))))
+      (when (< 0 newrev)
+       (number-to-string newrev)))))
 
 (defun vc-svn-next-revision (file rev)
-  (let ((newrev (1+ (string-to-number rev))))
-    ;; The "working revision" is an uneasy conceptual fit under Subversion;
-    ;; we use it as the upper bound until a better idea comes along.  If the
-    ;; workfile version W coincides with the tree's latest revision R, then
-    ;; this check prevents a "no such revision: R+1" error.  Otherwise, it
-    ;; inhibits showing of W+1 through R, which could be considered anywhere
-    ;; from gracious to impolite.
-    (unless (< (string-to-number (vc-file-getprop file 'vc-working-revision))
-               newrev)
-      (number-to-string newrev))))
-
+  (with-temp-buffer
+    (let (process-file-side-effects)
+      (vc-svn-command t 0 file "log" "-q" "--limit" "2"
+                     (format "-r%s:HEAD" rev)))
+    (let ((revision-list '()))
+      (while (re-search-backward "^r\\([0-9]+\\)" nil t)
+       (push (match-string 1) revision-list))
+      (cadr revision-list))))
 
 ;;;
 ;;; State-changing functions


-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





reply via email to

[Prev in Thread] Current Thread [Next in Thread]