emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master d586bae: vc-hg: use 'hg summary' to populate vc-dir headers


From: Lars Ingebrigtsen
Subject: master d586bae: vc-hg: use 'hg summary' to populate vc-dir headers
Date: Sun, 9 Aug 2020 08:36:56 -0400 (EDT)

branch: master
commit d586bae501a3d6ec8e6a8088d05b0abfa541dece
Author: Andrii Kolomoiets <andreyk.mad@gmail.com>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    vc-hg: use 'hg summary' to populate vc-dir headers
    
    * 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 (bug#38387).
---
 etc/NEWS         |  5 +++++
 lisp/vc/vc-hg.el | 37 ++++++++++++++++++++-----------------
 2 files changed, 25 insertions(+), 17 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 25ee6e1..b983b29 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -236,6 +236,11 @@ Bookmark locations can refer to VC directory buffers.
 *** New user option 'vc-hg-create-bookmark' controls whether a bookmark
 or branch will be created when you invoke 'C-u C-x v s' ('vc-create-tag').
 
+---
+*** 'vc-hg' now uses 'hg summary' command to populate extra 'vc-dir'
+headers.
+
+
 ** Gnus
 
 ---
diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el
index 09f8043..cb0657e 100644
--- a/lisp/vc/vc-hg.el
+++ b/lisp/vc/vc-hg.el
@@ -1384,25 +1384,28 @@ REV is the revision to check out into WORKFILE."
   (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-setup-buffer buffer)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]