diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el index f4a44df3c2..d5740b6e21 100644 --- a/lisp/vc/vc-hg.el +++ b/lisp/vc/vc-hg.el @@ -1185,19 +1185,33 @@ vc-hg-log-edit-mode "Major mode for editing Hg log messages. It is based on `log-edit-mode', and has Hg-specific extensions.") +(defvar vc-hg-patch-string nil) + (defun vc-hg-checkin (files comment &optional _rev) "Hg-specific version of `vc-backend-checkin'. REV is ignored." - (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))))) + (apply #'vc-hg-command nil 0 files + (nconc (list "commit" + "-m") + (vc-hg--extract-headers comment)))) + +(defun vc-hg-checkin-patch (patch-string comment) + (let ((patch-file (make-temp-file "hg-patch"))) + (with-temp-file patch-file + (insert patch-string)) + (unwind-protect + (apply #'vc-hg-command nil 0 nil + (nconc (list "import" "--bypass" patch-file "-m") + (vc-hg--extract-headers comment))) + (delete-file patch-file)))) + +(defun vc-hg--extract-headers (comment) + (log-edit-extract-headers `(("Author" . "--user") + ("Date" . "--date") + ("Amend" . (lambda (value) + (when (equal value "yes") + (list "--amend"))))) + comment)) (defun vc-hg-find-revision (file rev buffer) (let ((coding-system-for-read 'binary)