From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#60569: 29.0.60; vc-pull-and-push unsupported on non-git vcs Date: Wed, 18 Jan 2023 19:39:46 +0200 Organization: LINKOV.NET Message-ID: <861qnr4yet.fsf@mail.linkov.net> References: <864jt58l8f.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25872"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) To: 60569@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jan 18 18:43:18 2023 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 1pICSz-0006aV-Mo for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 18 Jan 2023 18:43:17 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pICSo-0005Wf-6H; Wed, 18 Jan 2023 12:43:06 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pICSk-0005WA-Ke for bug-gnu-emacs@gnu.org; Wed, 18 Jan 2023 12:43:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pICSk-0003FP-9h for bug-gnu-emacs@gnu.org; Wed, 18 Jan 2023 12:43:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pICSj-0000F1-Ut for bug-gnu-emacs@gnu.org; Wed, 18 Jan 2023 12:43:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 18 Jan 2023 17:43:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60569 X-GNU-PR-Package: emacs Original-Received: via spool by 60569-submit@debbugs.gnu.org id=B60569.1674063727822 (code B ref 60569); Wed, 18 Jan 2023 17:43:01 +0000 Original-Received: (at 60569) by debbugs.gnu.org; 18 Jan 2023 17:42:07 +0000 Original-Received: from localhost ([127.0.0.1]:41738 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pICRq-0000D9-IK for submit@debbugs.gnu.org; Wed, 18 Jan 2023 12:42:06 -0500 Original-Received: from relay3-d.mail.gandi.net ([217.70.183.195]:53253) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pICRl-0000Bv-Uk for 60569@debbugs.gnu.org; Wed, 18 Jan 2023 12:42:02 -0500 Original-Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id 0697E60004 for <60569@debbugs.gnu.org>; Wed, 18 Jan 2023 17:41:55 +0000 (UTC) In-Reply-To: <864jt58l8f.fsf@mail.linkov.net> (Juri Linkov's message of "Thu, 05 Jan 2023 09:58:00 +0200") 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:253651 Archived-At: --=-=-= Content-Type: text/plain > Isn't it so that as a general rule we don't add a vc command > when it's not supported by more than 1 backend? > > It seems fine to add a git-specific 'vc-git-pull-and-push', > but why to add 'vc-pull-and-push' supported only by git? > > It's more strange that the docstring of 'vc-pull-and-push' says: > > "It also signals an error in a Bazaar bound branch." > > whereas in fact it's not implemented for Bazaar at all. We can't release this with such uncalled api changes. So here is the fix: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=vc-pull-and-push.patch diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index 412598d084c..ef93edd1616 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el @@ -1303,25 +1303,6 @@ vc-git-push for the Git command to run." (vc-git--pushpull "push" prompt nil)) -(defun vc-git-pull-and-push (prompt) - "Pull changes into the current Git branch, and then push. -The push will only be performed if the pull was successful. - -Normally, this runs \"git pull\". If PROMPT is non-nil, prompt -for the Git command to run." - (let ((proc (vc-git--pushpull "pull" prompt '("--stat")))) - (when (process-buffer proc) - (with-current-buffer (process-buffer proc) - (if (and (eq (process-status proc) 'exit) - (zerop (process-exit-status proc))) - (let ((vc--inhibit-async-window t)) - (vc-git-push nil)) - (vc-exec-after - (lambda () - (let ((vc--inhibit-async-window t)) - (vc-git-push nil))) - proc)))))) - (defun vc-git-merge-branch () "Merge changes into the current Git branch. This prompts for a branch to merge from." diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index 13124509c27..0890b63d417 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -3071,9 +3071,20 @@ vc-pull-and-push (interactive "P") (let* ((vc-fileset (vc-deduce-fileset t)) (backend (car vc-fileset))) - (if (vc-find-backend-function backend 'pull-and-push) - (vc-call-backend backend 'pull-and-push arg) - (user-error "VC pull-and-push is unsupported for `%s'" backend)))) + (if (vc-find-backend-function backend 'pull) + (let ((proc (vc-call-backend backend 'pull arg))) + (when (and (processp proc) (process-buffer proc)) + (with-current-buffer (process-buffer proc) + (if (and (eq (process-status proc) 'exit) + (zerop (process-exit-status proc))) + (let ((vc--inhibit-async-window t)) + (vc-push arg)) + (vc-exec-after + (lambda () + (let ((vc--inhibit-async-window t)) + (vc-push arg))) + proc))))) + (user-error "VC pull is unsupported for `%s'" backend)))) (defun vc-version-backup-file (file &optional rev) "Return name of backup file for revision REV of FILE. --=-=-=--