From 5b07a81bedaddbe2874b37c79ef6c4c80da7707e Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sun, 30 Nov 2025 21:35:23 +0000 Subject: [PATCH] New display of outgoing revisions count in VC-Dir This relies on how vc--incoming-revision now caches incoming revisions. * lisp/vc/vc.el (vc--count-outgoing): New function. * lisp/vc/vc-dir.el (vc-dir-header-urgent-value): New face. (vc-dir-outgoing-revisions-map): New keymap. (vc-dir-headers): Use them. * etc/NEWS: Document the change. --- etc/NEWS | 5 +++++ lisp/vc/vc-dir.el | 23 ++++++++++++++++++++--- lisp/vc/vc.el | 11 +++++++++++ 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 7e67f84ef86..5623f1f5825 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -2529,6 +2529,11 @@ bindings: - 'C-x v O L' is bound to 'vc-log-outgoing' - 'C-x v O D' is bound to 'vc-root-diff-outgoing'. +--- +*** New display of outgoing revisions count in VC-Dir. +If there are outgoing revisions, VC-Dir now includes a count of how many +in its headers, to remind you to push them. + +++ *** New user option 'vc-async-checkin' to enable async checkin operations. Currently only supported by the Git and Mercurial backends. diff --git a/lisp/vc/vc-dir.el b/lisp/vc/vc-dir.el index ef5aa5dbda2..0b237e91974 100644 --- a/lisp/vc/vc-dir.el +++ b/lisp/vc/vc-dir.el @@ -64,6 +64,11 @@ See `run-hooks'." :group 'vc :version "28.1") +(defface vc-dir-header-urgent-value '((t :inherit font-lock-warning-face)) + "Face for urgent header values in VC-Dir buffers." + :group 'vc + :version "31.1") + (defface vc-dir-directory '((t :inherit font-lock-comment-delimiter-face)) "Face for directories in VC-Dir buffers." :group 'vc @@ -1328,19 +1333,31 @@ the *vc-dir* buffer. (hack-dir-local-variables-non-file-buffer) (vc-dir-refresh))) +(defvar-keymap vc-dir-outgoing-revisions-map + :doc "Local keymap for viewing outgoing revisions." + "" #'vc-log-outgoing) + (defun vc-dir-headers (backend dir) - "Display the headers in the *VC dir* buffer. + "Display the headers in the *VC-Dir* buffer. It calls the `dir-extra-headers' backend method to display backend specific headers." (concat - ;; First layout the common headers. (propertize "VC backend : " 'face 'vc-dir-header) (propertize (format "%s\n" backend) 'face 'vc-dir-header-value) (propertize "Working dir: " 'face 'vc-dir-header) (propertize (format "%s\n" (abbreviate-file-name dir)) 'face 'vc-dir-header-value) - ;; Then the backend specific ones. (vc-call-backend backend 'dir-extra-headers dir) + (and-let* ((count (ignore-errors (vc--count-outgoing backend))) + (_ (plusp count))) + (concat (propertize "\nOutgoing : " + 'face 'vc-dir-header) + (propertize (format "%d unpushed revisions\n" count) + 'face 'vc-dir-header-urgent-value + 'mouse-face 'highlight + 'keymap vc-dir-outgoing-revisions-map + 'help-echo "\\\ +\\[vc-log-outgoing]: List outgoing revisions"))) "\n")) (defun vc-dir-refresh-files (files) diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index afe3f4ebbda..6547e5ebfbd 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -4077,6 +4077,17 @@ can be a remote branch name." "" (vc-call-backend backend 'mergebase incoming))))) +(defun vc--count-outgoing (backend) + "Return number of changes that will be sent with a `vc-push'." + (with-temp-buffer + (let ((display-buffer-overriding-action + '(display-buffer-no-window (allow-no-window . t)))) + (vc-incoming-outgoing-internal backend nil + (current-buffer) 'log-outgoing)) + (let ((proc (get-buffer-process (current-buffer)))) + (while (accept-process-output proc))) + (how-many log-view-message-re))) + ;;;###autoload (defun vc-log-search (pattern) "Search the VC log of changes for PATTERN and show log of matching changes.