diff options
author | Dmitry Gutov <dgutov@yandex.ru> | 2019-04-21 00:39:36 +0300 |
---|---|---|
committer | Dmitry Gutov <dgutov@yandex.ru> | 2019-04-21 00:39:36 +0300 |
commit | 70f3175738225252acc5041b210c5b39376af1a1 (patch) | |
tree | 2e54a2eb90aa3647b28f3794e96d374fc2bf11ec /lisp/vc/vc-hg.el | |
parent | 6d1025f944128391a27b388d4cb34d187a0a26b9 (diff) | |
download | emacs-70f3175738225252acc5041b210c5b39376af1a1.tar.gz |
Support amending the last commit using VC-Hg
* lisp/vc/log-edit.el (log-edit--toggle-amend): Extract from
vc-git-log-edit-toggle-amend (bug#34944).
* lisp/vc/vc-hg.el (vc-hg-log-edit-toggle-amend): New function.
Use the aforementioned.
(vc-hg-log-edit-mode-map): New variable.
(vc-hg-log-edit-mode): New major mode.
Diffstat (limited to 'lisp/vc/vc-hg.el')
-rw-r--r-- | lisp/vc/vc-hg.el | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el index 6b17e861dda..d3f132dae70 100644 --- a/lisp/vc/vc-hg.el +++ b/lisp/vc/vc-hg.el @@ -1104,15 +1104,42 @@ hg binary." (vc-hg-command nil 0 file "forget")) (declare-function log-edit-extract-headers "log-edit" (headers string)) +(declare-function log-edit-mode "log-edit" ()) +(declare-function log-edit--toggle-amend "log-edit" (last-msg-fn)) + +(defun vc-hg-log-edit-toggle-amend () + "Toggle whether this will amend the previous commit. +If toggling on, also insert its message into the buffer." + (interactive) + (log-edit--toggle-amend + (lambda () + (with-output-to-string + (vc-hg-command + standard-output 1 nil + "log" "--limit=1" "--template" "{desc}"))))) + +(defvar vc-hg-log-edit-mode-map + (let ((map (make-sparse-keymap "Hg-Log-Edit"))) + (define-key map "\C-c\C-e" 'vc-hg-log-edit-toggle-amend) + map)) + +(define-derived-mode vc-hg-log-edit-mode log-edit-mode "Log-Edit/hg" + "Major mode for editing Hg log messages. +It is based on `log-edit-mode', and has Hg-specific extensions.") (defun vc-hg-checkin (files comment &optional _rev) "Hg-specific version of `vc-backend-checkin'. REV is ignored." - (apply 'vc-hg-command nil 0 files - (nconc (list "commit" "-m") - (log-edit-extract-headers '(("Author" . "--user") - ("Date" . "--date")) - comment)))) + (let ((amend-extract-fn + (lambda (value) + (when (equal value "yes") + (list "--amend"))))) + (apply 'vc-hg-command nil 0 files + (nconc (list "commit" "-m") + (log-edit-extract-headers `(("Author" . "--user") + ("Date" . "--date") + ("Amend" . ,amend-extract-fn)) + comment))))) (defun vc-hg-find-revision (file rev buffer) (let ((coding-system-for-read 'binary) |