unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#38156: 27.0.50; [PATCH] VC: ability to skip update buffers prompt
@ 2019-11-09 20:29 Andrii Kolomoiets
  2019-11-14  5:55 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 6+ messages in thread
From: Andrii Kolomoiets @ 2019-11-09 20:29 UTC (permalink / raw)
  To: 38156

[-- Attachment #1: Type: text/plain, Size: 191 bytes --]

Hi,

The `update' argument of `vc-retrieve-tag' is ignored by git, hg and svn
vc backends so the answer for "Update any affected buffers?" prompt
doesn't matter.  This prompt can be omitted.

[-- Attachment #2: 0001-VC-ability-to-skip-update-buffers-prompt.patch --]
[-- Type: application/octet-stream, Size: 4889 bytes --]

From 21d63d3a4c8e3348f590f4189da36798bc6e1bfd Mon Sep 17 00:00:00 2001
From: Andrii Kolomoiets <andreyk.mad@gmail.com>
Date: Sat, 9 Nov 2019 22:23:13 +0200
Subject: [PATCH] VC: ability to skip update buffers prompt

The `update' argument of `vc-retrieve-tag' is ignored by git, hg and svn vc
backends so the answer for "Update any affected buffers?" prompt doesn't
matter.  This prompt can be omitted.

* lisp/vc/vc.el (vc-default-update-on-retrieve-tag): New function.
(vc-retrieve-tag): Call `update-on-retrieve-tag' backend function to determine
if prompt for update buffers is needed; Include tag name into the "Retrieving
tag" message.
* lisp/vc/vc-git.el (vc-git-update-on-retrieve-tag):
* lisp/vc/vc-hg.el (vc-hg-update-on-retrieve-tag):
* lisp/vc/vc-svn.el (vc-svn-udate-on-retrieve-tag): New functions.  Buffers
update prompt on `vc-retrieve-tag' is omitted.

diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index 3960f725cf..587a37455e 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -47,6 +47,7 @@
 ;; FUNCTION NAME                                   STATUS
 ;; BACKEND PROPERTIES
 ;; * revision-granularity                          OK
+;; - update-on-retrieve-tag                        OK
 ;; STATE-QUERYING FUNCTIONS
 ;; * registered (file)                             OK
 ;; * state (file)                                  OK
@@ -218,6 +219,7 @@ vc-git-history
 
 (defun vc-git-revision-granularity () 'repository)
 (defun vc-git-checkout-model (_files) 'implicit)
+(defun vc-git-update-on-retrieve-tag () nil)
 
 ;;; STATE-QUERYING FUNCTIONS
 
diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el
index cc737b30b1..16e5dd6db0 100644
--- a/lisp/vc/vc-hg.el
+++ b/lisp/vc/vc-hg.el
@@ -40,6 +40,7 @@
 ;; FUNCTION NAME                               STATUS
 ;; BACKEND PROPERTIES
 ;; * revision-granularity                      OK
+;; - update-on-retrieve-tag                    OK
 ;; STATE-QUERYING FUNCTIONS
 ;; * registered (file)                         OK
 ;; * state (file)                              OK
@@ -194,6 +195,7 @@ vc-hg-history
 
 (defun vc-hg-revision-granularity () 'repository)
 (defun vc-hg-checkout-model (_files) 'implicit)
+(defun vc-hg-update-on-retrieve-tag () nil)
 
 ;;; State querying functions
 
diff --git a/lisp/vc/vc-svn.el b/lisp/vc/vc-svn.el
index 942dbd5fa5..ed34b357f9 100644
--- a/lisp/vc/vc-svn.el
+++ b/lisp/vc/vc-svn.el
@@ -127,6 +127,7 @@ vc-svn-admin-directory
 
 (defun vc-svn-revision-granularity () 'repository)
 (defun vc-svn-checkout-model (_files) 'implicit)
+(defun vc-svn-update-on-retrieve-tag () nil)
 
 ;;;
 ;;; State-querying functions
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index 20056dec7f..401b39145c 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -110,6 +110,12 @@
 ;;   that return 'file have per-file revision numbering; backends
 ;;   that return 'repository have per-repository revision numbering,
 ;;   so a revision level implicitly identifies a changeset
+;;
+;; - update-on-retrieve-tag
+;;
+;;   Takes no arguments.  Backends that return non-nil can update
+;;   buffers on `vc-retrieve-tag' based on user input.  In this case
+;;   user will be prompted to update buffers on `vc-retrieve-tag'.
 
 ;; STATE-QUERYING FUNCTIONS
 ;;
@@ -2302,14 +2308,15 @@ vc-retrieve-tag
       (vc-read-revision "Tag name to retrieve (default latest revisions): "
                         (list dir)
                         (vc-responsible-backend dir)))))
-  (let ((update (yes-or-no-p "Update any affected buffers? "))
-	(msg (if (or (not name) (string= name ""))
-		 (format "Updating %s... " (abbreviate-file-name dir))
-	       (format "Retrieving tag into %s... "
-		       (abbreviate-file-name dir)))))
+  (let* ((backend (vc-responsible-backend dir))
+         (update (when (vc-call-backend backend 'update-on-retrieve-tag)
+                   (yes-or-no-p "Update any affected buffers? ")))
+	 (msg (if (or (not name) (string= name ""))
+		  (format "Updating %s... " (abbreviate-file-name dir))
+	        (format "Retrieving tag %s into %s... "
+		        name (abbreviate-file-name dir)))))
     (message "%s" msg)
-    (vc-call-backend (vc-responsible-backend dir)
-		     'retrieve-tag dir name update)
+    (vc-call-backend backend 'retrieve-tag dir name update)
     (vc-resynch-buffer dir t t t)
     (run-hooks 'vc-retrieve-tag-hook)
     (message "%s" (concat msg "done"))))
@@ -3025,6 +3032,10 @@ vc-default-receive-file
   "Let BACKEND receive FILE from another version control system."
   (vc-call-backend backend 'register (list file) rev ""))
 
+(defun vc-default-update-on-retrieve-tag ()
+  "Prompt for update buffers on `vc-retrieve-tag'."
+  t)
+
 (defun vc-default-retrieve-tag (backend dir name update)
   (if (string= name "")
       (progn
-- 
2.15.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* bug#38156: 27.0.50; [PATCH] VC: ability to skip update buffers prompt
  2019-11-09 20:29 bug#38156: 27.0.50; [PATCH] VC: ability to skip update buffers prompt Andrii Kolomoiets
@ 2019-11-14  5:55 ` Lars Ingebrigtsen
  2019-11-14  7:13   ` Andrii Kolomoiets
  2019-11-14  9:54   ` Andrii Kolomoiets
  0 siblings, 2 replies; 6+ messages in thread
From: Lars Ingebrigtsen @ 2019-11-14  5:55 UTC (permalink / raw)
  To: Andrii Kolomoiets; +Cc: 38156

Andrii Kolomoiets <andreyk.mad@gmail.com> writes:

> The `update' argument of `vc-retrieve-tag' is ignored by git, hg and svn
> vc backends so the answer for "Update any affected buffers?" prompt
> doesn't matter.  This prompt can be omitted.

Would it be possible to make those backends respect the UPDATE argument
instead?  I had a quick peek at vc-cvs-retrieve-tag (which does respect
the argument), and it looks a bit painful, and I'm not sure whether it
looks that useful.

Anybody got an opinion?

I applied the patch anyway, because it provides a way to make the
backends say whether they support it or not, which seems generally
useful.

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





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#38156: 27.0.50; [PATCH] VC: ability to skip update buffers prompt
  2019-11-14  5:55 ` Lars Ingebrigtsen
@ 2019-11-14  7:13   ` Andrii Kolomoiets
  2019-11-14  7:18     ` Lars Ingebrigtsen
  2019-11-14  9:54   ` Andrii Kolomoiets
  1 sibling, 1 reply; 6+ messages in thread
From: Andrii Kolomoiets @ 2019-11-14  7:13 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 38156

[-- Attachment #1: Type: text/plain, Size: 349 bytes --]

Hi Lars,

> On 14 Nov 2019, at 07:55, Lars Ingebrigtsen <larsi@gnus.org> wrote:
> 
> I applied the patch anyway, because it provides a way to make the
> backends say whether they support it or not, which seems generally
> useful.

Please install attached patch. Totally missed that default vc functions
are called with `backend` argument.

Thanks.


[-- Attachment #2: 0001-lisp-vc-vc.el-vc-default-update-on-retrieve-tag-Acce.patch --]
[-- Type: application/octet-stream, Size: 808 bytes --]

From dfc40b85d9ff6fbc5344cd6882881c421decee35 Mon Sep 17 00:00:00 2001
From: Andrii Kolomoiets <andreyk.mad@gmail.com>
Date: Thu, 14 Nov 2019 09:07:31 +0200
Subject: [PATCH] lisp/vc/vc.el (vc-default-update-on-retrieve-tag): Accept
 backend

* lisp/vc/vc.el (vc-default-update-on-retrieve-tag): Accept backend argument

diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index 401b39145c..0d29c80d02 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -3032,7 +3032,7 @@ vc-default-receive-file
   "Let BACKEND receive FILE from another version control system."
   (vc-call-backend backend 'register (list file) rev ""))
 
-(defun vc-default-update-on-retrieve-tag ()
+(defun vc-default-update-on-retrieve-tag (_backend)
   "Prompt for update buffers on `vc-retrieve-tag'."
   t)
 
-- 
2.15.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* bug#38156: 27.0.50; [PATCH] VC: ability to skip update buffers prompt
  2019-11-14  7:13   ` Andrii Kolomoiets
@ 2019-11-14  7:18     ` Lars Ingebrigtsen
  0 siblings, 0 replies; 6+ messages in thread
From: Lars Ingebrigtsen @ 2019-11-14  7:18 UTC (permalink / raw)
  To: Andrii Kolomoiets; +Cc: 38156

Andrii Kolomoiets <andreyk.mad@gmail.com> writes:

> Please install attached patch. Totally missed that default vc functions
> are called with `backend` argument.

OK; installed.

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





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#38156: 27.0.50; [PATCH] VC: ability to skip update buffers prompt
  2019-11-14  5:55 ` Lars Ingebrigtsen
  2019-11-14  7:13   ` Andrii Kolomoiets
@ 2019-11-14  9:54   ` Andrii Kolomoiets
  2019-11-16  7:13     ` Lars Ingebrigtsen
  1 sibling, 1 reply; 6+ messages in thread
From: Andrii Kolomoiets @ 2019-11-14  9:54 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 38156

Hi Lars,

> On 14 Nov 2019, at 07:55, Lars Ingebrigtsen <larsi@gnus.org> wrote:
> 
> Andrii Kolomoiets <andreyk.mad@gmail.com> writes:
> 
>> The `update' argument of `vc-retrieve-tag' is ignored by git, hg and svn
>> vc backends so the answer for "Update any affected buffers?" prompt
>> doesn't matter.  This prompt can be omitted.
> 
> Would it be possible to make those backends respect the UPDATE argument
> instead?  I had a quick peek at vc-cvs-retrieve-tag (which does respect
> the argument), and it looks a bit painful, and I'm not sure whether it
> looks that useful.

vc-retrieve-tag is already updating buffers by calling
(vc-resynch-buffer dir t t t)

Maybe this commits are related:
http://git.savannah.gnu.org/cgit/emacs.git/commit/?id=5828f6cacc5
http://git.savannah.gnu.org/cgit/emacs.git/commit/?id=5f4f2ae4f96

IMO there are nothing more those backends can do with buffers so
`update` argument is mean nothing to them.

Don't know about cvs backend though.





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#38156: 27.0.50; [PATCH] VC: ability to skip update buffers prompt
  2019-11-14  9:54   ` Andrii Kolomoiets
@ 2019-11-16  7:13     ` Lars Ingebrigtsen
  0 siblings, 0 replies; 6+ messages in thread
From: Lars Ingebrigtsen @ 2019-11-16  7:13 UTC (permalink / raw)
  To: Andrii Kolomoiets; +Cc: 38156

Andrii Kolomoiets <andreyk.mad@gmail.com> writes:

> vc-retrieve-tag is already updating buffers by calling
> (vc-resynch-buffer dir t t t)
>
> Maybe this commits are related:
> http://git.savannah.gnu.org/cgit/emacs.git/commit/?id=5828f6cacc5
> http://git.savannah.gnu.org/cgit/emacs.git/commit/?id=5f4f2ae4f96
>
> IMO there are nothing more those backends can do with buffers so
> `update` argument is mean nothing to them.

OK; closing.

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





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-11-16  7:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-11-09 20:29 bug#38156: 27.0.50; [PATCH] VC: ability to skip update buffers prompt Andrii Kolomoiets
2019-11-14  5:55 ` Lars Ingebrigtsen
2019-11-14  7:13   ` Andrii Kolomoiets
2019-11-14  7:18     ` Lars Ingebrigtsen
2019-11-14  9:54   ` Andrii Kolomoiets
2019-11-16  7:13     ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).