aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorSean Whitton2025-04-27 11:45:54 +0800
committerSean Whitton2025-04-27 11:52:53 +0800
commit07c2b169edc2c5aaad1c8f494663a8198b2d4ca2 (patch)
tree04f09dd67ab76edec7acb4e9d6e23d824d300a20 /test
parentd047a89e769f3c8429c43a40d5f251a895590d3a (diff)
downloademacs-07c2b169edc2c5aaad1c8f494663a8198b2d4ca2.tar.gz
emacs-07c2b169edc2c5aaad1c8f494663a8198b2d4ca2.zip
Improve syncing VC buffers before generating diffs
* lisp/vc/vc.el (vc-maybe-buffer-sync): Delete. Correct handling of indirect buffers is now implicitly achieved by vc-buffer-sync-fileset. (vc-buffer-sync-fileset): Make NOT-ESSENTIAL argument optional, new MISSING-IN-DIRS optional argument. Rewrite to handle directories named in the fileset, not only files. (vc-ediff): Replace call to vc-maybe-buffer-sync with a call to vc-buffer-sync-fileset. (vc-root-diff): Similarly replace call to vc-maybe-buffer-sync. This means the user is prompted to save additional buffers, that they likely want to save before generating the diffs. * test/lisp/vc/vc-misc-tests.el: New file.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/vc/vc-misc-tests.el67
1 files changed, 67 insertions, 0 deletions
diff --git a/test/lisp/vc/vc-misc-tests.el b/test/lisp/vc/vc-misc-tests.el
new file mode 100644
index 00000000000..d19dda36d2f
--- /dev/null
+++ b/test/lisp/vc/vc-misc-tests.el
@@ -0,0 +1,67 @@
1;;; vc-misc-tests.el --- backend-agnostic VC tests -*- lexical-binding:t -*-
2
3;; Copyright (C) 2025 Free Software Foundation, Inc.
4
5;; Author: Sean Whitton <spwhitton@spwhitton.name>
6
7;; This file is part of GNU Emacs.
8
9;; GNU Emacs is free software: you can redistribute it and/or modify
10;; it under the terms of the GNU General Public License as published by
11;; the Free Software Foundation, either version 3 of the License, or
12;; (at your option) any later version.
13
14;; GNU Emacs is distributed in the hope that it will be useful,
15;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17;; GNU General Public License for more details.
18
19;; You should have received a copy of the GNU General Public License
20;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
21
22;;; Commentary:
23
24;;; Code:
25
26(require 'ert-x)
27(require 'vc)
28
29(ert-deftest vc-test-buffer-sync-fileset ()
30 "Test `vc-buffer-sync-fileset'."
31 (cl-flet ((test-it (&rest args)
32 (let (buffers)
33 (cl-letf (((symbol-function 'vc-buffer-sync)
34 (lambda (&rest _)
35 (push (current-buffer) buffers))))
36 (apply #'vc-buffer-sync-fileset args)
37 (sort buffers)))))
38 (ert-with-temp-directory temp
39 (let* ((default-directory temp)
40 (present (find-file-noselect "present"))
41 (missing (find-file-noselect "missing"))
42 (only-present (list present))
43 (only-missing (list missing))
44 (missing+present (list missing present)))
45 (with-current-buffer present (basic-save-buffer))
46 (with-temp-file "unvisited")
47 ;; Regular behavior for files.
48 (should (equal (test-it `(Git ("missing")))
49 only-missing))
50 (should (equal (test-it `(Git ("present" "missing")))
51 missing+present))
52 ;; Regular behavior for directories.
53 (should (equal (test-it `(Git (,temp)))
54 only-present))
55 ;; Two ways to override regular behavior for directories.
56 (should (equal (test-it `(Git (,temp)) nil t)
57 missing+present))
58 (should (equal (test-it `(Git (,temp "missing")))
59 missing+present))
60 ;; Doesn't sync PRESENT twice.
61 (should (equal (test-it `(Git ("present" ,temp)))
62 only-present))
63 (should (equal (test-it `(Git ("missing" ,temp "present")))
64 missing+present))))))
65
66(provide 'vc-misc-tests)
67;;; vc-misc-tests.el ends here