]> git.eshelyaron.com Git - emacs.git/commitdiff
Make `checkout-model' apply to filesets.
authorStefan Monnier <monnier@iro.umontreal.ca>
Tue, 29 Apr 2008 15:32:56 +0000 (15:32 +0000)
committerStefan Monnier <monnier@iro.umontreal.ca>
Tue, 29 Apr 2008 15:32:56 +0000 (15:32 +0000)
* 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.

lisp/ChangeLog
lisp/vc-bzr.el
lisp/vc-cvs.el
lisp/vc-git.el
lisp/vc-hg.el
lisp/vc-hooks.el
lisp/vc-mcvs.el
lisp/vc-rcs.el
lisp/vc-svn.el
lisp/vc.el

index 1661bfa789c45295226ed2b99997edf231e2d7b6..4d83c8050f279f5d9a22e53421ab860ba7fd03d4 100644 (file)
@@ -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.
 
index fcd1b9b1b5dba7b530ccd00b7adedc37e981edb0..aca00409fac6c611b1f15dd529ed4444eb2fbdf1 100644 (file)
@@ -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."
index 67830b48fd5feb74116ca99ce8548fb572757f63..eec813859d24ef46f448bb5c91ff183030e059cd 100644 (file)
@@ -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
index 19e5272618de45dc96aef11abe95efb91505bb88..757263fa11e277fcceba5e97541ef50dbab78b1f 100644 (file)
         (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)))
index 7755e92dbc46f7321f37054c563722fe4e264ca7..d6cd13d3bd0ab1cd408aa5f5b1edb2243036acb5 100644 (file)
@@ -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)
index 7d2a4a946ac44d0937d87652dcb26317c8b1fa1c..e75f6ebce7b1e00046f5dc91804dad7995090efa 100644 (file)
@@ -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)
index 6be69e47bd87d2b83ade34bf6ab66c3c5e963120..df8a4ebad0b805da60c7dd38254d1e79620ad09c 100644 (file)
@@ -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
index ac882762b62da3588fff68ec9e7235ab849ac253..a1b10aaa54115868e98723f39105ce19b42794bc 100644 (file)
@@ -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
index 5aa1cf7f143659d797b8dafe72350563868d9f5c..51b49b845891a213e3f84f3deace2dd5ea15b9a7 100644 (file)
@@ -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)
index 81762b69093b7af103f3d52597685abcabd10b16..4d71b6146651e6c5c4aede0552a24be1069ad0ff 100644 (file)
 ;;   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)))))