From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Spencer Baugh via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#62940: 29.0.60; vc: no easy way to get diff of all outgoing changes Date: Fri, 13 Sep 2024 16:54:29 -0400 Message-ID: References: <640746f7-fa1c-dfb9-aaab-f9d8effdf64f@gutov.dev> Reply-To: Spencer Baugh 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="23519"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 62940@debbugs.gnu.org, Filipp Gunbin To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Sep 13 22:55:11 2024 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 1spDJu-0005w1-Iy for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 13 Sep 2024 22:55:10 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1spDJd-00088d-R3; Fri, 13 Sep 2024 16:54:53 -0400 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 1spDJc-00088V-IX for bug-gnu-emacs@gnu.org; Fri, 13 Sep 2024 16:54:52 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1spDJc-0003oS-8y for bug-gnu-emacs@gnu.org; Fri, 13 Sep 2024 16:54:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=ZiqnZtUr9Y5063bTJSpi/y0cWLXchEOYqZqC2CKv9GE=; b=qwPauVK3N00mPjFT36eJ1PYeEPxqMwUp6jgJgBp//OVgdzZ1QS02yI0zvFmhXfi17kRxXQ+7X87HEZbNn6cyyP/yWl9eg5bv5WDPpZCT/o//+VdMX9FrtplWLqnN0mGRI2VjBtb7gsGU0KKyRYSnu0hLsoVTP8wjAY2UUVD/nYHoUAkljM6B3LwwbV56RZVOlGnUamWj/LL69C/HO0XUyDHl3FfuUDCizZlgTcbjecW8vloX1o6kfgW7uA03nIEYniK1pqA51dYj0NAeT8NchbzsL/OmIRjfYHAFoxV49ruOqzh7sqxd9JbbB1Sle9vi2rvsusfaGd04hcyQzDi1Og==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1spDJl-00005F-Pr for bug-gnu-emacs@gnu.org; Fri, 13 Sep 2024 16:55:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Spencer Baugh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 13 Sep 2024 20:55:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62940 X-GNU-PR-Package: emacs Original-Received: via spool by 62940-submit@debbugs.gnu.org id=B62940.172626088732755 (code B ref 62940); Fri, 13 Sep 2024 20:55:01 +0000 Original-Received: (at 62940) by debbugs.gnu.org; 13 Sep 2024 20:54:47 +0000 Original-Received: from localhost ([127.0.0.1]:44338 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1spDJW-0008WF-Uc for submit@debbugs.gnu.org; Fri, 13 Sep 2024 16:54:47 -0400 Original-Received: from mxout1.mail.janestreet.com ([38.105.200.78]:41441) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1spDJV-0008W2-6T for 62940@debbugs.gnu.org; Fri, 13 Sep 2024 16:54:45 -0400 In-Reply-To: <640746f7-fa1c-dfb9-aaab-f9d8effdf64f@gutov.dev> (Dmitry Gutov's message of "Tue, 18 Apr 2023 23:43:55 +0300") DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=waixah; t=1726260870; bh=ZiqnZtUr9Y5063bTJSpi/y0cWLXchEOYqZqC2CKv9GE=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=g1kvmFC9eExS8J0DPKjmxGrLNrfOFy834TmzguuzbtwxNb+pybDHEMBvqjxmaYVjh F7oROi8GdOhXZM4ZikVKgfjupQFy2NL6tDq7okaDD7H3d7APo9RTtfPaxqWo9c/pC6 u5KKlK4JJ3ETobBrOBo0+kM2mpzqPOwzKImZh7hXM7eayQiuZF3M57NDlKKHFgrSqz Pa8ByVXa5V0v4qmVc2BO+m+gZ7UQvebKekgA1AqQwuQU8WboAI96IUOFtQ+PQdDYDM i/6BpKWoHbcVOcedpsozQj4BmH/bUUOLdKnRA4l/KB8he9CLHuEBnmKxgovml7C1qC zf+Gb7LhU1nnw== 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:291674 Archived-At: --=-=-= Content-Type: text/plain Dmitry Gutov writes: > On 18/04/2023 23:36, Filipp Gunbin wrote: >> Usually I just do C-x v L, select commits that interest me (via region), >> and do M-x log-view-diff. > > Just in case: 'log-view-diff' is bound to '='. > > That's what I wanted to suggest, too. Or use 'vc-log-outgoing': > > C-x v O C-x h = > > Which would be D. in the original message. It doesn't support > uncommitted changes, but I would be surprised if it did. > > But one can also try this: > > C-u C-x v D origin/master ^J > > Where origin/master is the name of the upstream branch ref. This > should include uncommitted changes. This works great, but is a bit tricky to use because you need to type the upstream branch ref. I think it would be good to provide that as an additional default in the prompt for the old revision. The attached patch does that. (and probably is enough to close this bug) --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Add-a-last-pushed-revision-default-in-the-vc-diff-pr.patch >From 0a48d2973363361211c2e91c4f6c7bb75f16a853 Mon Sep 17 00:00:00 2001 From: Spencer Baugh Date: Fri, 13 Sep 2024 16:35:19 -0400 Subject: [PATCH] Add a "last pushed revision" default in the vc-diff prompt C-u M-x vc-root-diff will prompt for the old revision to use for the diff. It includes the current working revision as a default. Now it also includes the last pushed revision as a default, through a new pushed-revision vc backend function. * lisp/vc/vc-git.el (vc-git-pushed-revision): Add. (vc-git-log-outgoing): Use vc-git-pushed-revision. * lisp/vc/vc-hg.el (vc-hg-pushed-revision): Add. * lisp/vc/vc.el (vc-default-pushed-revision): Add new backend function with default implementation returning nil. (vc-diff-build-argument-list-internal): Add the last pushed revision as a default. (bug#62940) --- lisp/vc/vc-git.el | 10 +++++++--- lisp/vc/vc-hg.el | 6 ++++++ lisp/vc/vc.el | 7 +++++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index 2a7c8ae5fc4..4afbb978a3f 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el @@ -1512,6 +1512,12 @@ vc-git-print-log (list "-p")) '("--"))))))) +(defun vc-git-pushed-revision (_file &optional remote-location) + "Return the ref for REMOTE-LOCATION." + (if (and remote-location (not (string-empty-p remote-location))) + remote-location + "@{upstream}")) + (defun vc-git-log-outgoing (buffer remote-location) (vc-setup-buffer buffer) (apply #'vc-git-command buffer 'async nil @@ -1520,9 +1526,7 @@ vc-git-log-outgoing ,(format "--pretty=tformat:%s" (car vc-git-root-log-format)) "--abbrev-commit" ,@(ensure-list vc-git-shortlog-switches) - ,(concat (if (string= remote-location "") - "@{upstream}" - remote-location) + ,(concat (vc-git-pushed-revision nil remote-location) "..HEAD")))) (defun vc-git-log-incoming (buffer remote-location) diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el index 876d86dc24f..c0afb225871 100644 --- a/lisp/vc/vc-hg.el +++ b/lisp/vc/vc-hg.el @@ -1422,6 +1422,12 @@ vc-hg-log-incoming (vc-hg-command buffer 1 nil "incoming" "-n" (unless (string= remote-location "") remote-location))) +(defun vc-hg-pushed-revision (_file &optional remote-location) + "Return a revspec for the last commit not outgoing to REMOTE-LOCATION." + (unless remote-location + (setq remote-location "")) + (format "last(. and not outgoing(%s))" remote-location)) + (defun vc-hg-log-outgoing (buffer remote-location) (vc-setup-buffer buffer) (vc-hg-command buffer 1 nil "outgoing" "-n" (unless (string= remote-location "") diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index 597a1622f5a..0125924cc51 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -2061,6 +2061,11 @@ vc-read-multiple-revisions INITIAL-INPUT are passed on to `vc-read-revision' directly." (vc-read-revision prompt files backend default initial-input t)) +(defun vc-default-pushed-revision (_file &optional _remote-location) + "Return the last pushed revision of FILE. +The default is to return nil always." + nil) + (defun vc-diff-build-argument-list-internal (&optional fileset) "Build argument list for calling internal diff functions." (let* ((vc-fileset (or fileset (vc-deduce-fileset t))) ;FIXME: why t? --Stef @@ -2069,6 +2074,8 @@ vc-diff-build-argument-list-internal (first (car files)) (rev1-default nil) ) ;; (rev2-default nil) + (when-let ((pushed-revision (vc-call-backend backend 'pushed-revision first))) + (push pushed-revision rev1-default)) (cond ;; someday we may be able to do revision completion on non-singleton ;; filesets, but not yet. -- 2.39.3 --=-=-=--