diff options
| author | Richard M. Stallman | 1995-07-29 01:40:43 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1995-07-29 01:40:43 +0000 |
| commit | 503b5c85913d2d845e1acfd6df66977c96c2dd94 (patch) | |
| tree | a7928cb642f0990072faa408d4765d06bd689ceb | |
| parent | 848e24545c06d0188c941cc3001dbf0eb47a2271 (diff) | |
| download | emacs-503b5c85913d2d845e1acfd6df66977c96c2dd94.tar.gz emacs-503b5c85913d2d845e1acfd6df66977c96c2dd94.zip | |
(vc-resynch-buffer): New function.
(vc-locked-example): Renamed to vc-snapshot-precondition. It now also
checks whether any of the files are visited.
(vc-retrieve-snapshot): If any files are visited, ask whether to
revert their buffers. Use vc-backend-checkout and vc-resynch-buffer
to do that, instead of vc-checkout.
(vc-backend-checkout): Adjust default-directory so that the
checked-out file goes to the right place.
| -rw-r--r-- | lisp/vc.el | 59 |
1 files changed, 41 insertions, 18 deletions
diff --git a/lisp/vc.el b/lisp/vc.el index 96d1a156ed2..af950518703 100644 --- a/lisp/vc.el +++ b/lisp/vc.el | |||
| @@ -696,6 +696,14 @@ merge in the changes into your working copy." | |||
| 696 | (vc-mode-line buffer-file-name)) | 696 | (vc-mode-line buffer-file-name)) |
| 697 | (kill-buffer (current-buffer))))) | 697 | (kill-buffer (current-buffer))))) |
| 698 | 698 | ||
| 699 | (defun vc-resynch-buffer (file &optional keep noquery) | ||
| 700 | ;; if FILE is currently visited, resynch it's buffer | ||
| 701 | (let ((buffer (get-file-buffer file))) | ||
| 702 | (if buffer | ||
| 703 | (save-excursion | ||
| 704 | (set-buffer buffer) | ||
| 705 | (vc-resynch-window file keep noquery))))) | ||
| 706 | |||
| 699 | (defun vc-start-entry (file rev comment msg action &optional after-hook) | 707 | (defun vc-start-entry (file rev comment msg action &optional after-hook) |
| 700 | ;; Accept a comment for an operation on FILE revision REV. If COMMENT | 708 | ;; Accept a comment for an operation on FILE revision REV. If COMMENT |
| 701 | ;; is nil, pop up a VC-log buffer, emit MSG, and set the | 709 | ;; is nil, pop up a VC-log buffer, emit MSG, and set the |
| @@ -1268,15 +1276,20 @@ in all these directories. With a prefix argument, it lists all files." | |||
| 1268 | 1276 | ||
| 1269 | ;; Named-configuration entry points | 1277 | ;; Named-configuration entry points |
| 1270 | 1278 | ||
| 1271 | (defun vc-locked-example () | 1279 | (defun vc-snapshot-precondition () |
| 1272 | ;; Return an example of why the current directory is not ready to be snapshot | 1280 | ;; Scan the tree below the current directory. |
| 1273 | ;; or nil if no such example exists. | 1281 | ;; If any files are locked, return the name of the first such file. |
| 1274 | (catch 'vc-locked-example | 1282 | ;; (This means, neither snapshot creation nor retrieval is allowed.) |
| 1275 | (vc-file-tree-walk | 1283 | ;; If one or more of the files are currently visited, return `visited'. |
| 1276 | (function (lambda (f) | 1284 | ;; Otherwise, return nil. |
| 1277 | (if (and (vc-registered f) (vc-locking-user f)) | 1285 | (let ((status nil)) |
| 1278 | (throw 'vc-locked-example f))))) | 1286 | (catch 'vc-locked-example |
| 1279 | nil)) | 1287 | (vc-file-tree-walk |
| 1288 | (function (lambda (f) | ||
| 1289 | (and (vc-registered f) | ||
| 1290 | (if (vc-locking-user f) (throw 'vc-locked-example f) | ||
| 1291 | (if (get-file-buffer f) (setq status 'visited))))))) | ||
| 1292 | status))) | ||
| 1280 | 1293 | ||
| 1281 | ;;;###autoload | 1294 | ;;;###autoload |
| 1282 | (defun vc-create-snapshot (name) | 1295 | (defun vc-create-snapshot (name) |
| @@ -1285,9 +1298,9 @@ The snapshot is made from all registered files at or below the current | |||
| 1285 | directory. For each file, the version level of its latest | 1298 | directory. For each file, the version level of its latest |
| 1286 | version becomes part of the named configuration." | 1299 | version becomes part of the named configuration." |
| 1287 | (interactive "sNew snapshot name: ") | 1300 | (interactive "sNew snapshot name: ") |
| 1288 | (let ((locked (vc-locked-example))) | 1301 | (let ((result (vc-snapshot-precondition))) |
| 1289 | (if locked | 1302 | (if (stringp result) |
| 1290 | (error "File %s is locked" locked) | 1303 | (error "File %s is locked" result) |
| 1291 | (vc-file-tree-walk | 1304 | (vc-file-tree-walk |
| 1292 | (function (lambda (f) (and | 1305 | (function (lambda (f) (and |
| 1293 | (vc-name f) | 1306 | (vc-name f) |
| @@ -1301,14 +1314,18 @@ This function fails if any files are locked at or below the current directory | |||
| 1301 | Otherwise, all registered files are checked out (unlocked) at their version | 1314 | Otherwise, all registered files are checked out (unlocked) at their version |
| 1302 | levels in the snapshot." | 1315 | levels in the snapshot." |
| 1303 | (interactive "sSnapshot name to retrieve: ") | 1316 | (interactive "sSnapshot name to retrieve: ") |
| 1304 | (let ((locked (vc-locked-example))) | 1317 | (let ((result (vc-snapshot-precondition)) |
| 1305 | (if locked | 1318 | (update nil)) |
| 1306 | (error "File %s is locked" locked) | 1319 | (if (stringp result) |
| 1320 | (error "File %s is locked" result) | ||
| 1321 | (if (eq result 'visited) | ||
| 1322 | (setq update (yes-or-no-p "Update the affected buffers? "))) | ||
| 1307 | (vc-file-tree-walk | 1323 | (vc-file-tree-walk |
| 1308 | (function (lambda (f) (and | 1324 | (function (lambda (f) (and |
| 1309 | (vc-name f) | 1325 | (vc-name f) |
| 1310 | (vc-error-occurred | 1326 | (vc-error-occurred |
| 1311 | (vc-checkout f nil name)))))) | 1327 | (vc-backend-checkout f nil name) |
| 1328 | (if update (vc-resynch-buffer f t t))))))) | ||
| 1312 | ))) | 1329 | ))) |
| 1313 | 1330 | ||
| 1314 | ;; Miscellaneous other entry points | 1331 | ;; Miscellaneous other entry points |
| @@ -1556,11 +1573,16 @@ From a program, any arguments are passed to the `rcs2log' script." | |||
| 1556 | 1573 | ||
| 1557 | (defun vc-backend-checkout (file &optional writable rev workfile) | 1574 | (defun vc-backend-checkout (file &optional writable rev workfile) |
| 1558 | ;; Retrieve a copy of a saved version into a workfile | 1575 | ;; Retrieve a copy of a saved version into a workfile |
| 1559 | (let ((filename (or workfile file))) | 1576 | (let ((filename (or workfile file)) |
| 1577 | (file-buffer (get-file-buffer file)) | ||
| 1578 | (old-default-dir default-directory)) | ||
| 1560 | (message "Checking out %s..." filename) | 1579 | (message "Checking out %s..." filename) |
| 1561 | (save-excursion | 1580 | (save-excursion |
| 1562 | ;; Change buffers to get local value of vc-checkin-switches. | 1581 | ;; Change buffers to get local value of vc-checkin-switches. |
| 1563 | (set-buffer (or (get-file-buffer file) (current-buffer))) | 1582 | (if file-buffer (set-buffer file-buffer)) |
| 1583 | ;; Adjust the default-directory so that the check-out creates | ||
| 1584 | ;; the file in the right place. The old value is restored below. | ||
| 1585 | (setq default-directory (file-name-directory filename)) | ||
| 1564 | (vc-backend-dispatch file | 1586 | (vc-backend-dispatch file |
| 1565 | (if workfile;; SCCS | 1587 | (if workfile;; SCCS |
| 1566 | ;; Some SCCS implementations allow checking out directly to a | 1588 | ;; Some SCCS implementations allow checking out directly to a |
| @@ -1660,6 +1682,7 @@ From a program, any arguments are passed to the `rcs2log' script." | |||
| 1660 | vc-checkout-switches) | 1682 | vc-checkout-switches) |
| 1661 | (vc-file-setprop file 'vc-workfile-version nil)) | 1683 | (vc-file-setprop file 'vc-workfile-version nil)) |
| 1662 | )) | 1684 | )) |
| 1685 | (setq default-directory old-default-dir) | ||
| 1663 | (cond | 1686 | (cond |
| 1664 | ((not workfile) | 1687 | ((not workfile) |
| 1665 | (vc-file-clear-masterprops file) | 1688 | (vc-file-clear-masterprops file) |