summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2008-04-29 15:32:56 +0000
committerStefan Monnier <monnier@iro.umontreal.ca>2008-04-29 15:32:56 +0000
commite0607aaa2c6b33104fed475eb15452b2cdb6df03 (patch)
treebb3f35077180a6aa3f3fcf7399c68d4b7e2a4fb4 /lisp
parentb95ced6beee4bf2afccfc5aa0670d110d6afdfa6 (diff)
downloademacs-e0607aaa2c6b33104fed475eb15452b2cdb6df03.tar.gz
Make `checkout-model' apply to filesets.
* vc-hooks.el (vc-checkout-model): Rewrite. (vc-before-save, vc-after-save): Adjust callers accordingly. * vc.el (vc-editable-p, vc-next-action, vc-checkout, vc-update) (vc-transfer-file): Adjust callers accordingly. * vc-rcs.el (vc-rcs-checkout-model): Adjust arg. (vc-rcs-state, vc-rcs-state-heuristic, vc-rcs-receive-file) (vc-rcs-checkout, vc-rcs-fetch-master-state): Use vc-rcs-checkout-model instead of vc-checkout-model. * vc-mcvs.el (vc-mcvs-revert): Use vc-mcvs-checkout-model i.s.o vc-checkout-model. * vc-cvs.el (vc-cvs-checkout-model): Adjust arg. (vc-cvs-revert): Use vc-cvs-checkout-model i.s.o vc-checkout-model. * vc-svn.el (vc-svn-checkout-model): * vc-hg.el (vc-hg-checkout-model): * vc-git.el (vc-git-checkout-model): * vc-bzr.el (vc-bzr-checkout-model): Adjust arg.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog18
-rw-r--r--lisp/vc-bzr.el3
-rw-r--r--lisp/vc-cvs.el32
-rw-r--r--lisp/vc-git.el3
-rw-r--r--lisp/vc-hg.el3
-rw-r--r--lisp/vc-hooks.el31
-rw-r--r--lisp/vc-mcvs.el2
-rw-r--r--lisp/vc-rcs.el28
-rw-r--r--lisp/vc-svn.el2
-rw-r--r--lisp/vc.el59
10 files changed, 101 insertions, 80 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 1661bfa789c..4d83c8050f2 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,23 @@
2008-04-29 Stefan Monnier <monnier@iro.umontreal.ca>
+ Make `checkout-model' apply to filesets.
+ * vc-hooks.el (vc-checkout-model): Rewrite.
+ (vc-before-save, vc-after-save): Adjust callers accordingly.
+ * vc.el (vc-editable-p, vc-next-action, vc-checkout, vc-update)
+ (vc-transfer-file): Adjust callers accordingly.
+ * vc-rcs.el (vc-rcs-checkout-model): Adjust arg.
+ (vc-rcs-state, vc-rcs-state-heuristic, vc-rcs-receive-file)
+ (vc-rcs-checkout, vc-rcs-fetch-master-state): Use vc-rcs-checkout-model
+ instead of vc-checkout-model.
+ * vc-mcvs.el (vc-mcvs-revert):
+ Use vc-mcvs-checkout-model i.s.o vc-checkout-model.
+ * vc-cvs.el (vc-cvs-checkout-model): Adjust arg.
+ (vc-cvs-revert): Use vc-cvs-checkout-model i.s.o vc-checkout-model.
+ * vc-svn.el (vc-svn-checkout-model):
+ * vc-hg.el (vc-hg-checkout-model):
+ * vc-git.el (vc-git-checkout-model):
+ * vc-bzr.el (vc-bzr-checkout-model): Adjust arg.
+
* dired.el (dired-read-dir-and-switches): Replace last change with
a new approach that mixes read-file-name and read-directory-name.
diff --git a/lisp/vc-bzr.el b/lisp/vc-bzr.el
index fcd1b9b1b5d..aca00409fac 100644
--- a/lisp/vc-bzr.el
+++ b/lisp/vc-bzr.el
@@ -346,8 +346,7 @@ If any error occurred in running `bzr status', then return nil."
((eq exitcode 0) (substring output 0 -1))
(t nil))))))
-(defun vc-bzr-checkout-model (file)
- 'implicit)
+(defun vc-bzr-checkout-model (files) 'implicit)
(defun vc-bzr-create-repo ()
"Create a new Bzr repository."
diff --git a/lisp/vc-cvs.el b/lisp/vc-cvs.el
index 67830b48fd5..eec813859d2 100644
--- a/lisp/vc-cvs.el
+++ b/lisp/vc-cvs.el
@@ -238,21 +238,25 @@ See also variable `vc-cvs-sticky-date-format-string'."
(vc-cvs-registered file)
(vc-file-getprop file 'vc-working-revision))
-(defun vc-cvs-checkout-model (file)
+(defun vc-cvs-checkout-model (files)
"CVS-specific version of `vc-checkout-model'."
(if (getenv "CVSREAD")
'announce
- (let ((attrib (file-attributes file)))
- (if (and attrib ;; don't check further if FILE doesn't exist
- ;; If the file is not writable (despite CVSREAD being
- ;; undefined), this is probably because the file is being
- ;; "watched" by other developers.
- ;; (If vc-mistrust-permissions was t, we actually shouldn't
- ;; trust this, but there is no other way to learn this from CVS
- ;; at the moment (version 1.9).)
- (string-match "r-..-..-." (nth 8 attrib)))
- 'announce
- 'implicit))))
+ (let* ((file (if (consp files) (car files) files))
+ (attrib (file-attributes file)))
+ (or (vc-file-getprop file 'vc-checkout-model)
+ (vc-file-setprop
+ file 'vc-checkout-model
+ (if (and attrib ;; don't check further if FILE doesn't exist
+ ;; If the file is not writable (despite CVSREAD being
+ ;; undefined), this is probably because the file is being
+ ;; "watched" by other developers.
+ ;; (If vc-mistrust-permissions was t, we actually shouldn't
+ ;; trust this, but there is no other way to learn this from
+ ;; CVS at the moment (version 1.9).)
+ (string-match "r-..-..-." (nth 8 attrib)))
+ 'announce
+ 'implicit))))))
(defun vc-cvs-mode-line-string (file)
"Return string for placement into the modeline for FILE.
@@ -356,7 +360,7 @@ its parents."
(vc-file-setprop
(car files) 'vc-working-revision
(vc-parse-buffer "^\\(new\\|initial\\) revision: \\([0-9.]+\\)" 2))
- (mapc (lambda (file) (vc-file-clearprops file)) files))
+ (mapc 'vc-file-clearprops files))
;; Anyway, forget the checkout model of the file, because we might have
;; guessed wrong when we found the file. After commit, we can
;; tell it from the permissions of the file (see
@@ -418,7 +422,7 @@ REV is the revision to check out."
(defun vc-cvs-revert (file &optional contents-done)
"Revert FILE to the working revision on which it was based."
(vc-default-revert 'CVS file contents-done)
- (unless (eq (vc-checkout-model file) 'implicit)
+ (unless (eq (vc-cvs-checkout-model file) 'implicit)
(if vc-cvs-use-edit
(vc-cvs-command nil 0 file "unedit")
;; Make the file read-only by switching off all w-bits
diff --git a/lisp/vc-git.el b/lisp/vc-git.el
index 19e5272618d..757263fa11e 100644
--- a/lisp/vc-git.el
+++ b/lisp/vc-git.el
@@ -193,8 +193,7 @@
(match-string 2 str)
str)))
-(defun vc-git-checkout-model (file)
- 'implicit)
+(defun vc-git-checkout-model (files) 'implicit)
(defun vc-git-workfile-unchanged-p (file)
(eq 'up-to-date (vc-git-state file)))
diff --git a/lisp/vc-hg.el b/lisp/vc-hg.el
index 7755e92dbc4..d6cd13d3bd0 100644
--- a/lisp/vc-hg.el
+++ b/lisp/vc-hg.el
@@ -444,8 +444,7 @@ REV is the revision to check out into WORKFILE."
(vc-hg-command t 0 file "cat" "-r" rev)
(vc-hg-command t 0 file "cat")))))
-(defun vc-hg-checkout-model (file)
- 'implicit)
+(defun vc-hg-checkout-model (files) 'implicit)
;; Modelled after the similar function in vc-bzr.el
(defun vc-hg-workfile-unchanged-p (file)
diff --git a/lisp/vc-hooks.el b/lisp/vc-hooks.el
index 7d2a4a946ac..e75f6ebce7b 100644
--- a/lisp/vc-hooks.el
+++ b/lisp/vc-hooks.el
@@ -440,26 +440,23 @@ If the file is not registered, or the master name is not known, return nil."
(vc-call-backend (vc-backend file) 'registered file))
(vc-file-getprop file 'vc-name))))
-(defun vc-checkout-model (file)
- "Indicate how FILE is checked out.
+(defun vc-checkout-model (backend files)
+ "Indicate how FILES are checked out.
-If FILE is not registered, this function always returns nil.
+If FILES are not registered, this function always returns nil.
For registered files, the possible values are:
- 'implicit FILE is always writeable, and checked out `implicitly'
+ 'implicit FILES are always writeable, and checked out `implicitly'
when the user saves the first changes to the file.
- 'locking FILE is read-only if up-to-date; user must type
+ 'locking FILES are read-only if up-to-date; user must type
\\[vc-next-action] before editing. Strict locking
is assumed.
- 'announce FILE is read-only if up-to-date; user must type
+ 'announce FILES are read-only if up-to-date; user must type
\\[vc-next-action] before editing. But other users
may be editing at the same time."
- (or (vc-file-getprop file 'vc-checkout-model)
- (if (vc-backend file)
- (vc-file-setprop file 'vc-checkout-model
- (vc-call checkout-model file)))))
+ (vc-call-backend backend 'checkout-model files))
(defun vc-user-login-name (file)
"Return the name under which the user accesses the given FILE."
@@ -752,11 +749,12 @@ Before doing that, check if there are any old backups and get rid of them."
;; If the file on disk is still in sync with the repository,
;; and version backups should be made, copy the file to
;; another name. This enables local diffs and local reverting.
- (let ((file buffer-file-name))
+ (let ((file buffer-file-name)
+ backend)
(ignore-errors ;Be careful not to prevent saving the file.
- (and (vc-backend file)
+ (and (setq backend (vc-backend file))
(vc-up-to-date-p file)
- (eq (vc-checkout-model file) 'implicit)
+ (eq (vc-checkout-model backend file) 'implicit)
(vc-call make-version-backups-p file)
(vc-make-version-backup file)))))
@@ -767,8 +765,9 @@ Before doing that, check if there are any old backups and get rid of them."
;; If the file in the current buffer is under version control,
;; up-to-date, and locking is not used for the file, set
;; the state to 'edited and redisplay the mode line.
- (let ((file buffer-file-name))
- (and (vc-backend file)
+ (let* ((file buffer-file-name)
+ (backend (vc-backend file)))
+ (and backend
(or (and (equal (vc-file-getprop file 'vc-checkout-time)
(nth 5 (file-attributes file)))
;; File has been saved in the same second in which
@@ -777,7 +776,7 @@ Before doing that, check if there are any old backups and get rid of them."
(vc-file-setprop file 'vc-checkout-time nil))
t)
(vc-up-to-date-p file)
- (eq (vc-checkout-model file) 'implicit)
+ (eq (vc-checkout-model backend file) 'implicit)
(vc-file-setprop file 'vc-state 'edited)
(vc-mode-line file)
(when (featurep 'vc)
diff --git a/lisp/vc-mcvs.el b/lisp/vc-mcvs.el
index 6be69e47bd8..df8a4ebad0b 100644
--- a/lisp/vc-mcvs.el
+++ b/lisp/vc-mcvs.el
@@ -367,7 +367,7 @@ This is only possible if Meta-CVS is responsible for FILE's directory.")
(defun vc-mcvs-revert (file &optional contents-done)
"Revert FILE to the working revision it was based on."
(vc-default-revert 'MCVS file contents-done)
- (unless (eq (vc-checkout-model file) 'implicit)
+ (unless (eq (vc-mcvs-checkout-model file) 'implicit)
(if vc-mcvs-use-edit
(vc-mcvs-command nil 0 file "unedit")
;; Make the file read-only by switching off all w-bits
diff --git a/lisp/vc-rcs.el b/lisp/vc-rcs.el
index ac882762b62..a1b10aaa541 100644
--- a/lisp/vc-rcs.el
+++ b/lisp/vc-rcs.el
@@ -109,13 +109,12 @@ For a description of possible values, see `vc-check-master-templates'."
;;; State-querying functions
;;;
-;;; The autoload cookie below places vc-rcs-registered directly into
-;;; loaddefs.el, so that vc-rcs.el does not need to be loaded for
-;;; every file that is visited. The definition is repeated below
-;;; so that Help and etags can find it.
-
-;;;###autoload (defun vc-rcs-registered (f) (vc-default-registered 'RCS f))
-(defun vc-rcs-registered (f) (vc-default-registered 'RCS f))
+;; The autoload cookie below places vc-rcs-registered directly into
+;; loaddefs.el, so that vc-rcs.el does not need to be loaded for
+;; every file that is visited.
+;;;###autoload
+(progn
+(defun vc-rcs-registered (f) (vc-default-registered 'RCS f)))
(defun vc-rcs-state (file)
"Implementation of `vc-state' for RCS."
@@ -133,7 +132,7 @@ For a description of possible values, see `vc-check-master-templates'."
state
(if (vc-workfile-unchanged-p file)
'up-to-date
- (if (eq (vc-checkout-model file) 'locking)
+ (if (eq (vc-rcs-checkout-model file) 'locking)
'unlocked-changes
'edited)))))
@@ -168,7 +167,7 @@ For a description of possible values, see `vc-check-master-templates'."
(vc-file-setprop file 'vc-checkout-model 'locking)
'up-to-date)
((string-match ".rw..-..-." permissions)
- (if (eq (vc-checkout-model file) 'locking)
+ (if (eq (vc-rcs-checkout-model file) 'locking)
(if (file-ownership-preserved-p file)
'edited
owner-name)
@@ -218,9 +217,10 @@ When VERSION is given, perform check for that version."
(vc-insert-file (vc-name file) "^desc")
(vc-rcs-find-most-recent-rev (vc-branch-part version))))))
-(defun vc-rcs-checkout-model (file)
+(defun vc-rcs-checkout-model (files)
"RCS-specific version of `vc-checkout-model'."
- (let (result)
+ (let ((file (if (consp files) (car files) files))
+ result)
(when vc-consult-headers
(vc-file-setprop file 'vc-checkout-model nil)
(vc-rcs-consult-headers file)
@@ -319,7 +319,7 @@ expanded if `vc-keep-workfiles' is non-nil, otherwise, delete the workfile."
(defun vc-rcs-receive-file (file rev)
"Implementation of receive-file for RCS."
- (let ((checkout-model (vc-checkout-model file)))
+ (let ((checkout-model (vc-rcs-checkout-model file)))
(vc-rcs-register file rev "")
(when (eq checkout-model 'implicit)
(vc-rcs-set-non-strict-locking file))
@@ -430,7 +430,7 @@ whether to remove it."
nil 0 "co" (vc-name file)
;; If locking is not strict, force to overwrite
;; the writable workfile.
- (if (eq (vc-checkout-model file) 'implicit) "-f")
+ (if (eq (vc-rcs-checkout-model file) 'implicit) "-f")
(if editable "-l")
(if (stringp rev)
;; a literal revision was specified
@@ -893,7 +893,7 @@ file."
;; locked by the calling user
((and (stringp locking-user)
(string= locking-user (vc-user-login-name file)))
- (if (or (eq (vc-checkout-model file) 'locking)
+ (if (or (eq (vc-rcs-checkout-model file) 'locking)
workfile-is-latest
(vc-rcs-latest-on-branch-p file working-revision))
'edited
diff --git a/lisp/vc-svn.el b/lisp/vc-svn.el
index 5aa1cf7f143..51b49b84589 100644
--- a/lisp/vc-svn.el
+++ b/lisp/vc-svn.el
@@ -193,7 +193,7 @@ RESULT is a list of conses (FILE . STATE) for directory DIR."
(vc-svn-registered file)
(vc-file-getprop file 'vc-working-revision))
-(defun vc-svn-checkout-model (file)
+(defun vc-svn-checkout-model (files)
"SVN-specific version of `vc-checkout-model'."
;; It looks like Subversion has no equivalent of CVSREAD.
'implicit)
diff --git a/lisp/vc.el b/lisp/vc.el
index 81762b69093..4d71b614665 100644
--- a/lisp/vc.el
+++ b/lisp/vc.el
@@ -228,9 +228,9 @@
;; The default implementation always returns t, which means that
;; working with non-current revisions is not supported by default.
;;
-;; * checkout-model (file)
+;; * checkout-model (files)
;;
-;; Indicate whether FILE needs to be "checked out" before it can be
+;; Indicate whether FILES need to be "checked out" before they can be
;; edited. See `vc-checkout-model' for a list of possible values.
;;
;; - workfile-unchanged-p (file)
@@ -1506,13 +1506,16 @@ Otherwise, throw an error."
(unless (vc-backend buffer-file-name)
(error "File %s is not under version control" buffer-file-name))))))
-;;; Support for the C-x v v command. This is where all the single-file-oriented
-;;; code from before the fileset rewrite lives.
+;;; Support for the C-x v v command.
+;; This is where all the single-file-oriented code from before the fileset
+;; rewrite lives.
(defsubst vc-editable-p (file)
"Return non-nil if FILE can be edited."
- (or (eq (vc-checkout-model file) 'implicit)
- (memq (vc-state file) '(edited needs-merge conflict))))
+ (let ((backend (vc-backend file)))
+ (and backend
+ (or (eq (vc-checkout-model backend file) 'implicit)
+ (memq (vc-state file) '(edited needs-merge conflict))))))
(defun vc-revert-buffer-internal (&optional arg no-confirm)
"Revert buffer, keeping point and mark where user expects them.
@@ -1585,9 +1588,10 @@ with the logmessage as change commentary. A writable file is retained.
merge in the changes into your working copy."
(interactive "P")
(let* ((vc-fileset (vc-deduce-fileset nil t))
+ (backend (car vc-fileset))
(files (cdr vc-fileset))
state
- model
+ (model (vc-checkout-model backend files))
revision)
;; Check if there's at least one file present, and get `state' and
;; `model' from it.
@@ -1595,7 +1599,6 @@ merge in the changes into your working copy."
;; present, or `files' is nil.
(dolist (file files)
(unless (file-directory-p file)
- (setq model (vc-checkout-model (car files)))
(setq state (vc-state file))
(return)))
@@ -1605,7 +1608,7 @@ merge in the changes into your working copy."
(unless (file-directory-p file)
(unless (vc-compatible-state (vc-state file) state)
(error "Fileset is in a mixed-up state"))
- (unless (eq (vc-checkout-model file) model)
+ (unless (eq (vc-checkout-model backend file) model)
(error "Fileset has mixed checkout models"))))
;; Check for buffers in the fileset not matching the on-disk contents.
(dolist (file files)
@@ -1932,23 +1935,23 @@ After check-out, runs the normal hook `vc-checkout-hook'."
(vc-call make-version-backups-p file)
(vc-up-to-date-p file)
(vc-make-version-backup file))
- (with-vc-properties
- (list file)
- (condition-case err
- (vc-call checkout file writable rev)
- (file-error
- ;; Maybe the backend is not installed ;-(
- (when writable
- (let ((buf (get-file-buffer file)))
- (when buf (with-current-buffer buf (toggle-read-only -1)))))
- (signal (car err) (cdr err))))
- `((vc-state . ,(if (or (eq (vc-checkout-model file) 'implicit)
- (not writable))
- (if (vc-call latest-on-branch-p file)
- 'up-to-date
- 'needs-patch)
- 'edited))
- (vc-checkout-time . ,(nth 5 (file-attributes file)))))
+ (let ((backend (vc-backend file)))
+ (with-vc-properties (list file)
+ (condition-case err
+ (vc-call-backend 'checkout file writable rev)
+ (file-error
+ ;; Maybe the backend is not installed ;-(
+ (when writable
+ (let ((buf (get-file-buffer file)))
+ (when buf (with-current-buffer buf (toggle-read-only -1)))))
+ (signal (car err) (cdr err))))
+ `((vc-state . ,(if (or (eq (vc-checkout-model backend file) 'implicit)
+ (not writable))
+ (if (vc-call latest-on-branch-p file)
+ 'up-to-date
+ 'needs-patch)
+ 'edited))
+ (vc-checkout-time . ,(nth 5 (file-attributes file))))))
(vc-resynch-buffer file t t)
(run-hooks 'vc-checkout-hook))
@@ -3769,7 +3772,7 @@ changes from the current branch are merged into the working file."
(error "Please kill or save all modified buffers before updating."))
(if (vc-up-to-date-p file)
(vc-checkout file nil t)
- (if (eq (vc-checkout-model file) 'locking)
+ (if (eq (vc-checkout-model backend file) 'locking)
(if (eq (vc-state file) 'edited)
(error "%s"
(substitute-command-keys
@@ -3896,7 +3899,7 @@ backend to NEW-BACKEND, and unregister FILE from the current backend.
(vc-call-backend new-backend 'receive-file file rev))
(when modified-file
(vc-switch-backend file new-backend)
- (unless (eq (vc-checkout-model file) 'implicit)
+ (unless (eq (vc-checkout-model new-backend file) 'implicit)
(vc-checkout file t nil))
(rename-file modified-file file 'ok-if-already-exists)
(vc-file-setprop file 'vc-checkout-time nil)))))