mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-15 10:30:25 -08:00
vc-test--checkin-patch: Use atomic change groups
* test/lisp/vc/vc-tests/vc-tests.el (vc-test--with-temp-change): New macro. (vc-test--checkin-patch): Use it.
This commit is contained in:
parent
6ef6b517aa
commit
8453fd59d4
1 changed files with 20 additions and 19 deletions
|
|
@ -786,6 +786,20 @@ This checks also `vc-backend' and `vc-responsible-backend'."
|
|||
(declare-function vc-hg-command "vc-hg")
|
||||
(declare-function vc-git--out-str "vc-git")
|
||||
|
||||
(defmacro vc-test--with-temp-change (buf &rest body)
|
||||
(declare (indent 1) (debug (symbolp body)))
|
||||
(cl-with-gensyms (handle)
|
||||
`(let ((,handle (prepare-change-group ,buf)))
|
||||
(unwind-protect
|
||||
(with-current-buffer ,buf
|
||||
(activate-change-group ,handle)
|
||||
(insert "bar\n")
|
||||
(basic-save-buffer)
|
||||
,@body)
|
||||
(cancel-change-group ,handle)
|
||||
(with-current-buffer ,buf
|
||||
(basic-save-buffer))))))
|
||||
|
||||
(defun vc-test--checkin-patch (backend)
|
||||
"Test preparing and checking in patches."
|
||||
(ert-with-temp-directory _tempdir
|
||||
|
|
@ -813,11 +827,6 @@ This checks also `vc-backend' and `vc-responsible-backend'."
|
|||
(revert (msg)
|
||||
"Make a commit reverting the most recent change to FILE."
|
||||
(with-current-buffer buf
|
||||
(undo-boundary)
|
||||
(revert-buffer-quick)
|
||||
(undo-boundary)
|
||||
(undo)
|
||||
(basic-save-buffer)
|
||||
(vc-checkin (list file) backend)
|
||||
(insert msg)
|
||||
(let (vc-async-checkin)
|
||||
|
|
@ -856,9 +865,7 @@ This checks also `vc-backend' and `vc-responsible-backend'."
|
|||
(log-edit-done)))
|
||||
|
||||
;; (3) Prepare a commit with a known Author & Date.
|
||||
(with-current-buffer buf
|
||||
(insert "bar\n")
|
||||
(basic-save-buffer)
|
||||
(vc-test--with-temp-change buf
|
||||
(vc-root-diff nil)
|
||||
(vc-next-action nil)
|
||||
(insert desc1)
|
||||
|
|
@ -873,7 +880,8 @@ This checks also `vc-backend' and `vc-responsible-backend'."
|
|||
;; author, date and comment from PATCH-STRING.
|
||||
(let ((patch-string (get-patch-string)))
|
||||
(revert "Revert modification, first time")
|
||||
(vc-call-backend backend 'checkin-patch patch-string nil))
|
||||
(vc-test--with-temp-change buf
|
||||
(vc-call-backend backend 'checkin-patch patch-string nil)))
|
||||
(check author date desc1)
|
||||
|
||||
;; (5) Revert it again and try applying it with
|
||||
|
|
@ -881,16 +889,9 @@ This checks also `vc-backend' and `vc-responsible-backend'."
|
|||
;; Should take the author, date but not the comment from
|
||||
;; PATCH-STRING.
|
||||
(let ((patch-string (get-patch-string)))
|
||||
;; FIXME: Why doesn't `revert' work properly here?
|
||||
(if (and (eq backend 'Git)
|
||||
(eq system-type 'windows-nt))
|
||||
(with-current-buffer buf
|
||||
(vc-checkin (list file) backend)
|
||||
(insert "Revert modification, second time")
|
||||
(let (vc-async-checkin)
|
||||
(log-edit-done)))
|
||||
(revert "Revert modification, second time"))
|
||||
(vc-call-backend backend 'checkin-patch patch-string desc2))
|
||||
(revert "Revert modification, second time")
|
||||
(vc-test--with-temp-change buf
|
||||
(vc-call-backend backend 'checkin-patch patch-string desc2)))
|
||||
(check author date desc2))
|
||||
|
||||
;; Save exit.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue