diff options
| author | Eric S. Raymond | 1993-04-25 22:26:40 +0000 |
|---|---|---|
| committer | Eric S. Raymond | 1993-04-25 22:26:40 +0000 |
| commit | 8c0aaf4075e77ccb17827012667489ff3bcf14d3 (patch) | |
| tree | 71819a5c6a02dc1870f77cd5d6ebaea19ba21607 | |
| parent | 270967b21992489ab0c6d8b4a34065788647d093 (diff) | |
| download | emacs-8c0aaf4075e77ccb17827012667489ff3bcf14d3.tar.gz emacs-8c0aaf4075e77ccb17827012667489ff3bcf14d3.zip | |
(vc-diff): Get proper error message when you run this with no prefix
arg on an empty buffer.
(vc-directory): Better directory format --- replace the user and group IDs
with locking-user (if any).
(vc-finish-logentry, vc-next-comment, vc-previous-comment): Replace
*VC-comment-buffer* with a ring vector.
| -rw-r--r-- | lisp/vc.el | 290 |
1 files changed, 181 insertions, 109 deletions
diff --git a/lisp/vc.el b/lisp/vc.el index c143fe93e5a..0f7a3557544 100644 --- a/lisp/vc.el +++ b/lisp/vc.el | |||
| @@ -58,7 +58,15 @@ | |||
| 58 | ;;; Code: | 58 | ;;; Code: |
| 59 | 59 | ||
| 60 | (require 'vc-hooks) | 60 | (require 'vc-hooks) |
| 61 | (require 'ring) | ||
| 61 | (require 'dired) | 62 | (require 'dired) |
| 63 | (require 'compile) | ||
| 64 | (require 'sendmail) | ||
| 65 | |||
| 66 | (if (not (assoc 'vc-parent-buffer minor-mode-alist)) | ||
| 67 | (setq minor-mode-alist | ||
| 68 | (cons '(vc-parent-buffer vc-parent-buffer-name) | ||
| 69 | minor-mode-alist))) | ||
| 62 | 70 | ||
| 63 | ;; General customization | 71 | ;; General customization |
| 64 | 72 | ||
| @@ -77,10 +85,12 @@ The value is only computed when needed to avoid an expensive search.") | |||
| 77 | "*Display run messages from back-end commands.") | 85 | "*Display run messages from back-end commands.") |
| 78 | (defvar vc-mistrust-permissions 'file-symlink-p | 86 | (defvar vc-mistrust-permissions 'file-symlink-p |
| 79 | "*Don't assume that permissions and ownership track version-control status.") | 87 | "*Don't assume that permissions and ownership track version-control status.") |
| 80 | |||
| 81 | (defvar vc-checkin-switches nil | 88 | (defvar vc-checkin-switches nil |
| 82 | "*Extra switches passed to the checkin program by \\[vc-checkin].") | 89 | "*Extra switches passed to the checkin program by \\[vc-checkin].") |
| 83 | 90 | ||
| 91 | (defconst vc-maximum-comment-ring-size 32 | ||
| 92 | "Maximum number of saved comments in the comment ring.") | ||
| 93 | |||
| 84 | ;;;###autoload | 94 | ;;;###autoload |
| 85 | (defvar vc-checkin-hook nil | 95 | (defvar vc-checkin-hook nil |
| 86 | "*List of functions called after a vc-checkin is done. See `run-hooks'.") | 96 | "*List of functions called after a vc-checkin is done. See `run-hooks'.") |
| @@ -110,20 +120,34 @@ is sensitive to blank lines.") | |||
| 110 | (defvar vc-log-after-operation-hook nil) | 120 | (defvar vc-log-after-operation-hook nil) |
| 111 | (defvar vc-checkout-writeable-buffer-hook 'vc-checkout-writeable-buffer) | 121 | (defvar vc-checkout-writeable-buffer-hook 'vc-checkout-writeable-buffer) |
| 112 | (defvar vc-parent-buffer nil) | 122 | (defvar vc-parent-buffer nil) |
| 123 | (defvar vc-parent-buffer-name nil) | ||
| 113 | 124 | ||
| 114 | (defvar vc-log-file) | 125 | (defvar vc-log-file) |
| 115 | (defvar vc-log-version) | 126 | (defvar vc-log-version) |
| 116 | 127 | ||
| 117 | (defconst vc-name-assoc-file "VC-names") | 128 | (defconst vc-name-assoc-file "VC-names") |
| 118 | 129 | ||
| 130 | (defvar vc-dired-mode nil) | ||
| 119 | (make-variable-buffer-local 'vc-dired-mode) | 131 | (make-variable-buffer-local 'vc-dired-mode) |
| 120 | 132 | ||
| 133 | (defvar vc-comment-ring nil) | ||
| 134 | (defvar vc-comment-ring-index nil) | ||
| 135 | (defvar vc-last-comment-match nil) | ||
| 136 | |||
| 121 | ;; File property caching | 137 | ;; File property caching |
| 122 | 138 | ||
| 123 | (defun vc-file-clearprops (file) | 139 | (defun vc-file-clearprops (file) |
| 124 | ;; clear all properties of a given file | 140 | ;; clear all properties of a given file |
| 125 | (setplist (intern file vc-file-prop-obarray) nil)) | 141 | (setplist (intern file vc-file-prop-obarray) nil)) |
| 126 | 142 | ||
| 143 | (defun vc-clear-context () | ||
| 144 | "Clear all cached file properties and the comment ring." | ||
| 145 | (interactive) | ||
| 146 | (fillarray vc-file-prop-obarray nil) | ||
| 147 | ;; Note: there is potential for minor lossage here if there is an open | ||
| 148 | ;; log buffer with a nonzero local value of vc-comment-ring-index. | ||
| 149 | (setq vc-comment-ring nil)) | ||
| 150 | |||
| 127 | ;; Random helper functions | 151 | ;; Random helper functions |
| 128 | 152 | ||
| 129 | (defun vc-name (file) | 153 | (defun vc-name (file) |
| @@ -162,8 +186,10 @@ the master name of FILE; this is appended to an optional list of FLAGS." | |||
| 162 | (vc-file (and file (vc-name file))) | 186 | (vc-file (and file (vc-name file))) |
| 163 | status) | 187 | status) |
| 164 | (set-buffer (get-buffer-create "*vc*")) | 188 | (set-buffer (get-buffer-create "*vc*")) |
| 165 | (make-local-variable 'vc-parent-buffer) | 189 | (set (make-local-variable 'vc-parent-buffer) camefrom) |
| 166 | (setq vc-parent-buffer camefrom) | 190 | (set (make-local-variable 'vc-parent-buffer-name) |
| 191 | (concat " from " (buffer-name camefrom))) | ||
| 192 | |||
| 167 | (erase-buffer) | 193 | (erase-buffer) |
| 168 | 194 | ||
| 169 | ;; This is so that command arguments typed in the *vc* buffer will | 195 | ;; This is so that command arguments typed in the *vc* buffer will |
| @@ -330,11 +356,11 @@ the master name of FILE; this is appended to an optional list of FLAGS." | |||
| 330 | (if vc-initial-comment | 356 | (if vc-initial-comment |
| 331 | (setq vc-log-after-operation-hook | 357 | (setq vc-log-after-operation-hook |
| 332 | 'vc-checkout-writeable-buffer-hook) | 358 | 'vc-checkout-writeable-buffer-hook) |
| 333 | (vc-checkout-writeable-buffer))) | 359 | (vc-checkout-writeable-buffer file))) |
| 334 | 360 | ||
| 335 | ;; if there is no lock on the file, assert one and get it | 361 | ;; if there is no lock on the file, assert one and get it |
| 336 | ((not (setq owner (vc-locking-user file))) | 362 | ((not (setq owner (vc-locking-user file))) |
| 337 | (vc-checkout-writeable-buffer)) | 363 | (vc-checkout-writeable-buffer file)) |
| 338 | 364 | ||
| 339 | ;; a checked-out version exists, but the user may not own the lock | 365 | ;; a checked-out version exists, but the user may not own the lock |
| 340 | ((not (string-equal owner (user-login-name))) | 366 | ((not (string-equal owner (user-login-name))) |
| @@ -346,7 +372,7 @@ the master name of FILE; this is appended to an optional list of FLAGS." | |||
| 346 | owner)) | 372 | owner)) |
| 347 | 373 | ||
| 348 | ;; OK, user owns the lock on the file | 374 | ;; OK, user owns the lock on the file |
| 349 | (t (let (file-window) | 375 | (t |
| 350 | (find-file file) | 376 | (find-file file) |
| 351 | 377 | ||
| 352 | ;; give luser a chance to save before checking in. | 378 | ;; give luser a chance to save before checking in. |
| @@ -370,7 +396,7 @@ the master name of FILE; this is appended to an optional list of FLAGS." | |||
| 370 | 396 | ||
| 371 | ;; OK, let's do the checkin | 397 | ;; OK, let's do the checkin |
| 372 | (vc-checkin file version comment) | 398 | (vc-checkin file version comment) |
| 373 | )))))) | 399 | ))))) |
| 374 | 400 | ||
| 375 | (defun vc-next-action-dired (file rev comment) | 401 | (defun vc-next-action-dired (file rev comment) |
| 376 | ;; We've accepted a log comment, now do a vc-next-action using it on all | 402 | ;; We've accepted a log comment, now do a vc-next-action using it on all |
| @@ -378,7 +404,11 @@ the master name of FILE; this is appended to an optional list of FLAGS." | |||
| 378 | (set-buffer vc-parent-buffer) | 404 | (set-buffer vc-parent-buffer) |
| 379 | (dired-map-over-marks | 405 | (dired-map-over-marks |
| 380 | (save-window-excursion | 406 | (save-window-excursion |
| 381 | (vc-next-action-on-file (dired-get-filename) nil comment)) nil t) | 407 | (let ((file (dired-get-filename))) |
| 408 | (message "Processing %s..." file) | ||
| 409 | (vc-next-action-on-file file nil comment) | ||
| 410 | (message "Processing %s...done" file))) | ||
| 411 | nil t) | ||
| 382 | ) | 412 | ) |
| 383 | 413 | ||
| 384 | ;; Here's the major entry point. | 414 | ;; Here's the major entry point. |
| @@ -408,13 +438,15 @@ each one. The log message will be used as a comment for any register | |||
| 408 | or checkin operations, but ignored when doing checkouts. Attempted | 438 | or checkin operations, but ignored when doing checkouts. Attempted |
| 409 | lock steals will raise an error." | 439 | lock steals will raise an error." |
| 410 | (interactive "P") | 440 | (interactive "P") |
| 411 | (if vc-dired-mode | 441 | (catch 'nogo |
| 412 | (let ((files (dired-get-marked-files))) | 442 | (if vc-dired-mode |
| 413 | (if (null files) | 443 | (let ((files (dired-get-marked-files))) |
| 414 | (find-file-other-window (dired-get-filename)) | 444 | (if (= (length files) 1) |
| 415 | (vc-start-entry nil nil nil | 445 | (find-file-other-window (dired-get-filename)) |
| 416 | "Enter a change comment." | 446 | (vc-start-entry nil nil nil |
| 417 | 'vc-next-action-dired))) | 447 | "Enter a change comment for the marked files." |
| 448 | 'vc-next-action-dired) | ||
| 449 | (throw 'nogo)))) | ||
| 418 | (while vc-parent-buffer | 450 | (while vc-parent-buffer |
| 419 | (pop-to-buffer vc-parent-buffer)) | 451 | (pop-to-buffer vc-parent-buffer)) |
| 420 | (if buffer-file-name | 452 | (if buffer-file-name |
| @@ -423,9 +455,9 @@ lock steals will raise an error." | |||
| 423 | 455 | ||
| 424 | ;;; These functions help the vc-next-action entry point | 456 | ;;; These functions help the vc-next-action entry point |
| 425 | 457 | ||
| 426 | (defun vc-checkout-writeable-buffer () | 458 | (defun vc-checkout-writeable-buffer (&optional file) |
| 427 | "Retrieve a writeable copy of the latest version of the current buffer's file." | 459 | "Retrieve a writeable copy of the latest version of the current buffer's file." |
| 428 | (vc-checkout (buffer-file-name) t) | 460 | (vc-checkout (or file (buffer-file-name)) t) |
| 429 | ) | 461 | ) |
| 430 | 462 | ||
| 431 | ;;;###autoload | 463 | ;;;###autoload |
| @@ -473,8 +505,9 @@ lock steals will raise an error." | |||
| 473 | (if comment | 505 | (if comment |
| 474 | (set-buffer (get-buffer-create "*VC-log*")) | 506 | (set-buffer (get-buffer-create "*VC-log*")) |
| 475 | (pop-to-buffer (get-buffer-create "*VC-log*"))) | 507 | (pop-to-buffer (get-buffer-create "*VC-log*"))) |
| 476 | (make-local-variable 'vc-parent-buffer) | 508 | (set (make-local-variable 'vc-parent-buffer) parent) |
| 477 | (setq vc-parent-buffer parent) | 509 | (set (make-local-variable 'vc-parent-buffer-name) |
| 510 | (concat " from " (buffer-name vc-parent-buffer))) | ||
| 478 | (vc-mode-line (if file (file-name-nondirectory file) " (no file)")) | 511 | (vc-mode-line (if file (file-name-nondirectory file) " (no file)")) |
| 479 | (vc-log-mode) | 512 | (vc-log-mode) |
| 480 | (setq vc-log-operation action) | 513 | (setq vc-log-operation action) |
| @@ -483,9 +516,10 @@ lock steals will raise an error." | |||
| 483 | (if comment | 516 | (if comment |
| 484 | (progn | 517 | (progn |
| 485 | (erase-buffer) | 518 | (erase-buffer) |
| 486 | (if (not (eq comment t)) | 519 | (if (eq comment t) |
| 487 | (insert comment)) | 520 | (vc-finish-logentry t) |
| 488 | (vc-finish-logentry)) | 521 | (insert comment) |
| 522 | (vc-finish-logentry nil))) | ||
| 489 | (message "%s Type C-c C-c when done." msg)))) | 523 | (message "%s Type C-c C-c when done." msg)))) |
| 490 | 524 | ||
| 491 | (defun vc-admin (file rev &optional comment) | 525 | (defun vc-admin (file rev &optional comment) |
| @@ -514,7 +548,6 @@ level to check it in under. COMMENT, if specified, is the checkin comment." | |||
| 514 | (setq owner (vc-locking-user file))) | 548 | (setq owner (vc-locking-user file))) |
| 515 | (if (not (y-or-n-p (format "Take the lock on %s:%s from %s?" file rev owner))) | 549 | (if (not (y-or-n-p (format "Take the lock on %s:%s from %s?" file rev owner))) |
| 516 | (error "Steal cancelled.")) | 550 | (error "Steal cancelled.")) |
| 517 | (require 'sendmail) | ||
| 518 | (pop-to-buffer (get-buffer-create "*VC-mail*")) | 551 | (pop-to-buffer (get-buffer-create "*VC-mail*")) |
| 519 | (setq default-directory (expand-file-name "~/")) | 552 | (setq default-directory (expand-file-name "~/")) |
| 520 | (auto-save-mode auto-save-default) | 553 | (auto-save-mode auto-save-default) |
| @@ -547,7 +580,7 @@ popped up to accept a comment." | |||
| 547 | ;;; Here is a checkin hook that may prove useful to sites using the | 580 | ;;; Here is a checkin hook that may prove useful to sites using the |
| 548 | ;;; ChangeLog facility supported by Emacs. | 581 | ;;; ChangeLog facility supported by Emacs. |
| 549 | (defun vc-comment-to-change-log (&optional file) | 582 | (defun vc-comment-to-change-log (&optional file) |
| 550 | "Update change log from comments entered into VC for the current file. | 583 | "Update change log from VC change comments entered for the current file. |
| 551 | Optional FILE specifies the change log file name; see `find-change-log'. | 584 | Optional FILE specifies the change log file name; see `find-change-log'. |
| 552 | See `vc-update-change-log'." | 585 | See `vc-update-change-log'." |
| 553 | (interactive) | 586 | (interactive) |
| @@ -558,24 +591,22 @@ See `vc-update-change-log'." | |||
| 558 | (vc-update-change-log | 591 | (vc-update-change-log |
| 559 | (file-relative-name buffer-file-name)))))) | 592 | (file-relative-name buffer-file-name)))))) |
| 560 | 593 | ||
| 561 | (defun vc-finish-logentry () | 594 | (defun vc-finish-logentry (&optional nocomment) |
| 562 | "Complete the operation implied by the current log entry." | 595 | "Complete the operation implied by the current log entry." |
| 563 | (interactive) | 596 | (interactive) |
| 564 | (goto-char (point-max)) | 597 | ;; Check and record the comment, if any. |
| 565 | (if (not (bolp)) (newline)) | 598 | (if (not nocomment) |
| 566 | ;; Append the contents of the log buffer to the comment ring | 599 | (progn |
| 567 | (save-excursion | 600 | (goto-char (point-max)) |
| 568 | (set-buffer (get-buffer-create "*VC-comment-ring*")) | 601 | (if (not (bolp)) |
| 569 | (goto-char (point-max)) | 602 | (newline)) |
| 570 | (set-mark (point)) | 603 | ;; Comment too long? |
| 571 | (insert-buffer-substring "*VC-log*") | 604 | (vc-backend-logentry-check vc-log-file) |
| 572 | (if (and (not (bobp)) (not (= (char-after (1- (point))) ?\f))) | 605 | ;; Record the comment in the comment ring |
| 573 | (insert-char ?\f 1)) | 606 | (if (null vc-comment-ring) |
| 574 | (if (not (bobp)) | 607 | (setq vc-comment-ring (make-ring vc-maximum-comment-ring-size))) |
| 575 | (forward-char -1)) | 608 | (ring-insert vc-comment-ring (buffer-string)) |
| 576 | (exchange-point-and-mark) | 609 | )) |
| 577 | ;; Check for errors | ||
| 578 | (vc-backend-logentry-check vc-log-file)) | ||
| 579 | ;; OK, do it to it | 610 | ;; OK, do it to it |
| 580 | (if vc-log-operation | 611 | (if vc-log-operation |
| 581 | (save-excursion | 612 | (save-excursion |
| @@ -589,7 +620,6 @@ See `vc-update-change-log'." | |||
| 589 | (vc-error-occurred | 620 | (vc-error-occurred |
| 590 | (delete-window (get-buffer-window "*VC-log*"))) | 621 | (delete-window (get-buffer-window "*VC-log*"))) |
| 591 | (kill-buffer "*VC-log*") | 622 | (kill-buffer "*VC-log*") |
| 592 | (bury-buffer "*VC-comment-ring*") | ||
| 593 | ;; Now make sure we see the expanded headers | 623 | ;; Now make sure we see the expanded headers |
| 594 | (if buffer-file-name | 624 | (if buffer-file-name |
| 595 | (vc-resynch-window buffer-file-name vc-keep-workfiles t)) | 625 | (vc-resynch-window buffer-file-name vc-keep-workfiles t)) |
| @@ -597,57 +627,65 @@ See `vc-update-change-log'." | |||
| 597 | 627 | ||
| 598 | ;; Code for access to the comment ring | 628 | ;; Code for access to the comment ring |
| 599 | 629 | ||
| 600 | (defun vc-next-comment () | 630 | (defun vc-previous-comment (arg) |
| 601 | "Fill the log buffer with the next message in the msg ring." | 631 | "Cycle backwards through comment history." |
| 602 | (interactive) | 632 | (interactive "*p") |
| 603 | (erase-buffer) | 633 | (let ((len (ring-length vc-comment-ring))) |
| 604 | (save-excursion | 634 | (cond ((<= len 0) |
| 605 | (set-buffer "*VC-comment-ring*") | 635 | (message "Empty comment ring") |
| 606 | (forward-page) | 636 | (ding)) |
| 607 | (if (= (point) (point-max)) | 637 | (t |
| 608 | (goto-char (point-min))) | 638 | (erase-buffer) |
| 609 | (mark-page) | 639 | ;; Initialize the index on the first use of this command |
| 610 | (append-to-buffer "*VC-log*" (point) (1- (mark))) | 640 | ;; so that the first M-p gets index 0, and the first M-n gets |
| 611 | )) | 641 | ;; index -1. |
| 612 | 642 | (if (null vc-comment-ring-index) | |
| 613 | (defun vc-previous-comment () | 643 | (setq vc-comment-ring-index |
| 614 | "Fill the log buffer with the previous message in the msg ring." | 644 | (if (> arg 0) -1 |
| 615 | (interactive) | 645 | (if (< arg 0) 1 0)))) |
| 616 | (erase-buffer) | 646 | (setq vc-comment-ring-index |
| 617 | (save-excursion | 647 | (ring-mod (+ vc-comment-ring-index arg) len)) |
| 618 | (set-buffer "*VC-comment-ring*") | 648 | (message "%d" (1+ vc-comment-ring-index)) |
| 619 | (if (= (point) (point-min)) | 649 | (insert (ring-ref vc-comment-ring vc-comment-ring-index)))))) |
| 620 | (goto-char (point-max))) | 650 | |
| 621 | (backward-page) | 651 | (defun vc-next-comment (arg) |
| 622 | (mark-page) | 652 | "Cycle forwards through comment history." |
| 623 | (append-to-buffer "*VC-log*" (point) (1- (mark))) | 653 | (interactive "*p") |
| 624 | )) | 654 | (vc-previous-comment (- arg))) |
| 625 | 655 | ||
| 626 | (defun vc-comment-search-backward (regexp) | 656 | (defun vc-comment-search-reverse (str) |
| 627 | "Fill the log buffer with the last message in the msg ring matching REGEXP." | 657 | "Searches backwards through comment history for substring match." |
| 628 | (interactive "sSearch backward for: ") | 658 | (interactive "sComment substring: ") |
| 629 | (erase-buffer) | 659 | (if (string= str "") |
| 630 | (save-excursion | 660 | (setq str vc-last-comment-match) |
| 631 | (set-buffer "*VC-comment-ring*") | 661 | (setq vc-last-comment-match str)) |
| 632 | (if (= (point) (point-min)) | 662 | (if (null vc-comment-ring-index) |
| 633 | (goto-char (point-max))) | 663 | (setq vc-comment-ring-index -1)) |
| 634 | (re-search-backward regexp nil t) | 664 | (let ((str (regexp-quote str)) |
| 635 | (mark-page) | 665 | (len (ring-length vc-comment-ring)) |
| 636 | (append-to-buffer "*VC-log*" (point) (1- (mark))) | 666 | (n (1+ vc-comment-ring-index))) |
| 637 | )) | 667 | (while (and (< n len) (not (string-match str (ring-ref vc-comment-ring n)))) |
| 638 | 668 | (setq n (+ n 1))) | |
| 639 | (defun vc-comment-search-forward (regexp) | 669 | (cond ((< n len) |
| 640 | "Fill the log buffer with the next message in the msg ring matching REGEXP." | 670 | (vc-previous-comment (- n vc-comment-ring-index))) |
| 641 | (interactive "sSearch forward for: ") | 671 | (t (error "Not found"))))) |
| 642 | (erase-buffer) | 672 | |
| 643 | (save-excursion | 673 | (defun vc-comment-search-forward (str) |
| 644 | (set-buffer "*VC-comment-ring*") | 674 | "Searches forwards through comment history for substring match." |
| 645 | (if (= (point) (point-max)) | 675 | (interactive "sComment substring: ") |
| 646 | (goto-char (point-min))) | 676 | (if (string= str "") |
| 647 | (re-search-forward regexp nil t) | 677 | (setq str vc-last-comment-match) |
| 648 | (mark-page) | 678 | (setq vc-last-comment-match str)) |
| 649 | (append-to-buffer "*VC-log*" (point) (1- (mark))) | 679 | (if (null vc-comment-ring-index) |
| 650 | )) | 680 | (setq vc-comment-ring-index 0)) |
| 681 | (let ((str (regexp-quote str)) | ||
| 682 | (len (ring-length vc-comment-ring)) | ||
| 683 | (n vc-comment-ring-index)) | ||
| 684 | (while (and (>= n 0) (not (string-match str (ring-ref vc-comment-ring n)))) | ||
| 685 | (setq n (- n 1))) | ||
| 686 | (cond ((>= n 0) | ||
| 687 | (vc-next-comment (- n vc-comment-ring-index))) | ||
| 688 | (t (error "Not found"))))) | ||
| 651 | 689 | ||
| 652 | ;; Additional entry points for examining version histories | 690 | ;; Additional entry points for examining version histories |
| 653 | 691 | ||
| @@ -661,14 +699,23 @@ See `vc-update-change-log'." | |||
| 661 | (pop-to-buffer vc-parent-buffer)) | 699 | (pop-to-buffer vc-parent-buffer)) |
| 662 | (if historic | 700 | (if historic |
| 663 | (call-interactively 'vc-version-diff) | 701 | (call-interactively 'vc-version-diff) |
| 702 | (if (or (null buffer-file-name) (null (vc-name buffer-file-name))) | ||
| 703 | (error "There is no version-control master associated with this buffer.")) | ||
| 664 | (let ((file buffer-file-name) | 704 | (let ((file buffer-file-name) |
| 665 | unchanged) | 705 | unchanged) |
| 666 | (vc-buffer-sync) | 706 | (vc-buffer-sync) |
| 667 | (setq unchanged (vc-workfile-unchanged-p buffer-file-name)) | 707 | (setq unchanged (vc-workfile-unchanged-p buffer-file-name)) |
| 668 | (if unchanged | 708 | (if unchanged |
| 669 | (message "No changes to %s since latest version." file) | 709 | (message "No changes to %s since latest version." file) |
| 670 | (pop-to-buffer "*vc*") | ||
| 671 | (vc-backend-diff file nil) | 710 | (vc-backend-diff file nil) |
| 711 | ;; Ideally, we'd like at this point to parse the diff so that | ||
| 712 | ;; the buffer effectively goes into compilation mode and we | ||
| 713 | ;; can visit the old and new change locations via next-error. | ||
| 714 | ;; Unfortunately, this is just too painful to do. The basic | ||
| 715 | ;; problem is that the `old' file doesn't exist to be | ||
| 716 | ;; visited. This plays hell with numerous assumptions in | ||
| 717 | ;; the diff.el and compile.el machinery. | ||
| 718 | (pop-to-buffer "*vc*") | ||
| 672 | (vc-shrink-to-fit) | 719 | (vc-shrink-to-fit) |
| 673 | (goto-char (point-min)) | 720 | (goto-char (point-min)) |
| 674 | ) | 721 | ) |
| @@ -687,8 +734,9 @@ files in or below it." | |||
| 687 | (if (file-directory-p file) | 734 | (if (file-directory-p file) |
| 688 | (let ((camefrom (current-buffer))) | 735 | (let ((camefrom (current-buffer))) |
| 689 | (set-buffer (get-buffer-create "*vc-status*")) | 736 | (set-buffer (get-buffer-create "*vc-status*")) |
| 690 | (make-local-variable 'vc-parent-buffer) | 737 | (set (make-local-variable 'vc-parent-buffer) camefrom) |
| 691 | (setq vc-parent-buffer camefrom) | 738 | (set (make-local-variable 'vc-parent-buffer-name) |
| 739 | (concat " from " (buffer-name camefrom))) | ||
| 692 | (erase-buffer) | 740 | (erase-buffer) |
| 693 | (insert "Diffs between " | 741 | (insert "Diffs between " |
| 694 | (or rel1 "last version checked in") | 742 | (or rel1 "last version checked in") |
| @@ -773,6 +821,24 @@ on a buffer attached to the file named in the current Dired buffer line." | |||
| 773 | (setq vc-dired-mode t) | 821 | (setq vc-dired-mode t) |
| 774 | (setq vc-mode " under VC")) | 822 | (setq vc-mode " under VC")) |
| 775 | 823 | ||
| 824 | (defun vc-dired-reformat-line (x) | ||
| 825 | ;; Hack a directory-listing line, plugging in locking-user info in | ||
| 826 | ;; place of the user and group info. Should have the beneficial | ||
| 827 | ;; side-effect of shortening the listing line. Each call starts with | ||
| 828 | ;; point immediately following the dired mark area on the line to be | ||
| 829 | ;; hacked. | ||
| 830 | ;; | ||
| 831 | ;; Simplest possible one: | ||
| 832 | ;; (insert (concat x "\t"))) | ||
| 833 | ;; | ||
| 834 | ;; This code, like dired, assumes UNIX -l format. | ||
| 835 | (forward-word 1) ;; skip over any extra field due to -ibs options | ||
| 836 | (if x (setq x (concat "(" x ")"))) | ||
| 837 | (if (re-search-forward "\\([0-9]+ \\).................\\( .*\\)" nil 0) | ||
| 838 | (let ((rep (substring (concat x " ") 0 9))) | ||
| 839 | (replace-match (concat "\\1" rep "\\2") t))) | ||
| 840 | ) | ||
| 841 | |||
| 776 | ;;;###autoload | 842 | ;;;###autoload |
| 777 | (defun vc-directory (verbose) | 843 | (defun vc-directory (verbose) |
| 778 | "Show version-control status of all files under the current directory." | 844 | "Show version-control status of all files under the current directory." |
| @@ -780,7 +846,8 @@ on a buffer attached to the file named in the current Dired buffer line." | |||
| 780 | (let (nonempty | 846 | (let (nonempty |
| 781 | (dl (length default-directory)) | 847 | (dl (length default-directory)) |
| 782 | (filelist nil) (userlist nil) | 848 | (filelist nil) (userlist nil) |
| 783 | dired-buf) | 849 | dired-buf |
| 850 | dired-buf-mod-count) | ||
| 784 | (vc-file-tree-walk | 851 | (vc-file-tree-walk |
| 785 | (function (lambda (f) | 852 | (function (lambda (f) |
| 786 | (if (vc-registered f) | 853 | (if (vc-registered f) |
| @@ -789,22 +856,26 @@ on a buffer attached to the file named in the current Dired buffer line." | |||
| 789 | (setq filelist (cons (substring f dl) filelist)) | 856 | (setq filelist (cons (substring f dl) filelist)) |
| 790 | (setq userlist (cons user userlist)))))))) | 857 | (setq userlist (cons user userlist)))))))) |
| 791 | (save-excursion | 858 | (save-excursion |
| 792 | (dired (cons default-directory (nreverse filelist))) | 859 | ;; This uses a semi-documented featre of dired; giving a switch |
| 793 | (setq dired-buf (current-buffer)) | 860 | ;; argument forces the buffer to refresh each time. |
| 794 | (setq nonempty (not (zerop (buffer-size))))) | 861 | (dired |
| 862 | (cons default-directory (nreverse filelist)) | ||
| 863 | dired-listing-switches) | ||
| 864 | (setq dired-buf (current-buffer)) | ||
| 865 | (setq nonempty (not (zerop (buffer-size))))) | ||
| 795 | (if nonempty | 866 | (if nonempty |
| 796 | (progn | 867 | (progn |
| 797 | (pop-to-buffer dired-buf) | 868 | (pop-to-buffer dired-buf) |
| 798 | (vc-dired-mode) | 869 | (vc-dired-mode) |
| 799 | (goto-char (point-min)) | 870 | (goto-char (point-min)) |
| 800 | (setq buffer-read-only nil) | 871 | (setq buffer-read-only nil) |
| 872 | (forward-line 1) ;; Skip header line | ||
| 801 | (mapcar | 873 | (mapcar |
| 802 | (function (lambda (x) | 874 | (lambda (x) |
| 803 | (forward-char 2) ;; skip dired's mark area | 875 | (forward-char 2) ;; skip dired's mark area |
| 804 | (if x (insert x)) | 876 | (vc-dired-reformat-line x) |
| 805 | (insert "\t") | 877 | (forward-line 1)) ;; go to next line |
| 806 | (forward-line 1))) | 878 | (nreverse userlist)) |
| 807 | (cons "\t" (nreverse userlist))) | ||
| 808 | (setq buffer-read-only t) | 879 | (setq buffer-read-only t) |
| 809 | (goto-char (point-min)) | 880 | (goto-char (point-min)) |
| 810 | ) | 881 | ) |
| @@ -1269,7 +1340,7 @@ Return nil if there is no such person." | |||
| 1269 | 1340 | ||
| 1270 | (defun vc-backend-logentry-check (file) | 1341 | (defun vc-backend-logentry-check (file) |
| 1271 | (vc-backend-dispatch file | 1342 | (vc-backend-dispatch file |
| 1272 | (if (>= (- (region-end) (region-beginning)) 512) ;; SCCS | 1343 | (if (>= (buffer-size) 512) ;; SCCS |
| 1273 | (progn | 1344 | (progn |
| 1274 | (goto-char 512) | 1345 | (goto-char 512) |
| 1275 | (error | 1346 | (error |
| @@ -1414,8 +1485,8 @@ saved comments. These can be recalled as follows: | |||
| 1414 | 1485 | ||
| 1415 | \\[vc-next-comment] replace region with next message in comment ring | 1486 | \\[vc-next-comment] replace region with next message in comment ring |
| 1416 | \\[vc-previous-comment] replace region with previous message in comment ring | 1487 | \\[vc-previous-comment] replace region with previous message in comment ring |
| 1417 | \\[vc-search-comment-reverse] search backward for regexp in the comment ring | 1488 | \\[vc-comment-search-reverse] search backward for regexp in the comment ring |
| 1418 | \\[vc-search-comment-forward] search backward for regexp in the comment ring | 1489 | \\[vc-comment-search-forward] search backward for regexp in the comment ring |
| 1419 | 1490 | ||
| 1420 | Entry to the change-log submode calls the value of text-mode-hook, then | 1491 | Entry to the change-log submode calls the value of text-mode-hook, then |
| 1421 | the value of vc-log-mode-hook. | 1492 | the value of vc-log-mode-hook. |
| @@ -1457,6 +1528,7 @@ Global user options: | |||
| 1457 | (setq mode-name "VC-Log") | 1528 | (setq mode-name "VC-Log") |
| 1458 | (make-local-variable 'vc-log-file) | 1529 | (make-local-variable 'vc-log-file) |
| 1459 | (make-local-variable 'vc-log-version) | 1530 | (make-local-variable 'vc-log-version) |
| 1531 | (make-local-variable 'vc-comment-ring-index) | ||
| 1460 | (set-buffer-modified-p nil) | 1532 | (set-buffer-modified-p nil) |
| 1461 | (setq buffer-file-name nil) | 1533 | (setq buffer-file-name nil) |
| 1462 | (run-hooks 'text-mode-hook 'vc-log-mode-hook) | 1534 | (run-hooks 'text-mode-hook 'vc-log-mode-hook) |
| @@ -1468,7 +1540,7 @@ Global user options: | |||
| 1468 | (setq vc-log-entry-mode (make-sparse-keymap)) | 1540 | (setq vc-log-entry-mode (make-sparse-keymap)) |
| 1469 | (define-key vc-log-entry-mode "\M-n" 'vc-next-comment) | 1541 | (define-key vc-log-entry-mode "\M-n" 'vc-next-comment) |
| 1470 | (define-key vc-log-entry-mode "\M-p" 'vc-previous-comment) | 1542 | (define-key vc-log-entry-mode "\M-p" 'vc-previous-comment) |
| 1471 | (define-key vc-log-entry-mode "\M-r" 'vc-comment-search-backward) | 1543 | (define-key vc-log-entry-mode "\M-r" 'vc-comment-search-reverse) |
| 1472 | (define-key vc-log-entry-mode "\M-s" 'vc-comment-search-forward) | 1544 | (define-key vc-log-entry-mode "\M-s" 'vc-comment-search-forward) |
| 1473 | (define-key vc-log-entry-mode "\C-c\C-c" 'vc-finish-logentry) | 1545 | (define-key vc-log-entry-mode "\C-c\C-c" 'vc-finish-logentry) |
| 1474 | ) | 1546 | ) |