;; - receive-file (file rev) ?? PROBABLY NOT NEEDED
;; - unregister (file) OK
;; * checkin (files rev comment) OK
+;; - checkin-patch (patch-string comment) OK
;; * find-revision (file rev buffer) OK
;; * checkout (file &optional rev) OK
;; * revert (file &optional contents-done) OK
(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)