From: Andrii Kolomoiets <andreyk.mad@gmail.com>
To: 38387@debbugs.gnu.org
Subject: bug#38387: 27.0.50; [PATCH] vc-hg: use 'hg summary' to populate vc-dir headers
Date: Tue, 26 Nov 2019 17:16:07 +0200 [thread overview]
Message-ID: <DE1FB6AF-1746-40E8-9B9F-D165415303B0@gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 183 bytes --]
Hi,
By invoking single 'summary' command we can get more info about
repository state: parent revisions, current branch, tags, bookmarks,
commit status, available updates and phase.
[-- Attachment #2: 0001-vc-hg-use-hg-summary-to-populate-extra-vc-dir-header.patch --]
[-- Type: application/octet-stream, Size: 3231 bytes --]
From 77350d57f718efbf96d4c8deb59b80e22c2ebea7 Mon Sep 17 00:00:00 2001
From: Andrii Kolomoiets <andreyk.mad@gmail.com>
Date: Tue, 26 Nov 2019 17:10:29 +0200
Subject: [PATCH] vc-hg: use 'hg summary' to populate vc-dir headers
By invoking single 'summary' command we can get more info about
repository state: parent revisions, current branch, tags, bookmarks,
commit status, available updates and phase.
* lisp/vc/vc-hg.el (vc-hg-dir-extra-headers): Use 'hg summary' command.
(vc-hg-dir-extra-header): Remove unused function.
* etc/NEWS: Mention changes to vc-hg.el
diff --git a/etc/NEWS b/etc/NEWS
index d3331daf17..f7abfb1680 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -956,6 +956,10 @@ with conflicts existed in earlier versions of Emacs, but incorrectly
never detected a conflict due to invalid assumptions about cached
values.
+---
+*** 'vc-hg' now uses 'hg summary' command to populate extra 'vc-dir'
+headers.
+
+++
*** The Hg (Mercurial) back-end now supports 'vc-region-history'.
The 'C-x v h' command now works in buffers that visit files controlled
diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el
index 17d38fa400..6ff4923a14 100644
--- a/lisp/vc/vc-hg.el
+++ b/lisp/vc/vc-hg.el
@@ -1357,25 +1357,28 @@ vc-hg-dir-status-files
(vc-run-delayed
(vc-hg-after-dir-status update-function)))
-(defun vc-hg-dir-extra-header (name &rest commands)
- (concat (propertize name 'face 'font-lock-type-face)
- (propertize
- (with-temp-buffer
- (apply 'vc-hg-command (current-buffer) 0 nil commands)
- (buffer-substring-no-properties (point-min) (1- (point-max))))
- 'face 'font-lock-variable-name-face)))
-
(defun vc-hg-dir-extra-headers (dir)
- "Generate extra status headers for a Mercurial tree."
+ "Generate extra status headers for a repository in DIR.
+This runs the command \"hg summary\"."
(let ((default-directory dir))
- (concat
- (vc-hg-dir-extra-header "Root : " "root") "\n"
- (vc-hg-dir-extra-header "Branch : " "id" "-b") "\n"
- (vc-hg-dir-extra-header "Tags : " "id" "-t") ; "\n"
- ;; these change after each commit
- ;; (vc-hg-dir-extra-header "Local num : " "id" "-n") "\n"
- ;; (vc-hg-dir-extra-header "Global id : " "id" "-i")
- )))
+ (with-temp-buffer
+ (vc-hg-command t 0 nil "summary")
+ (goto-char (point-min))
+ (mapconcat
+ #'identity
+ (let (result)
+ (while (not (eobp))
+ (push
+ (let ((entry (if (looking-at "\\([^ ].*\\): \\(.*\\)")
+ (cons (capitalize (match-string 1)) (match-string 2))
+ (cons "" (buffer-substring (point) (line-end-position))))))
+ (concat
+ (propertize (format "%-11s: " (car entry)) 'face 'font-lock-type-face)
+ (propertize (cdr entry) 'face 'font-lock-variable-name-face)))
+ result)
+ (forward-line))
+ (nreverse result))
+ "\n"))))
(defun vc-hg-log-incoming (buffer remote-location)
(vc-hg-command buffer 1 nil "incoming" "-n" (unless (string= remote-location "")
--
2.15.1
next reply other threads:[~2019-11-26 15:16 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-26 15:16 Andrii Kolomoiets [this message]
2019-11-27 12:30 ` bug#38387: 27.0.50; [PATCH] vc-hg: use 'hg summary' to populate vc-dir headers Dmitry Gutov
2019-11-27 13:37 ` Andreas Schwab
2019-11-27 13:56 ` Dmitry Gutov
2019-11-27 18:53 ` Daniel Colascione
2019-11-28 8:07 ` Andrii Kolomoiets
2019-12-02 0:31 ` Dmitry Gutov
2019-12-02 0:53 ` Daniel Colascione
2020-08-09 12:36 ` Lars Ingebrigtsen
2019-11-28 9:50 ` Dmitry Gutov
2019-11-28 8:20 ` Andrii Kolomoiets
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DE1FB6AF-1746-40E8-9B9F-D165415303B0@gmail.com \
--to=andreyk.mad@gmail.com \
--cc=38387@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).