diff options
| author | Glenn Morris | 2012-06-05 20:29:10 -0400 |
|---|---|---|
| committer | Glenn Morris | 2012-06-05 20:29:10 -0400 |
| commit | 7a58f64d95ae1bc62c36c379f3ff22a3a6594c31 (patch) | |
| tree | dd00867952202ec54643950a0421cc6c2f922cd4 | |
| parent | 903a72b37a76b69b4642ceef493f52c78d2b3a38 (diff) | |
| download | emacs-7a58f64d95ae1bc62c36c379f3ff22a3a6594c31.tar.gz emacs-7a58f64d95ae1bc62c36c379f3ff22a3a6594c31.zip | |
Replace the last use of the external vcdiff script
* lisp/vc/vc-sccs.el (vc-sccs-write-revision): New function.
(vc-sccs-workfile-unchanged-p): Use vc-sccs-write-revision.
(vc-sccs-diff): Replace use of the external vcdiff script.
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/vc/vc-sccs.el | 107 |
2 files changed, 88 insertions, 25 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 281b857ba8b..075e0231c27 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2012-06-06 Glenn Morris <rgm@gnu.org> | ||
| 2 | |||
| 3 | * vc/vc-sccs.el (vc-sccs-write-revision): New function. | ||
| 4 | (vc-sccs-workfile-unchanged-p): Use vc-sccs-write-revision. | ||
| 5 | (vc-sccs-diff): Replace use of the external vcdiff script. | ||
| 6 | |||
| 1 | 2012-06-05 Glenn Morris <rgm@gnu.org> | 7 | 2012-06-05 Glenn Morris <rgm@gnu.org> |
| 2 | 8 | ||
| 3 | * ledit.el: Move to obsolete/. | 9 | * ledit.el: Move to obsolete/. |
diff --git a/lisp/vc/vc-sccs.el b/lisp/vc/vc-sccs.el index 0cc92bb9db1..a34222f7236 100644 --- a/lisp/vc/vc-sccs.el +++ b/lisp/vc/vc-sccs.el | |||
| @@ -23,10 +23,6 @@ | |||
| 23 | 23 | ||
| 24 | ;;; Commentary: | 24 | ;;; Commentary: |
| 25 | 25 | ||
| 26 | ;; Proper function of the SCCS diff commands requires the shellscript vcdiff | ||
| 27 | ;; to be installed somewhere on Emacs's path for executables. | ||
| 28 | ;; | ||
| 29 | |||
| 30 | ;;; Code: | 26 | ;;; Code: |
| 31 | 27 | ||
| 32 | (eval-when-compile | 28 | (eval-when-compile |
| @@ -37,15 +33,13 @@ | |||
| 37 | ;;; | 33 | ;;; |
| 38 | 34 | ||
| 39 | ;; ;; Maybe a better solution is to not use "get" but "sccs get". | 35 | ;; ;; Maybe a better solution is to not use "get" but "sccs get". |
| 40 | ;; (defcustom vc-sccs-path | 36 | ;; ;; Note for GNU CSSC, you can parse sccs -V to get the libexec path. |
| 41 | ;; (let ((path ())) | 37 | ;; (defcustom vc-sccs-path |
| 42 | ;; (dolist (dir '("/usr/sccs" "/usr/lib/sccs" "/usr/libexec/sccs")) | 38 | ;; (prune-directory-list '("/usr/ccs/bin" "/usr/sccs" "/usr/lib/sccs" |
| 43 | ;; (if (file-directory-p dir) | 39 | ;; "/usr/libexec/sccs")) |
| 44 | ;; (push dir path))) | 40 | ;; "List of extra directories to search for SCCS commands." |
| 45 | ;; path) | 41 | ;; :type '(repeat directory) |
| 46 | ;; "List of extra directories to search for SCCS commands." | 42 | ;; :group 'vc) |
| 47 | ;; :type '(repeat directory) | ||
| 48 | ;; :group 'vc) | ||
| 49 | 43 | ||
| 50 | (defgroup vc-sccs nil | 44 | (defgroup vc-sccs nil |
| 51 | "VC SCCS backend." | 45 | "VC SCCS backend." |
| @@ -186,17 +180,22 @@ For a description of possible values, see `vc-check-master-templates'." | |||
| 186 | (vc-insert-file (vc-name file) "^\001e\n\001[^s]") | 180 | (vc-insert-file (vc-name file) "^\001e\n\001[^s]") |
| 187 | (vc-parse-buffer "^\001d D \\([^ ]+\\)" 1))) | 181 | (vc-parse-buffer "^\001d D \\([^ ]+\\)" 1))) |
| 188 | 182 | ||
| 183 | ;; Cf vc-sccs-find-revision. | ||
| 184 | (defun vc-sccs-write-revision (file outfile &optional rev) | ||
| 185 | "Write the SCCS version of input file FILE to output file OUTFILE. | ||
| 186 | Optional string REV is a revision." | ||
| 187 | (with-temp-buffer | ||
| 188 | (apply 'vc-sccs-do-command t 0 "get" (vc-name file) | ||
| 189 | (append '("-s" "-p" "-k") ; -k: no keyword expansion | ||
| 190 | (if rev (list (concat "-r" rev))))) | ||
| 191 | (write-region nil nil outfile nil 'silent))) | ||
| 192 | |||
| 189 | (defun vc-sccs-workfile-unchanged-p (file) | 193 | (defun vc-sccs-workfile-unchanged-p (file) |
| 190 | "SCCS-specific implementation of `vc-workfile-unchanged-p'." | 194 | "SCCS-specific implementation of `vc-workfile-unchanged-p'." |
| 191 | (let ((tempfile (make-temp-file "vc-sccs"))) | 195 | (let ((tempfile (make-temp-file "vc-sccs"))) |
| 192 | (unwind-protect | 196 | (unwind-protect |
| 193 | (progn | 197 | (progn |
| 194 | (with-temp-buffer | 198 | (vc-sccs-write-revision file tempfile (vc-working-revision file)) |
| 195 | ;; Cf vc-sccs-find-revision. | ||
| 196 | (vc-sccs-do-command t 0 "get" (vc-name file) | ||
| 197 | "-s" "-p" "-k" ; no keyword expansion | ||
| 198 | (concat "-r" (vc-working-revision file))) | ||
| 199 | (write-region nil nil tempfile nil 'silent)) | ||
| 200 | (zerop (vc-do-command "*vc*" 1 "cmp" file tempfile))) | 199 | (zerop (vc-do-command "*vc*" 1 "cmp" file tempfile))) |
| 201 | (delete-file tempfile)))) | 200 | (delete-file tempfile)))) |
| 202 | 201 | ||
| @@ -354,17 +353,75 @@ revert all subfiles." | |||
| 354 | (vc-sccs-do-command buffer 0 "prs" (mapcar 'vc-name files)) | 353 | (vc-sccs-do-command buffer 0 "prs" (mapcar 'vc-name files)) |
| 355 | (when limit 'limit-unsupported)) | 354 | (when limit 'limit-unsupported)) |
| 356 | 355 | ||
| 356 | ;; FIXME use sccsdiff if present? | ||
| 357 | (defun vc-sccs-diff (files &optional oldvers newvers buffer) | 357 | (defun vc-sccs-diff (files &optional oldvers newvers buffer) |
| 358 | "Get a difference report using SCCS between two filesets." | 358 | "Get a difference report using SCCS between two filesets." |
| 359 | (setq files (vc-expand-dirs files)) | 359 | (setq files (vc-expand-dirs files)) |
| 360 | (setq oldvers (vc-sccs-lookup-triple (car files) oldvers)) | 360 | (setq oldvers (vc-sccs-lookup-triple (car files) oldvers)) |
| 361 | (setq newvers (vc-sccs-lookup-triple (car files) newvers)) | 361 | (setq newvers (vc-sccs-lookup-triple (car files) newvers)) |
| 362 | (apply 'vc-do-command (or buffer "*vc-diff*") | 362 | (or buffer (setq buffer "*vc-diff*")) |
| 363 | 1 "vcdiff" (mapcar 'vc-name (vc-expand-dirs files)) | 363 | ;; We have to reimplement pieces of vc-do-command, because |
| 364 | (append (list "-q" | 364 | ;; we want to run multiple external commands, and only do the setup |
| 365 | (and oldvers (concat "-r" oldvers)) | 365 | ;; and exit pieces once. |
| 366 | (and newvers (concat "-r" newvers))) | 366 | (save-current-buffer |
| 367 | (vc-switches 'SCCS 'diff)))) | 367 | (unless (or (eq buffer t) |
| 368 | (and (stringp buffer) (string= (buffer-name) buffer)) | ||
| 369 | (eq buffer (current-buffer))) | ||
| 370 | (vc-setup-buffer buffer)) | ||
| 371 | (let* ((fake-flags (append (vc-switches 'SCCS 'diff) | ||
| 372 | (if oldvers (list (concat " -r" oldvers))) | ||
| 373 | (if newvers (list (concat " -r" newvers))))) | ||
| 374 | (fake-command | ||
| 375 | (format "diff%s %s" | ||
| 376 | (if fake-flags | ||
| 377 | (concat " " (mapconcat 'identity fake-flags " ")) | ||
| 378 | "") | ||
| 379 | (vc-delistify files))) | ||
| 380 | (status 0) | ||
| 381 | (oldproc (get-buffer-process (current-buffer)))) | ||
| 382 | (when vc-command-messages | ||
| 383 | (message "Running %s in foreground..." fake-command)) | ||
| 384 | (if oldproc (delete-process oldproc)) | ||
| 385 | (dolist (file files) | ||
| 386 | (let ((oldfile (make-temp-file "vc-sccs")) | ||
| 387 | newfile) | ||
| 388 | (unwind-protect | ||
| 389 | (progn | ||
| 390 | (vc-sccs-write-revision file oldfile oldvers) | ||
| 391 | (if newvers | ||
| 392 | (vc-sccs-write-revision file (setq newfile | ||
| 393 | (make-temp-file "vc-sccs")) | ||
| 394 | newvers)) | ||
| 395 | (let* ((inhibit-read-only t) | ||
| 396 | (buffer-undo-list t) | ||
| 397 | (process-environment | ||
| 398 | (cons "LC_MESSAGES=C" process-environment)) | ||
| 399 | (w32-quote-process-args t) | ||
| 400 | (this-status | ||
| 401 | (apply 'process-file "diff" nil t nil | ||
| 402 | (append (vc-switches 'SCCS 'diff) | ||
| 403 | (list oldfile | ||
| 404 | (or newfile | ||
| 405 | (file-relative-name file))))))) | ||
| 406 | (or (integerp this-status) (setq status 'error)) | ||
| 407 | (and (integerp status) | ||
| 408 | (> this-status status) | ||
| 409 | (setq status this-status)))) | ||
| 410 | (delete-file oldfile) | ||
| 411 | (if newfile (delete-file newfile))))) | ||
| 412 | (when (or (not (integerp status)) (> status 1)) | ||
| 413 | (unless (eq ?\s (aref (buffer-name (current-buffer)) 0)) | ||
| 414 | (pop-to-buffer (current-buffer)) | ||
| 415 | (goto-char (point-min)) | ||
| 416 | (shrink-window-if-larger-than-buffer)) | ||
| 417 | (error "Running %s...FAILED (%s)" fake-command | ||
| 418 | (if (integerp status) (format "status %d" status) status))) | ||
| 419 | (when vc-command-messages | ||
| 420 | (message "Running %s...OK = %d" fake-command status)) | ||
| 421 | ;; Should we pretend we ran sccsdiff instead? | ||
| 422 | ;; This might not actually be a valid diff command. | ||
| 423 | (run-hook-with-args 'vc-post-command-functions "diff" files fake-flags) | ||
| 424 | status))) | ||
| 368 | 425 | ||
| 369 | 426 | ||
| 370 | ;;; | 427 | ;;; |