diff options
| author | Richard M. Stallman | 1993-11-12 22:31:12 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1993-11-12 22:31:12 +0000 |
| commit | d52f0de91eba27581cccf8521546e0368494a0ce (patch) | |
| tree | 96a4a66bbcc51b669082f26fdeb317ee44cea3fd | |
| parent | ae06ea79c817b855e68347eb43f8b84b61458150 (diff) | |
| download | emacs-d52f0de91eba27581cccf8521546e0368494a0ce.tar.gz emacs-d52f0de91eba27581cccf8521546e0368494a0ce.zip | |
(vc-rename-file): Don't overwrite an existing file.
Fix test for unsaved files.
Calculate name of new master file properly.
| -rw-r--r-- | lisp/vc.el | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/lisp/vc.el b/lisp/vc.el index 5adf1ca8147..145be72c7c5 100644 --- a/lisp/vc.el +++ b/lisp/vc.el | |||
| @@ -1137,19 +1137,38 @@ A prefix argument means do not revert the buffer afterwards." | |||
| 1137 | "Rename file OLD to NEW, and rename its master file likewise." | 1137 | "Rename file OLD to NEW, and rename its master file likewise." |
| 1138 | (interactive "fVC rename file: \nFRename to: ") | 1138 | (interactive "fVC rename file: \nFRename to: ") |
| 1139 | (let ((oldbuf (get-file-buffer old))) | 1139 | (let ((oldbuf (get-file-buffer old))) |
| 1140 | (if (buffer-modified-p oldbuf) | 1140 | (if (and oldbuf (buffer-modified-p oldbuf)) |
| 1141 | (error "Please save files before moving them")) | 1141 | (error "Please save files before moving them")) |
| 1142 | (if (get-file-buffer new) | 1142 | (if (get-file-buffer new) |
| 1143 | (error "Already editing new file name")) | 1143 | (error "Already editing new file name")) |
| 1144 | (if (file-exists-p new) | ||
| 1145 | (error "New file already exists")) | ||
| 1144 | (let ((oldmaster (vc-name old))) | 1146 | (let ((oldmaster (vc-name old))) |
| 1145 | (if oldmaster | 1147 | (if oldmaster |
| 1146 | (if (vc-locking-user old) | 1148 | (progn |
| 1147 | (error "Please check in files before moving them")) | 1149 | (if (vc-locking-user old) |
| 1148 | (if (or (file-symlink-p oldmaster) | 1150 | (error "Please check in files before moving them")) |
| 1149 | ;; This had FILE, I changed it to OLD. -- rms. | 1151 | (if (or (file-symlink-p oldmaster) |
| 1150 | (file-symlink-p (vc-backend-subdirectory-name old))) | 1152 | ;; This had FILE, I changed it to OLD. -- rms. |
| 1151 | (error "This is not a safe thing to do in the presence of symbolic links")) | 1153 | (file-symlink-p (vc-backend-subdirectory-name old))) |
| 1152 | (rename-file oldmaster (vc-name new))) | 1154 | (error "This is not a safe thing to do in the presence of symbolic links")) |
| 1155 | (rename-file | ||
| 1156 | oldmaster | ||
| 1157 | (let ((backend (vc-backend-deduce old)) | ||
| 1158 | (newdir (or (file-name-directory new) "")) | ||
| 1159 | (newbase (file-name-nondirectory new))) | ||
| 1160 | (catch 'found | ||
| 1161 | (mapcar | ||
| 1162 | (function | ||
| 1163 | (lambda (s) | ||
| 1164 | (if (eq backend (cdr s)) | ||
| 1165 | (let* ((newmaster (format (car s) newdir newbase)) | ||
| 1166 | (newmasterdir (file-name-directory newmaster))) | ||
| 1167 | (if (or (not newmasterdir) | ||
| 1168 | (file-directory-p newmasterdir)) | ||
| 1169 | (throw 'found newmaster)))))) | ||
| 1170 | vc-master-templates) | ||
| 1171 | (error "New file lacks a version control directory")))))) | ||
| 1153 | (if (or (not oldmaster) (file-exists-p old)) | 1172 | (if (or (not oldmaster) (file-exists-p old)) |
| 1154 | (rename-file old new))) | 1173 | (rename-file old new))) |
| 1155 | ; ?? Renaming a file might change its contents due to keyword expansion. | 1174 | ; ?? Renaming a file might change its contents due to keyword expansion. |