* align.el:
[bpt/emacs.git] / lisp / vc-mcvs.el
index 73fe745..fcfda05 100644 (file)
@@ -3,14 +3,14 @@
 ;; Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Author:      FSF (see vc.el for full credits)
-;; Maintainer:  Stefan Monnier <monnier@gnu.org>
+;; Maintainer:  None
 
 ;; This file is part of GNU Emacs.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,9 +18,7 @@
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
@@ -50,7 +48,7 @@
 
 ;;; Bugs:
 
-;; - Retrieving snapshots doesn't filter `cvs update' output and thus
+;; - Retrieving tags doesn't filter `cvs update' output and thus
 ;;   parses bogus filenames.  Don't know if it harms.
 
 ;;; Code:
@@ -63,7 +61,7 @@
 ;;;
 
 (defcustom vc-mcvs-global-switches nil
-  "*Global switches to pass to any Meta-CVS command."
+  "Global switches to pass to any Meta-CVS command."
   :type '(choice (const :tag "None" nil)
                 (string :tag "Argument String")
                 (repeat :tag "Argument List"
@@ -73,7 +71,7 @@
   :group 'vc)
 
 (defcustom vc-mcvs-register-switches nil
-  "*Extra switches for registering a file into Meta-CVS.
+  "Extra switches for registering a file into Meta-CVS.
 A string or list of strings passed to the checkin program by
 \\[vc-register]."
   :type '(choice (const :tag "None" nil)
@@ -85,7 +83,7 @@ A string or list of strings passed to the checkin program by
   :group 'vc)
 
 (defcustom vc-mcvs-diff-switches nil
-  "*A string or list of strings specifying extra switches for cvs diff under VC."
+  "A string or list of strings specifying extra switches for cvs diff under VC."
     :type '(choice (const :tag "None" nil)
                 (string :tag "Argument String")
                 (repeat :tag "Argument List"
@@ -96,13 +94,13 @@ A string or list of strings passed to the checkin program by
 
 (defcustom vc-mcvs-header (or (cdr (assoc 'MCVS vc-header-alist))
                              vc-cvs-header)
-  "*Header keywords to be inserted by `vc-insert-headers'."
+  "Header keywords to be inserted by `vc-insert-headers'."
   :version "22.1"
   :type '(repeat string)
   :group 'vc)
 
 (defcustom vc-mcvs-use-edit vc-cvs-use-edit
-  "*Non-nil means to use `cvs edit' to \"check out\" a file.
+  "Non-nil means to use `cvs edit' to \"check out\" a file.
 This is only meaningful if you don't use the implicit checkout model
 \(i.e. if you have $CVSREAD set)."
   :type 'boolean
@@ -111,8 +109,8 @@ This is only meaningful if you don't use the implicit checkout model
 
 ;;; Properties of the backend
 
-(defun vc-mcvs-revision-granularity ()
-     'file)
+(defalias 'vc-mcvs-revision-granularity 'vc-cvs-revision-granularity)
+(defalias 'vc-mcvs-checkout-model 'vc-cvs-checkout-model)
 
 ;;;
 ;;; State-querying functions
@@ -177,33 +175,11 @@ This is only meaningful if you don't use the implicit checkout model
 
 (defalias 'vc-mcvs-state-heuristic 'vc-cvs-state-heuristic)
 
-(defun vc-mcvs-dir-state (dir)
-  "Find the Meta-CVS state of all files in DIR and subdirectories."
-  ;; if DIR is not under Meta-CVS control, don't do anything.
-  (when (file-readable-p (expand-file-name "MCVS/CVS/Entries" dir))
-    (if (vc-stay-local-p dir)
-       (vc-mcvs-dir-state-heuristic dir)
-      (let ((default-directory dir))
-       ;; Don't specify DIR in this command, the default-directory is
-       ;; enough.  Otherwise it might fail with remote repositories.
-       (with-temp-buffer
-         (buffer-disable-undo)         ;; Because these buffers can get huge
-         (setq default-directory (vc-mcvs-root dir))
-         (vc-mcvs-command t 0 nil "status")
-         (goto-char (point-min))
-         (while (re-search-forward "^=+\n\\([^=\n].*\n\\|\n\\)+" nil t)
-           (narrow-to-region (match-beginning 0) (match-end 0))
-           (vc-cvs-parse-status)
-           (goto-char (point-max))
-           (widen)))))))
-
 (defun vc-mcvs-working-revision (file)
   (vc-cvs-working-revision
    (expand-file-name (vc-file-getprop file 'mcvs-inode)
                     (vc-file-getprop file 'mcvs-root))))
 
-(defalias 'vc-mcvs-checkout-model 'vc-cvs-checkout-model)
-
 ;;;
 ;;; State-changing functions
 ;;;
@@ -216,7 +192,7 @@ COMMENT can be used to provide an initial description of FILE.
 the Meta-CVS command (in that order)."
   ;; FIXME: multiple-file case should be made to work
   (if (> (length files) 1) (error "Registering filesets is not yet supported."))
-  (let* ((file (car files)) 
+  (let* ((file (car files))
         (filename (file-name-nondirectory file))
         (extpos (string-match "\\." filename))
         (ext (if extpos (substring filename (1+ extpos))))
@@ -245,19 +221,19 @@ the Meta-CVS command (in that order)."
          (pp types (current-buffer))
          (save-buffer)
          (unless (get-buffer-window (current-buffer) t)
-           (kill-buffer (current-buffer)))))))
-  ;; Now do the ADD.
-  (prog1 (apply 'vc-mcvs-command nil 0 file
-               "add"
-               (and comment (string-match "[^\t\n ]" comment)
-                    (concat "-m" comment))
-               (vc-switches 'MCVS 'register))
-    ;; I'm not sure exactly why, but if we don't setup the inode and root
-    ;; prop of the file, things break later on in vc-mode-line that
-    ;; ends up calling vc-mcvs-working-revision.
-    ;; We also need to set vc-checkout-time so that vc-workfile-unchanged-p
-    ;; doesn't try to call `mcvs diff' on the file.
-    (vc-mcvs-registered file)))
+           (kill-buffer (current-buffer))))))
+    ;; Now do the ADD.
+    (prog1 (apply 'vc-mcvs-command nil 0 file
+                  "add"
+                  (and comment (string-match "[^\t\n ]" comment)
+                       (concat "-m" comment))
+                  (vc-switches 'MCVS 'register))
+      ;; I'm not sure exactly why, but if we don't setup the inode and root
+      ;; prop of the file, things break later on in vc-mode-line that
+      ;; ends up calling vc-mcvs-working-revision.
+      ;; We also need to set vc-checkout-time so that vc-workfile-unchanged-p
+      ;; doesn't try to call `mcvs diff' on the file.
+      (vc-mcvs-registered file))))
 
 (defalias 'vc-mcvs-responsible-p 'vc-mcvs-root
   "Return non-nil if CVS thinks it is responsible for FILE.")
@@ -336,7 +312,7 @@ This is only possible if Meta-CVS is responsible for FILE's directory.")
 (defun vc-mcvs-checkout (file &optional editable rev)
   (message "Checking out %s..." file)
   (with-current-buffer (or (get-file-buffer file) (current-buffer))
-    (vc-call update file editable rev (vc-switches 'MCVS 'checkout)))
+    (vc-mcvs-update file editable rev (vc-switches 'MCVS 'checkout)))
   (vc-mode-line file)
   (message "Checking out %s...done" file))
 
@@ -344,7 +320,7 @@ This is only possible if Meta-CVS is responsible for FILE's directory.")
   (if (and (file-exists-p file) (not rev))
       ;; If no revision was specified, just make the file writable
       ;; if necessary (using `cvs-edit' if requested).
-      (and editable (not (eq (vc-mcvs-checkout-model file) 'implicit))
+      (and editable (not (eq (vc-mcvs-checkout-model (list file)) 'implicit))
           (if vc-mcvs-use-edit
               (vc-mcvs-command nil 0 file "edit")
             (set-file-modes file (logior (file-modes file) 128))
@@ -367,7 +343,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 (list 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
@@ -434,7 +410,7 @@ The changes are between FIRST-REVISION and SECOND-REVISION."
       (message "Merging changes into %s...done" file))))
 
 (defun vc-mcvs-modify-change-comment (files rev comment)
-  "Modify the change comments for FILES on a specified REV. 
+  "Modify the change comments for FILES on a specified REV.
 Will fail unless you have administrative privileges on the repo."
   (vc-mcvs-command nil 0 files "rcs" (concat "-m" comment ":" rev)))
 
@@ -485,10 +461,10 @@ Optional arg REVISION is a revision to annotate from."
 (defalias 'vc-mcvs-annotate-time 'vc-cvs-annotate-time)
 
 ;;;
-;;; Snapshot system
+;;; Tag system
 ;;;
 
-(defun vc-mcvs-create-snapshot (dir name branchp)
+(defun vc-mcvs-create-tag (dir name branchp)
   "Assign to DIR's current revision a given NAME.
 If BRANCHP is non-nil, the name is created as a branch (and the current
 workspace is immediately moved to that new branch)."
@@ -497,9 +473,9 @@ workspace is immediately moved to that new branch)."
     (vc-mcvs-command nil 0 dir "branch" name)
     (vc-mcvs-command nil 0 dir "switch" name)))
 
-(defun vc-mcvs-retrieve-snapshot (dir name update)
-  "Retrieve a snapshot at and below DIR.
-NAME is the name of the snapshot; if it is empty, do a `cvs update'.
+(defun vc-mcvs-retrieve-tag (dir name update)
+  "Retrieve a tag at and below DIR.
+NAME is the name of the tag; if it is empty, do a `cvs update'.
 If UPDATE is non-nil, then update (resynch) any affected buffers."
   (with-current-buffer (get-buffer-create "*vc*")
     (let ((default-directory dir)
@@ -557,13 +533,13 @@ and that it passes `vc-mcvs-global-switches' to it before FLAGS."
                        (append vc-mcvs-global-switches flags)))))
     (if (not (member (car flags) '("diff" "log" "status")))
        ;; No need to filter: do it the easy way.
-       (apply 'vc-do-command buffer okstatus "mcvs" file args)
+       (apply 'vc-do-command (or buffer "*vc*") okstatus "mcvs" file args)
       ;; We need to filter the output.
       ;; The output of the filter uses filenames relative to the root,
       ;; so we need to change the default-directory.
       ;; (assert (equal default-directory (vc-mcvs-root file)))
       (vc-do-command
-       buffer okstatus "sh" nil "-c"
+       (or buffer "*vc*") okstatus "sh" nil "-c"
        (concat "mcvs "
               (mapconcat
                'shell-quote-argument