diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el index 2eebe2d543..30b4e55818 100644 --- a/lisp/vc/vc-hg.el +++ b/lisp/vc/vc-hg.el @@ -1189,16 +1189,32 @@ vc-hg-log-edit-mode (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"))) + (write-region patch-string nil patch-file) + (unwind-protect + (progn + (apply #'vc-hg-command nil 0 nil + (nconc (list "import" "--bypass" patch-file "-m") + (vc-hg--extract-headers comment))) + (vc-hg-command nil 0 nil + "update" + "--merge" "--tool" "internal:local" + "tip")) + (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)