From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.bugs Subject: bug#13547: svn annotate - incorrect previous/next revision Date: Thu, 15 Jul 2021 11:01:13 +0200 Message-ID: <878s28kl2e.fsf@gnus.org> References: <51025067.7070204@matholka.se> <5105105F.9040500@matholka.se> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="416"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Glenn Morris , Stefan Monnier , 13547@debbugs.gnu.org To: Lars Ljung Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jul 15 11:02:09 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m3xFx-000AWx-L9 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 15 Jul 2021 11:02:09 +0200 Original-Received: from localhost ([::1]:58652 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m3xFw-0006S9-Dj for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 15 Jul 2021 05:02:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50968) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m3xFq-0006S1-Iu for bug-gnu-emacs@gnu.org; Thu, 15 Jul 2021 05:02:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:35257) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m3xFq-0002yu-A9 for bug-gnu-emacs@gnu.org; Thu, 15 Jul 2021 05:02:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1m3xFq-0004f5-5l for bug-gnu-emacs@gnu.org; Thu, 15 Jul 2021 05:02:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 15 Jul 2021 09:02:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 13547 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 13547-submit@debbugs.gnu.org id=B13547.162633968516238 (code B ref 13547); Thu, 15 Jul 2021 09:02:02 +0000 Original-Received: (at 13547) by debbugs.gnu.org; 15 Jul 2021 09:01:25 +0000 Original-Received: from localhost ([127.0.0.1]:46803 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m3xFF-0004DX-5J for submit@debbugs.gnu.org; Thu, 15 Jul 2021 05:01:25 -0400 Original-Received: from quimby.gnus.org ([95.216.78.240]:54824) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m3xFD-00047k-1b for 13547@debbugs.gnu.org; Thu, 15 Jul 2021 05:01:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=dOTjjqPeBhX72fkIo6Pl3WjAVhd3D+sOTaj7TJ/wy3k=; b=kLOqSxEyTVLYO2mj+aVR0LX8iX NrNve5Cl9Q8BOz1VY6mrYpR3nag27z8X18hdHJCfl//vNPtC84pz7ssWr4Z3zbb9Is2Nb+fLsZNhq sxgIWzDfXi1nNhEP+kroj7eCTUk06Vm4GPk2SX4HbbPIVrF/CH2D82Mbd4hepiI7SQVI=; Original-Received: from cm-84.212.220.105.getinternet.no ([84.212.220.105] helo=elva) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m3xF3-0006Ts-Li; Thu, 15 Jul 2021 11:01:16 +0200 X-Now-Playing: Bob Hund's _KlassiskBOBHUNkonsert_: "Hollywood =?UTF-8?Q?n=C3=A4sta?=" In-Reply-To: <5105105F.9040500@matholka.se> (Lars Ljung's message of "Sun, 27 Jan 2013 12:32:47 +0100") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:210018 Archived-At: Lars Ljung 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