]> code.delx.au - gnu-emacs/blobdiff - lisp/vc/vc-sccs.el
Resurrect the ability to specify a revision in vc-next-action
[gnu-emacs] / lisp / vc / vc-sccs.el
index 8a9e0b112894a40a18a5bde62693050de6e2a3b9..a3facc56d5dd24c9908f509ecf013a08a0fcc0b8 100644 (file)
@@ -1,6 +1,6 @@
 ;;; vc-sccs.el --- support for SCCS version-control  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1992-2014 Free Software Foundation, Inc.
+;; Copyright (C) 1992-2015 Free Software Foundation, Inc.
 
 ;; Author:     FSF (see vc.el for full credits)
 ;; Maintainer: Andre Spiegel <spiegel@gnu.org>
@@ -134,16 +134,10 @@ For a description of possible values, see `vc-check-master-templates'."
 
 (autoload 'vc-expand-dirs "vc")
 
-(defun vc-sccs-dir-status (dir update-function)
-  ;; FIXME: this function should be rewritten, using `vc-expand-dirs'
-  ;; is not TRTD because it returns files from multiple backends.
-  ;; It should also return 'unregistered files.
-
-  ;; Doing lots of individual VC-state calls is painful, but
-  ;; there is no better option in SCCS-land.
-  (let ((flist (vc-expand-dirs (list dir)))
-       (result nil))
-    (dolist (file flist)
+(defun vc-sccs-dir-status-files (dir files update-function)
+  (if (not files) (setq files (vc-expand-dirs (list dir) 'RCS)))
+  (let ((result nil))
+    (dolist (file files)
       (let ((state (vc-state file))
            (frel (file-relative-name file)))
        (when (and (eq (vc-backend file) 'SCCS)
@@ -155,13 +149,14 @@ For a description of possible values, see `vc-check-master-templates'."
 
 (defun vc-sccs-working-revision (file)
   "SCCS-specific version of `vc-working-revision'."
-  (with-temp-buffer
-    ;; The working revision is always the latest revision number.
-    ;; To find this number, search the entire delta table,
-    ;; rather than just the first entry, because the
-    ;; first entry might be a deleted ("R") revision.
-    (vc-insert-file (vc-master-name file) "^\001e\n\001[^s]")
-    (vc-parse-buffer "^\001d D \\([^ ]+\\)" 1)))
+  (when (and (file-regular-p file) (vc-master-name file))
+    (with-temp-buffer
+      ;; The working revision is always the latest revision number.
+      ;; To find this number, search the entire delta table,
+      ;; rather than just the first entry, because the
+      ;; first entry might be a deleted ("R") revision.
+      (vc-insert-file (vc-master-name file) "^\001e\n\001[^s]")
+      (vc-parse-buffer "^\001d D \\([^ ]+\\)" 1))))
 
 ;; Cf vc-sccs-find-revision.
 (defun vc-sccs-write-revision (file outfile &optional rev)
@@ -201,12 +196,10 @@ Optional string REV is a revision."
 
 (defun vc-sccs-register (files &optional comment)
   "Register FILES into the SCCS version-control system.
+Automatically retrieve a read-only version of the files with keywords expanded.
 COMMENT can be used to provide an initial description of FILES.
 Passes either `vc-sccs-register-switches' or `vc-register-switches'
-to the SCCS command.
-
-Automatically retrieve a read-only version of the files with keywords
-expanded if `vc-keep-workfiles' is non-nil, otherwise, delete the workfile."
+to the SCCS command."
   (dolist (file files)
     (let* ((dirname (or (file-name-directory file) ""))
           (basename (file-name-nondirectory file))
@@ -220,8 +213,7 @@ expanded if `vc-keep-workfiles' is non-nil, otherwise, delete the workfile."
               (and comment (concat "-y" comment))
               (vc-switches 'SCCS 'register)))
       (delete-file file)
-      (if vc-keep-workfiles
-         (vc-sccs-do-command nil 0 "get" (vc-master-name file))))))
+      (vc-sccs-do-command nil 0 "get" (vc-master-name file)))))
 
 (defun vc-sccs-responsible-p (file)
   "Return non-nil if SCCS thinks it would be responsible for registering FILE."
@@ -230,14 +222,14 @@ expanded if `vc-keep-workfiles' is non-nil, otherwise, delete the workfile."
       (stringp (vc-sccs-search-project-dir (or (file-name-directory file) "")
                                           (file-name-nondirectory file)))))
 
-(defun vc-sccs-checkin (files comment)
+(defun vc-sccs-checkin (files comment &optional rev)
   "SCCS-specific version of `vc-backend-checkin'."
-  (dolist (file (vc-expand-dirs files))
+  (dolist (file (vc-expand-dirs files 'SCCS))
     (apply 'vc-sccs-do-command nil 0 "delta" (vc-master-name file)
+           (if rev (concat "-r" rev))
           (concat "-y" comment)
           (vc-switches 'SCCS 'checkin))
-    (if vc-keep-workfiles
-       (vc-sccs-do-command nil 0 "get" (vc-master-name file)))))
+       (vc-sccs-do-command nil 0 "get" (vc-master-name file))))
 
 (defun vc-sccs-find-revision (file rev buffer)
   (apply 'vc-sccs-do-command
@@ -255,7 +247,7 @@ If FILE is a directory, all version-controlled files beneath are checked out.
 EDITABLE non-nil means that the file should be writable and
 locked.  REV is the revision to check out."
   (if (file-directory-p file)
-      (mapc 'vc-sccs-checkout (vc-expand-dirs (list file)))
+      (mapc 'vc-sccs-checkout (vc-expand-dirs (list file) 'SCCS))
     (let ((file-buffer (get-file-buffer file))
          switches)
       (message "Checking out %s..." file)
@@ -281,27 +273,11 @@ locked.  REV is the revision to check out."
                   switches))))
       (message "Checking out %s...done" file))))
 
-(defun vc-sccs-rollback (files)
-  "Roll back, undoing the most recent checkins of FILES.  Directories
-are expanded to all version-controlled subfiles."
-  (setq files (vc-expand-dirs files))
-  (if (not files)
-      (error "SCCS backend doesn't support directory-level rollback"))
-  (dolist (file files)
-         (let ((discard (vc-working-revision file)))
-           (if (null (yes-or-no-p (format "Remove version %s from %s history? "
-                                          discard file)))
-               (error "Aborted"))
-           (message "Removing revision %s from %s..." discard file)
-           (vc-sccs-do-command nil 0 "rmdel"
-                                (vc-master-name file) (concat "-r" discard))
-           (vc-sccs-do-command nil 0 "get" (vc-master-name file) nil))))
-
 (defun vc-sccs-revert (file &optional _contents-done)
   "Revert FILE to the version it was based on. If FILE is a directory,
 revert all subfiles."
   (if (file-directory-p file)
-      (mapc 'vc-sccs-revert (vc-expand-dirs (list file)))
+      (mapc 'vc-sccs-revert (vc-expand-dirs (list file) 'SCCS))
     (vc-sccs-do-command nil 0 "unget" (vc-master-name file))
     (vc-sccs-do-command nil 0 "get" (vc-master-name file))
     ;; Checking out explicit revisions is not supported under SCCS, yet.
@@ -312,7 +288,7 @@ revert all subfiles."
 (defun vc-sccs-steal-lock (file &optional rev)
   "Steal the lock on the current workfile for FILE and revision REV."
   (if (file-directory-p file)
-      (mapc 'vc-sccs-steal-lock (vc-expand-dirs (list file)))
+      (mapc 'vc-sccs-steal-lock (vc-expand-dirs (list file) 'SCCS))
     (vc-sccs-do-command nil 0 "unget"
                        (vc-master-name file) "-n" (if rev (concat "-r" rev)))
     (vc-sccs-do-command nil 0 "get"
@@ -320,7 +296,7 @@ revert all subfiles."
 
 (defun vc-sccs-modify-change-comment (files rev comment)
   "Modify (actually, append to) the change comments for FILES on a specified REV."
-  (dolist (file (vc-expand-dirs files))
+  (dolist (file (vc-expand-dirs files 'SCCS))
     (vc-sccs-do-command nil 0 "cdc" (vc-master-name file)
                         (concat "-y" comment) (concat "-r" rev))))
 
@@ -332,7 +308,7 @@ revert all subfiles."
 (defun vc-sccs-print-log (files buffer &optional _shortlog _start-revision-ignored limit)
   "Print commit log associated with FILES into specified BUFFER.
 Remaining arguments are ignored."
-  (setq files (vc-expand-dirs files))
+  (setq files (vc-expand-dirs files 'SCCS))
   (vc-sccs-do-command buffer 0 "prs" (mapcar 'vc-master-name files))
   (when limit 'limit-unsupported))
 
@@ -342,9 +318,9 @@ Remaining arguments are ignored."
 (defvar w32-quote-process-args)
 
 ;; FIXME use sccsdiff if present?
-(defun vc-sccs-diff (files &optional _async oldvers newvers buffer)
+(defun vc-sccs-diff (files &optional oldvers newvers buffer _async)
   "Get a difference report using SCCS between two filesets."
-  (setq files (vc-expand-dirs files))
+  (setq files (vc-expand-dirs files 'SCCS))
   (setq oldvers (vc-sccs-lookup-triple (car files) oldvers))
   (setq newvers (vc-sccs-lookup-triple (car files) newvers))
   (or buffer (setq buffer "*vc-diff*"))