mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-06-14 12:31:25 +00:00
Fix renaming files and directories under RCS
* lisp/vc/vc-rcs.el (vc-rcs-register): Filter out directories from FILES. (vc-rcs-rename-file): Support OLD being a directory. * test/lisp/vc/vc-tests/vc-tests.el (vc-test--rename-file) (vc-test--rename-directory): Re-enable these tests for RCS. (vc-test--rename-directory): Disable 'yes-or-no-p' questions that RCS asks when it needs to create the RCS/ subdirectory: this lets the test run without user interaction.
This commit is contained in:
parent
5147a78dd1
commit
bbdab523b4
2 changed files with 36 additions and 26 deletions
|
|
@ -249,6 +249,9 @@ COMMENT can be used to provide an initial description for each FILES.
|
|||
Passes either `vc-rcs-register-switches' or `vc-register-switches'
|
||||
to the RCS command."
|
||||
(let (subdir name)
|
||||
;; RCS doesn't track directories, and 'ci' will fail if passed a
|
||||
;; directory name.
|
||||
(setq files (seq-remove #'file-directory-p files))
|
||||
(dolist (file files)
|
||||
(and (not (file-exists-p
|
||||
(setq subdir (expand-file-name "RCS"
|
||||
|
|
@ -945,8 +948,11 @@ Uses `rcs2log' which only works for RCS and CVS."
|
|||
(autoload 'vc-rename-master "vc-filewise")
|
||||
|
||||
(defun vc-rcs-rename-file (old new)
|
||||
;; Just move the master file (using vc-rcs-master-templates).
|
||||
(vc-rename-master (vc-master-name old) new vc-rcs-master-templates))
|
||||
(if (file-directory-p old)
|
||||
;; RCS doesn't track directories, so just rename the directory.
|
||||
(rename-file old new)
|
||||
;; Just move the master file (using vc-rcs-master-templates).
|
||||
(vc-rename-master (vc-master-name old) new vc-rcs-master-templates)))
|
||||
|
||||
(defun vc-rcs-find-file-hook ()
|
||||
;; If the file is locked by some other user, make
|
||||
|
|
|
|||
|
|
@ -609,20 +609,18 @@ This checks also `vc-backend' and `vc-responsible-backend'."
|
|||
(should (file-exists-p new-name))))
|
||||
|
||||
;; Test moving into an existing directory.
|
||||
;; FIXME: This is broken for RCS and I don't know why. --spwhitton
|
||||
(unless (eq backend 'RCS)
|
||||
(let ((tmp-name (expand-file-name "quux" default-directory))
|
||||
(new-dir (expand-file-name "dir1/" default-directory))
|
||||
(new-name (expand-file-name "dir1/quux" default-directory)))
|
||||
(make-directory new-dir)
|
||||
(write-region "quux" nil tmp-name nil 'nomessage)
|
||||
(vc-register
|
||||
`(,backend (,(file-relative-name new-dir default-directory)
|
||||
,(file-name-nondirectory tmp-name))))
|
||||
(let ((tmp-name (expand-file-name "quux" default-directory))
|
||||
(new-dir (expand-file-name "dir1/" default-directory))
|
||||
(new-name (expand-file-name "dir1/quux" default-directory)))
|
||||
(make-directory new-dir)
|
||||
(write-region "quux" nil tmp-name nil 'nomessage)
|
||||
(vc-register
|
||||
`(,backend (,(file-relative-name new-dir default-directory)
|
||||
,(file-name-nondirectory tmp-name))))
|
||||
|
||||
(vc-rename-file tmp-name new-dir)
|
||||
(should-not (file-exists-p tmp-name))
|
||||
(should (file-exists-p new-name)))))
|
||||
(vc-rename-file tmp-name new-dir)
|
||||
(should-not (file-exists-p tmp-name))
|
||||
(should (file-exists-p new-name))))
|
||||
|
||||
;; Save exit.
|
||||
(ignore-errors
|
||||
|
|
@ -662,10 +660,14 @@ This checks also `vc-backend' and `vc-responsible-backend'."
|
|||
(write-region "foo" nil tmp-name1 nil 'nomessage)
|
||||
(write-region "bar" nil tmp-name2 nil 'nomessage)
|
||||
;; Register TMP-NAME1 but *not* TMP-NAME2.
|
||||
(vc-register `(,backend
|
||||
(,(file-relative-name tmp-name1
|
||||
default-directory))))
|
||||
|
||||
;; (We disable yes-or-no-p for RCS, which asks whether to
|
||||
;; create the RCS/ subdirectory of a directory where we
|
||||
;; register the first file.)
|
||||
(cl-letf (((symbol-function #'yes-or-no-p)
|
||||
#'always))
|
||||
(vc-register `(,backend
|
||||
(,(file-relative-name tmp-name1
|
||||
default-directory)))))
|
||||
(vc-rename-file (directory-file-name tmp-dir)
|
||||
(directory-file-name new-dir))
|
||||
(should-not (file-exists-p tmp-name1))
|
||||
|
|
@ -697,9 +699,14 @@ This checks also `vc-backend' and `vc-responsible-backend'."
|
|||
(new-name (expand-file-name "foo" new-dir)))
|
||||
(make-directory tmp-dir)
|
||||
(write-region "foo" nil tmp-name nil 'nomessage)
|
||||
(vc-register `(,backend
|
||||
(,(file-relative-name tmp-name
|
||||
default-directory))))
|
||||
;; (We disable yes-or-no-p for RCS, which asks whether to
|
||||
;; create the RCS/ subdirectory of a directory where we
|
||||
;; register the first file.)
|
||||
(cl-letf (((symbol-function #'yes-or-no-p)
|
||||
#'always))
|
||||
(vc-register `(,backend
|
||||
(,(file-relative-name tmp-name
|
||||
default-directory)))))
|
||||
|
||||
(vc-rename-file (directory-file-name tmp-dir)
|
||||
(directory-file-name new-dir))
|
||||
|
|
@ -1324,10 +1331,7 @@ This checks also `vc-backend' and `vc-responsible-backend'."
|
|||
;; See vc-test-*-rename-file regarding CVS and Mtn.
|
||||
;; SVN requires all files to rename are registered but we want
|
||||
;; to test a mix of registered and unregistered files in this test.
|
||||
;; RCS does not seem to support renaming directories; possibly
|
||||
;; `vc-rcs-rename-file' could be improved or it might be a
|
||||
;; fundamental limitation.
|
||||
(skip-when (memq ',backend '(CVS SVN Mtn RCS)))
|
||||
(skip-when (memq ',backend '(CVS SVN Mtn)))
|
||||
(vc-test--rename-directory ',backend))))))
|
||||
|
||||
(provide 'vc-tests)
|
||||
|
|
|
|||
Loading…
Reference in a new issue