diff options
Diffstat (limited to 'lisp/vc/vc-hg.el')
-rw-r--r-- | lisp/vc/vc-hg.el | 62 |
1 files changed, 50 insertions, 12 deletions
diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el index d6227d67820..d3f132dae70 100644 --- a/lisp/vc/vc-hg.el +++ b/lisp/vc/vc-hg.el @@ -1,6 +1,6 @@ ;;; vc-hg.el --- VC backend for the mercurial version control system -*- lexical-binding: t -*- -;; Copyright (C) 2006-2018 Free Software Foundation, Inc. +;; Copyright (C) 2006-2019 Free Software Foundation, Inc. ;; Author: Ivan Kanis ;; Maintainer: emacs-devel@gnu.org @@ -145,6 +145,15 @@ switches." :version "25.1" :group 'vc-hg) +(defcustom vc-hg-revert-switches nil + "String or list of strings specifying switches for hg revert +under VC." + :type '(choice (const :tag "None" nil) + (string :tag "Argument String") + (repeat :tag "Argument List" :value ("") string)) + :version "27.1" + :group 'vc-hg) + (defcustom vc-hg-program "hg" "Name of the Mercurial executable (excluding any arguments)." :type 'string @@ -914,9 +923,6 @@ FILENAME must be the file's true absolute name." (setf ignored (string-match (pop patterns) filename))) ignored)) -(defun vc-hg--time-to-integer (ts) - (+ (* 65536 (car ts)) (cadr ts))) - (defvar vc-hg--cached-ignore-patterns nil "Cached pre-parsed hg ignore patterns.") @@ -1037,8 +1043,9 @@ hg binary." (let ((vc-hg-size (nth 2 dirstate-entry)) (vc-hg-mtime (nth 3 dirstate-entry)) (fs-size (file-attribute-size stat)) - (fs-mtime (vc-hg--time-to-integer - (file-attribute-modification-time stat)))) + (fs-mtime (encode-time + (file-attribute-modification-time stat) + 'integer))) (if (and (eql vc-hg-size fs-size) (eql vc-hg-mtime fs-mtime)) 'up-to-date 'edited))) @@ -1097,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) @@ -1161,7 +1195,11 @@ REV is the revision to check out into WORKFILE." ;; Modeled after the similar function in vc-bzr.el (defun vc-hg-revert (file &optional contents-done) (unless contents-done - (with-temp-buffer (vc-hg-command t 0 file "revert")))) + (with-temp-buffer + (apply #'vc-hg-command + t 0 file + "revert" + (append (vc-switches 'hg 'revert)))))) ;;; Hg specific functionality. |