Mercurial > emacs
comparison lisp/vc.el @ 32097:adf341c172af
(vc-transfer-file, vc-default-receive-file): Rewritten to factorize
backend-specific code cleanly.
(vc-unregister): Function removed.
author | André Spiegel <spiegel@gnu.org> |
---|---|
date | Tue, 03 Oct 2000 12:24:15 +0000 |
parents | 5c36fa51ee96 |
children | 3aab429d3c8a |
comparison
equal
deleted
inserted
replaced
32096:e7f273d850bf | 32097:adf341c172af |
---|---|
3 ;; Copyright (C) 1992,93,94,95,96,97,98,2000 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1992,93,94,95,96,97,98,2000 Free Software Foundation, Inc. |
4 | 4 |
5 ;; Author: FSF (see below for full credits) | 5 ;; Author: FSF (see below for full credits) |
6 ;; Maintainer: Andre Spiegel <spiegel@gnu.org> | 6 ;; Maintainer: Andre Spiegel <spiegel@gnu.org> |
7 | 7 |
8 ;; $Id$ | 8 ;; $Id: vc.el,v 1.275 2000/10/03 11:22:13 spiegel Exp $ |
9 | 9 |
10 ;; This file is part of GNU Emacs. | 10 ;; This file is part of GNU Emacs. |
11 | 11 |
12 ;; GNU Emacs is free software; you can redistribute it and/or modify | 12 ;; GNU Emacs is free software; you can redistribute it and/or modify |
13 ;; it under the terms of the GNU General Public License as published by | 13 ;; it under the terms of the GNU General Public License as published by |
91 ;; - merge (file rev1 rev2) | 91 ;; - merge (file rev1 rev2) |
92 ;; - steal-lock (file &optional version) | 92 ;; - steal-lock (file &optional version) |
93 ;; Only required if files can be locked by somebody else. | 93 ;; Only required if files can be locked by somebody else. |
94 ;; * register (file rev comment) | 94 ;; * register (file rev comment) |
95 ;; * unregister (file backend) | 95 ;; * unregister (file backend) |
96 ;; - receive-file (file move) | 96 ;; - receive-file (file rev) |
97 ;; - responsible-p (file) | 97 ;; - responsible-p (file) |
98 ;; Should also work if FILE is a directory (ends with a slash). | 98 ;; Should also work if FILE is a directory (ends with a slash). |
99 ;; - could-register (file) | 99 ;; - could-register (file) |
100 ;; * checkout (file writable &optional rev destfile) | 100 ;; * checkout (file writable &optional rev destfile) |
101 ;; Checkout revision REV of FILE into DESTFILE. | 101 ;; Checkout revision REV of FILE into DESTFILE. |
1126 (defun vc-default-could-register (backend file) | 1126 (defun vc-default-could-register (backend file) |
1127 "Return non-nil if BACKEND could be used to register FILE. | 1127 "Return non-nil if BACKEND could be used to register FILE. |
1128 The default implementation returns t for all files." | 1128 The default implementation returns t for all files." |
1129 t) | 1129 t) |
1130 | 1130 |
1131 (defun vc-unregister (file) | |
1132 "Unregister FILE from version control system BACKEND." | |
1133 (vc-call unregister file) | |
1134 (vc-file-clearprops file)) | |
1135 | |
1136 (defun vc-default-unregister (backend file) | |
1137 "Default implementation of `vc-unregister', signals an error." | |
1138 (error "Unregistering files is not supported for %s" backend)) | |
1139 | |
1140 (defun vc-resynch-window (file &optional keep noquery) | 1131 (defun vc-resynch-window (file &optional keep noquery) |
1141 "If FILE is in the current buffer, either revert or unvisit it. | 1132 "If FILE is in the current buffer, either revert or unvisit it. |
1142 The choice between revert (to see expanded keywords) and unvisit depends on | 1133 The choice between revert (to see expanded keywords) and unvisit depends on |
1143 `vc-keep-workfiles'. NOQUERY if non-nil inhibits confirmation for | 1134 `vc-keep-workfiles'. NOQUERY if non-nil inhibits confirmation for |
1144 reverting. NOQUERY should be t *only* if it is known the only | 1135 reverting. NOQUERY should be t *only* if it is known the only |
2288 NEW-BACKEND, using the version number from the current backend as the | 2279 NEW-BACKEND, using the version number from the current backend as the |
2289 base level. If NEW-BACKEND has a lower precedence than the current | 2280 base level. If NEW-BACKEND has a lower precedence than the current |
2290 backend, then commit all changes that were made under the current | 2281 backend, then commit all changes that were made under the current |
2291 backend to NEW-BACKEND, and unregister FILE from the current backend. | 2282 backend to NEW-BACKEND, and unregister FILE from the current backend. |
2292 \(If FILE is not yet registered under NEW-BACKEND, register it.)" | 2283 \(If FILE is not yet registered under NEW-BACKEND, register it.)" |
2293 (let ((old-backend (vc-backend file))) | 2284 (let* ((old-backend (vc-backend file)) |
2285 (edited (memq (vc-state file) '(edited needs-merge))) | |
2286 (registered (vc-call-backend new-backend 'registered file)) | |
2287 (move | |
2288 (and registered ; Never move if not registered in new-backend yet. | |
2289 ;; move if new-backend comes later in vc-handled-backends | |
2290 (or (memq new-backend (memq old-backend vc-handled-backends)) | |
2291 (y-or-n-p "Final transfer ? ")))) | |
2292 (comment nil)) | |
2294 (if (eq old-backend new-backend) | 2293 (if (eq old-backend new-backend) |
2295 (error "%s is the current backend of %s" | 2294 (error "%s is the current backend of %s" new-backend file)) |
2296 new-backend file) | 2295 (if registered |
2297 (with-vc-properties | 2296 (set-file-modes file (logior (file-modes file) 128)) |
2298 file | 2297 ;; `registered' might have switched under us. |
2299 (vc-call-backend new-backend 'receive-file file | 2298 (vc-switch-backend file old-backend) |
2300 ;; set MOVE argument if new-backend | 2299 (let ((copy (and edited (make-temp-name file))) |
2301 ;; comes later in vc-handled-backends | 2300 (rev (vc-workfile-version file))) |
2302 (memq new-backend | 2301 ;; Go back to the base unmodified file. |
2303 (memq old-backend vc-handled-backends))) | 2302 (unwind-protect |
2304 `((vc-backend ,new-backend)))) | 2303 (progn |
2305 (vc-resynch-buffer file t t))) | 2304 (when copy (copy-file file copy)) ; (vc-revert-file file)) |
2306 | 2305 ; TODO: uncomment when we |
2307 (defun vc-default-receive-file (backend file move) | 2306 ; have local version caching |
2308 "Let BACKEND receive FILE from another version control system. | 2307 (vc-call-backend new-backend 'receive-file file rev)) |
2309 If MOVE is non-nil, then FILE is unregistered from the old | 2308 (when copy |
2310 backend and its comment history is used as the initial contents | 2309 (vc-switch-backend file new-backend) |
2311 of the log entry buffer." | 2310 (unless (eq (vc-checkout-model file) 'implicit) |
2312 (let ((old-backend (vc-backend file)) | 2311 (vc-checkout file t nil)) |
2313 (rev (vc-workfile-version file)) | 2312 (rename-file copy file 'ok-if-already-exists))))) |
2314 (state (vc-state file)) | 2313 (when move |
2315 (comment (and move (vc-call comment-history file)))) | 2314 (vc-switch-backend file old-backend) |
2316 (if move (vc-unregister file)) | 2315 (setq comment (vc-call comment-history file)) |
2317 (vc-file-clearprops file) | 2316 (vc-call unregister file)) |
2318 (if (not (vc-call-backend backend 'registered file)) | 2317 (vc-switch-backend file new-backend) |
2319 (with-vc-properties | 2318 (when (or move edited) |
2320 file | |
2321 ;; TODO: If the file was 'edited under the old backend, | |
2322 ;; this should actually register the version | |
2323 ;; it was based on. | |
2324 (vc-call-backend backend 'register file rev "") | |
2325 `((vc-backend ,backend))) | |
2326 (vc-file-setprop file 'vc-backend backend) | |
2327 (vc-file-setprop file 'vc-state 'edited) | |
2328 (set-file-modes file | |
2329 (logior (file-modes file) 128))) | |
2330 (when (or move (eq state 'edited)) | |
2331 (vc-file-setprop file 'vc-state 'edited) | 2319 (vc-file-setprop file 'vc-state 'edited) |
2332 (vc-checkin file nil comment (stringp comment))))) | 2320 (vc-checkin file nil comment (stringp comment))))) |
2321 | |
2322 (defun vc-default-unregister (backend file) | |
2323 "Default implementation of `vc-unregister', signals an error." | |
2324 (error "Unregistering files is not supported for %s" backend)) | |
2325 | |
2326 (defun vc-default-receive-file (backend file rev) | |
2327 "Let BACKEND receive FILE from another version control system." | |
2328 (vc-call-backend backend 'register file rev "")) | |
2333 | 2329 |
2334 (defun vc-rename-master (oldmaster newfile templates) | 2330 (defun vc-rename-master (oldmaster newfile templates) |
2335 "Rename OLDMASTER to be the master file for NEWFILE based on TEMPLATES." | 2331 "Rename OLDMASTER to be the master file for NEWFILE based on TEMPLATES." |
2336 (let* ((dir (file-name-directory (expand-file-name oldmaster))) | 2332 (let* ((dir (file-name-directory (expand-file-name oldmaster))) |
2337 (newdir (or (file-name-directory newfile) "")) | 2333 (newdir (or (file-name-directory newfile) "")) |