diff options
| author | André Spiegel | 2002-01-05 17:15:20 +0000 |
|---|---|---|
| committer | André Spiegel | 2002-01-05 17:15:20 +0000 |
| commit | 869131a59320d279fa9f18585e93eee125f550d9 (patch) | |
| tree | af5670affb4385a224e8db56e368f645ed9d3ea2 | |
| parent | a62d9f303183825115f2a34e03e1500bf4566406 (diff) | |
| download | emacs-869131a59320d279fa9f18585e93eee125f550d9.tar.gz emacs-869131a59320d279fa9f18585e93eee125f550d9.zip | |
(vc-branch-part): Return nil if there's no `.'
(vc-default-previous-version): Renamed from vc-previous-version. New
args BACKEND and FILE. Return nil for revision numbers without a `.'
(vc-version-diff): Call vc-BACKEND-previous-version.
(vc-steal-lock): Steal lock before composing mail, so that no mail is
sent when the stealing goes wrong. And we'll actually see the error
in that case now.
(vc-finish-steal): Removed.
| -rw-r--r-- | lisp/vc.el | 63 |
1 files changed, 35 insertions, 28 deletions
diff --git a/lisp/vc.el b/lisp/vc.el index 6c2b5d954a3..41124f05789 100644 --- a/lisp/vc.el +++ b/lisp/vc.el | |||
| @@ -6,7 +6,7 @@ | |||
| 6 | ;; Maintainer: Andre Spiegel <spiegel@gnu.org> | 6 | ;; Maintainer: Andre Spiegel <spiegel@gnu.org> |
| 7 | ;; Keywords: tools | 7 | ;; Keywords: tools |
| 8 | 8 | ||
| 9 | ;; $Id: vc.el,v 1.323 2001/11/26 16:17:17 pj Exp $ | 9 | ;; $Id: vc.el,v 1.324 2001/12/20 18:47:19 pj Exp $ |
| 10 | 10 | ||
| 11 | ;; This file is part of GNU Emacs. | 11 | ;; This file is part of GNU Emacs. |
| 12 | 12 | ||
| @@ -365,6 +365,10 @@ | |||
| 365 | ;; `revert' operations itself, without calling the backend system. The | 365 | ;; `revert' operations itself, without calling the backend system. The |
| 366 | ;; default implementation always returns nil. | 366 | ;; default implementation always returns nil. |
| 367 | ;; | 367 | ;; |
| 368 | ;; - previous-version (file rev) | ||
| 369 | ;; | ||
| 370 | ;; Return the version number that precedes REV for FILE. | ||
| 371 | ;; | ||
| 368 | ;; - check-headers () | 372 | ;; - check-headers () |
| 369 | ;; | 373 | ;; |
| 370 | ;; Return non-nil if the current buffer contains any version headers. | 374 | ;; Return non-nil if the current buffer contains any version headers. |
| @@ -689,27 +693,32 @@ The keys are \(BUFFER . BACKEND\). See also `vc-annotate-get-backend'.") | |||
| 689 | 693 | ||
| 690 | (defun vc-branch-part (rev) | 694 | (defun vc-branch-part (rev) |
| 691 | "Return the branch part of a revision number REV." | 695 | "Return the branch part of a revision number REV." |
| 692 | (substring rev 0 (string-match "\\.[0-9]+\\'" rev))) | 696 | (let ((index (string-match "\\.[0-9]+\\'" rev))) |
| 697 | (if index | ||
| 698 | (substring rev 0 index)))) | ||
| 693 | 699 | ||
| 694 | (defun vc-minor-part (rev) | 700 | (defun vc-minor-part (rev) |
| 695 | "Return the minor version number of a revision number REV." | 701 | "Return the minor version number of a revision number REV." |
| 696 | (string-match "[0-9]+\\'" rev) | 702 | (string-match "[0-9]+\\'" rev) |
| 697 | (substring rev (match-beginning 0) (match-end 0))) | 703 | (substring rev (match-beginning 0) (match-end 0))) |
| 698 | 704 | ||
| 699 | (defun vc-previous-version (rev) | 705 | (defun vc-default-previous-version (backend file rev) |
| 700 | "Guess the version number immediately preceding REV." | 706 | "Guess the version number immediately preceding REV for FILE. |
| 707 | This default implementation works for <major>.<minor>-style version numbers | ||
| 708 | as used by RCS and CVS." | ||
| 701 | (let ((branch (vc-branch-part rev)) | 709 | (let ((branch (vc-branch-part rev)) |
| 702 | (minor-num (string-to-number (vc-minor-part rev)))) | 710 | (minor-num (string-to-number (vc-minor-part rev)))) |
| 703 | (if (> minor-num 1) | 711 | (when branch |
| 704 | ;; version does probably not start a branch or release | 712 | (if (> minor-num 1) |
| 705 | (concat branch "." (number-to-string (1- minor-num))) | 713 | ;; version does probably not start a branch or release |
| 706 | (if (vc-trunk-p rev) | 714 | (concat branch "." (number-to-string (1- minor-num))) |
| 707 | ;; we are at the beginning of the trunk -- | 715 | (if (vc-trunk-p rev) |
| 708 | ;; don't know anything to return here | 716 | ;; we are at the beginning of the trunk -- |
| 709 | "" | 717 | ;; don't know anything to return here |
| 710 | ;; we are at the beginning of a branch -- | 718 | nil |
| 711 | ;; return version of starting point | 719 | ;; we are at the beginning of a branch -- |
| 712 | (vc-branch-part branch))))) | 720 | ;; return version of starting point |
| 721 | (vc-branch-part branch)))))) | ||
| 713 | 722 | ||
| 714 | ;; File property caching | 723 | ;; File property caching |
| 715 | 724 | ||
| @@ -1510,9 +1519,16 @@ After check-out, runs the normal hook `vc-checkout-hook'." | |||
| 1510 | (if (not (yes-or-no-p (format "Steal the lock on %s from %s? " | 1519 | (if (not (yes-or-no-p (format "Steal the lock on %s from %s? " |
| 1511 | file-description owner))) | 1520 | file-description owner))) |
| 1512 | (error "Steal canceled")) | 1521 | (error "Steal canceled")) |
| 1513 | (compose-mail owner (format "Stolen lock on %s" file-description) | 1522 | (message "Stealing lock on %s..." file) |
| 1514 | nil nil nil nil | 1523 | (with-vc-properties |
| 1515 | (list (list 'vc-finish-steal file rev))) | 1524 | file |
| 1525 | (vc-call steal-lock file rev) | ||
| 1526 | `((vc-state . edited))) | ||
| 1527 | (vc-resynch-buffer file t t) | ||
| 1528 | (message "Stealing lock on %s...done" file) | ||
| 1529 | ;; Write mail after actually stealing, because if the stealing | ||
| 1530 | ;; goes wrong, we don't want to send any mail. | ||
| 1531 | (compose-mail owner (format "Stolen lock on %s" file-description)) | ||
| 1516 | (setq default-directory (expand-file-name "~/")) | 1532 | (setq default-directory (expand-file-name "~/")) |
| 1517 | (goto-char (point-max)) | 1533 | (goto-char (point-max)) |
| 1518 | (insert | 1534 | (insert |
| @@ -1521,16 +1537,6 @@ After check-out, runs the normal hook `vc-checkout-hook'." | |||
| 1521 | ".\n") | 1537 | ".\n") |
| 1522 | (message "Please explain why you stole the lock. Type C-c C-c when done."))) | 1538 | (message "Please explain why you stole the lock. Type C-c C-c when done."))) |
| 1523 | 1539 | ||
| 1524 | (defun vc-finish-steal (file version) | ||
| 1525 | ;; This is called when the notification has been sent. | ||
| 1526 | (message "Stealing lock on %s..." file) | ||
| 1527 | (with-vc-properties | ||
| 1528 | file | ||
| 1529 | (vc-call steal-lock file version) | ||
| 1530 | `((vc-state . edited))) | ||
| 1531 | (vc-resynch-buffer file t t) | ||
| 1532 | (message "Stealing lock on %s...done" file)) | ||
| 1533 | |||
| 1534 | (defun vc-checkin (file &optional rev comment initial-contents) | 1540 | (defun vc-checkin (file &optional rev comment initial-contents) |
| 1535 | "Check in FILE. | 1541 | "Check in FILE. |
| 1536 | The optional argument REV may be a string specifying the new version | 1542 | The optional argument REV may be a string specifying the new version |
| @@ -1771,7 +1777,8 @@ versions of all registered files in or below it." | |||
| 1771 | (setq rel1-default (vc-workfile-version file))) | 1777 | (setq rel1-default (vc-workfile-version file))) |
| 1772 | ;; if the file is not locked, use last and previous version as default | 1778 | ;; if the file is not locked, use last and previous version as default |
| 1773 | (t | 1779 | (t |
| 1774 | (setq rel1-default (vc-previous-version (vc-workfile-version file))) | 1780 | (setq rel1-default (vc-call previous-version file |
| 1781 | (vc-workfile-version file))) | ||
| 1775 | (if (string= rel1-default "") (setq rel1-default nil)) | 1782 | (if (string= rel1-default "") (setq rel1-default nil)) |
| 1776 | (setq rel2-default (vc-workfile-version file)))) | 1783 | (setq rel2-default (vc-workfile-version file)))) |
| 1777 | ;; construct argument list | 1784 | ;; construct argument list |