diff options
| author | Sean Whitton | 2025-07-25 19:34:04 +0100 |
|---|---|---|
| committer | Sean Whitton | 2025-07-25 19:34:04 +0100 |
| commit | 50ffb29d0bbb92a7c6569c83d2e3e4868c4e867b (patch) | |
| tree | 0911cfa9182a3910deb041c6bc7391f2ce849096 /test/lisp | |
| parent | 08ca6caa0a081cd67d253b09896c3789268da7a1 (diff) | |
| download | emacs-50ffb29d0bbb92a7c6569c83d2e3e4868c4e867b.tar.gz emacs-50ffb29d0bbb92a7c6569c83d2e3e4868c4e867b.zip | |
VC: New support for other working trees
* lisp/vc/vc-git.el (vc-git--read-start-point): New function,
factored out of vc-git-create-tag.
(vc-git-create-tag): Use it.
(vc-git--worktrees, vc-git-known-other-working-trees)
(vc-git-add-working-tree, vc-git-delete-working-tree)
(vc-git-move-working-tree):
* lisp/vc/vc-hg.el (vc-hg-known-other-working-trees)
(vc-hg-add-working-tree, vc-hg--shared-p)
(vc-hg-delete-working-tree, vc-hg-move-working-tree): New
functions.
* lisp/vc/vc.el: Define API for known-other-working-tree,
add-working-tree, delete-working-tree and move-working-tree
backend functions.
(vc-dir-status-files): New function.
(project-current-directory-override): Declare.
(dired-rename-subdir): Autoload.
(vc-add-working-tree, vc-switch-working-tree)
(vc-delete-working-tree, vc-move-working-tree): New commands.
* lisp/vc/vc-hooks.el (vc-prefix-map): Bind them under C-x v.
* doc/emacs/vc1-xtra.texi (Other Working Trees): New node.
* etc/NEWS: Announce the new commands.
* test/lisp/vc/vc-tests/vc-tests.el
(vc-test--other-working-trees): New function.
(vc-test-git07-other-working-trees)
(vc-test-hg07-other-working-trees): New tests.
* lisp/ldefs-boot.el: Regenerate.
Diffstat (limited to 'test/lisp')
| -rw-r--r-- | test/lisp/vc/vc-tests/vc-tests.el | 119 |
1 files changed, 118 insertions, 1 deletions
diff --git a/test/lisp/vc/vc-tests/vc-tests.el b/test/lisp/vc/vc-tests/vc-tests.el index 82f28cdad3a..9f570ca0dd1 100644 --- a/test/lisp/vc/vc-tests/vc-tests.el +++ b/test/lisp/vc/vc-tests/vc-tests.el | |||
| @@ -44,6 +44,7 @@ | |||
| 44 | ;; - latest-on-branch-p (file) | 44 | ;; - latest-on-branch-p (file) |
| 45 | ;; * checkout-model (files) DONE | 45 | ;; * checkout-model (files) DONE |
| 46 | ;; - mode-line-string (file) | 46 | ;; - mode-line-string (file) |
| 47 | ;; - other-working-trees () DONE | ||
| 47 | 48 | ||
| 48 | ;; STATE-CHANGING FUNCTIONS | 49 | ;; STATE-CHANGING FUNCTIONS |
| 49 | ;; | 50 | ;; |
| @@ -65,6 +66,9 @@ | |||
| 65 | ;; - modify-change-comment (files rev comment) | 66 | ;; - modify-change-comment (files rev comment) |
| 66 | ;; - mark-resolved (files) | 67 | ;; - mark-resolved (files) |
| 67 | ;; - find-admin-dir (file) | 68 | ;; - find-admin-dir (file) |
| 69 | ;; - add-working-tree (directory) DONE | ||
| 70 | ;; - delete-working-tree (directory) DONE | ||
| 71 | ;; - move-working-tree (from to) DONE | ||
| 68 | 72 | ||
| 69 | ;; HISTORY FUNCTIONS | 73 | ;; HISTORY FUNCTIONS |
| 70 | ;; | 74 | ;; |
| @@ -656,6 +660,103 @@ This checks also `vc-backend' and `vc-responsible-backend'." | |||
| 656 | (ignore-errors | 660 | (ignore-errors |
| 657 | (run-hooks 'vc-test--cleanup-hook)))))) | 661 | (run-hooks 'vc-test--cleanup-hook)))))) |
| 658 | 662 | ||
| 663 | (defun vc-test--other-working-trees (backend) | ||
| 664 | "Test other working trees actions." | ||
| 665 | (ert-with-temp-directory tempdir | ||
| 666 | (let ((vc-handled-backends `(,backend)) | ||
| 667 | (default-directory | ||
| 668 | (file-name-as-directory | ||
| 669 | (expand-file-name | ||
| 670 | (make-temp-name "vc-test") temporary-file-directory))) | ||
| 671 | (process-environment process-environment) | ||
| 672 | vc-test--cleanup-hook) | ||
| 673 | (unwind-protect | ||
| 674 | (progn | ||
| 675 | ;; Cleanup. | ||
| 676 | (add-hook | ||
| 677 | 'vc-test--cleanup-hook | ||
| 678 | (let ((dir default-directory)) | ||
| 679 | (lambda () | ||
| 680 | (delete-directory dir 'recursive) | ||
| 681 | (dolist (name '("first" "second" "first")) | ||
| 682 | (project-forget-project | ||
| 683 | (expand-file-name name default-directory)))))) | ||
| 684 | |||
| 685 | (let* ((first (file-name-as-directory | ||
| 686 | (expand-file-name "first" default-directory))) | ||
| 687 | (second (file-name-as-directory | ||
| 688 | (expand-file-name "second" default-directory))) | ||
| 689 | (third (file-name-as-directory | ||
| 690 | (expand-file-name "third" default-directory))) | ||
| 691 | (tmp-name (expand-file-name "foo" first))) | ||
| 692 | |||
| 693 | ;; Set up the first working tree. | ||
| 694 | (make-directory first t) | ||
| 695 | (let ((default-directory first)) | ||
| 696 | (vc-test--create-repo-function backend) | ||
| 697 | (write-region "foo" nil tmp-name nil 'nomessage) | ||
| 698 | (vc-register `(,backend (,(file-name-nondirectory tmp-name))))) | ||
| 699 | (with-current-buffer (find-file-noselect tmp-name) | ||
| 700 | (vc-checkin (list (file-name-nondirectory tmp-name)) backend) | ||
| 701 | (insert "Testing other working trees") | ||
| 702 | (let (vc-async-checkin) | ||
| 703 | (log-edit-done)) | ||
| 704 | |||
| 705 | ;; Set up the second working tree. | ||
| 706 | ;; For the backends which do additional prompting (as | ||
| 707 | ;; specified in the API for this backend function) we | ||
| 708 | ;; need to stub that out. | ||
| 709 | (cl-ecase backend | ||
| 710 | (Git (cl-letf (((symbol-function 'completing-read) | ||
| 711 | (lambda (&rest _ignore) ""))) | ||
| 712 | (vc-add-working-tree backend second))) | ||
| 713 | (Hg (vc-add-working-tree backend second)))) | ||
| 714 | |||
| 715 | ;; Test `known-other-working-trees'. | ||
| 716 | (with-current-buffer (find-file-noselect tmp-name) | ||
| 717 | (should | ||
| 718 | (equal (list second) | ||
| 719 | (vc-call-backend backend 'known-other-working-trees))) | ||
| 720 | (let ((default-directory second)) | ||
| 721 | (should | ||
| 722 | (equal (list first) | ||
| 723 | (vc-call-backend backend 'known-other-working-trees)))) | ||
| 724 | |||
| 725 | ;; Test `move-working-tree'. | ||
| 726 | (vc-move-working-tree backend second third) | ||
| 727 | (should | ||
| 728 | (equal (list third) | ||
| 729 | (vc-call-backend backend 'known-other-working-trees))) | ||
| 730 | (should-not (file-directory-p second)) | ||
| 731 | (should (file-directory-p third)) | ||
| 732 | ;; Moving the first working tree is only supported | ||
| 733 | ;; for some backends. | ||
| 734 | (cl-ecase backend | ||
| 735 | (Git | ||
| 736 | (let ((default-directory third)) | ||
| 737 | (vc-move-working-tree backend first second)) | ||
| 738 | (let ((default-directory third)) | ||
| 739 | (should | ||
| 740 | (equal (list second) | ||
| 741 | (vc-call-backend backend | ||
| 742 | 'known-other-working-trees)))) | ||
| 743 | (should-not (file-directory-p first)) | ||
| 744 | (should (file-directory-p second)) | ||
| 745 | (vc-move-working-tree backend second first)) | ||
| 746 | (Hg | ||
| 747 | (let ((default-directory third)) | ||
| 748 | (should-error (vc-move-working-tree backend | ||
| 749 | first second))))) | ||
| 750 | |||
| 751 | ;; Test `delete-working-tree'. | ||
| 752 | (let ((default-directory first)) | ||
| 753 | (vc-delete-working-tree backend third) | ||
| 754 | (should-not (file-directory-p third)))))) | ||
| 755 | |||
| 756 | ;; Save exit. | ||
| 757 | (ignore-errors | ||
| 758 | (run-hooks 'vc-test--cleanup-hook)))))) | ||
| 759 | |||
| 659 | ;; Create the test cases. | 760 | ;; Create the test cases. |
| 660 | 761 | ||
| 661 | (defun vc-test--rcs-enabled () | 762 | (defun vc-test--rcs-enabled () |
| @@ -794,7 +895,23 @@ This checks also `vc-backend' and `vc-responsible-backend'." | |||
| 794 | (eq system-type 'windows-nt) | 895 | (eq system-type 'windows-nt) |
| 795 | noninteractive)) | 896 | noninteractive)) |
| 796 | (vc-test--version-diff ',backend)) | 897 | (vc-test--version-diff ',backend)) |
| 797 | )))) | 898 | |
| 899 | (ert-deftest | ||
| 900 | ,(intern (format "vc-test-%s07-other-working-trees" backend-string)) () | ||
| 901 | ,(format "Check other working trees functions for the %s backend." | ||
| 902 | backend-string) | ||
| 903 | (skip-unless | ||
| 904 | (ert-test-passed-p | ||
| 905 | (ert-test-most-recent-result | ||
| 906 | (ert-get-test | ||
| 907 | ',(intern | ||
| 908 | (format "vc-test-%s01-register" backend-string)))))) | ||
| 909 | (skip-unless (memq ',backend '(Git Hg))) | ||
| 910 | (skip-when | ||
| 911 | (and (eq ',backend 'Hg) | ||
| 912 | (equal (car (process-lines-ignore-status "hg" "share")) | ||
| 913 | "hg: unknown command 'share'"))) | ||
| 914 | (vc-test--other-working-trees ',backend)))))) | ||
| 798 | 915 | ||
| 799 | (provide 'vc-tests) | 916 | (provide 'vc-tests) |
| 800 | ;;; vc-tests.el ends here | 917 | ;;; vc-tests.el ends here |