diff options
| author | André Spiegel | 1998-03-31 17:19:32 +0000 |
|---|---|---|
| committer | André Spiegel | 1998-03-31 17:19:32 +0000 |
| commit | 18483cf000f867954b23d958f4d3d50abbfd3f9e (patch) | |
| tree | dfe78abbf1fa855d6b22aea3019ff71f8d368098 | |
| parent | 652838b531e16056fa17595358289c4505c492be (diff) | |
| download | emacs-18483cf000f867954b23d958f4d3d50abbfd3f9e.tar.gz emacs-18483cf000f867954b23d958f4d3d50abbfd3f9e.zip | |
* vc.el (vc-resolve-conflicts): New function.
(vc-next-action-on-file): Use it.
(vc-backend-revert): For CVS, revert to the version the buffer was
based on, not the latest on the current branch (same behavior as
for RCS). For SCCS, forget vc-workfile-version so that it gets
recomputed.
(vc-revert-buffer): Rewrote doc string to explain the above.
(vc-finish-logentry): Don't add extra newline.
| -rw-r--r-- | lisp/vc.el | 122 |
1 files changed, 101 insertions, 21 deletions
diff --git a/lisp/vc.el b/lisp/vc.el index 1e047daefda..080ba2f6714 100644 --- a/lisp/vc.el +++ b/lisp/vc.el | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | ;; Author: Eric S. Raymond <esr@snark.thyrsus.com> | 5 | ;; Author: Eric S. Raymond <esr@snark.thyrsus.com> |
| 6 | ;; Maintainer: Andre Spiegel <spiegel@inf.fu-berlin.de> | 6 | ;; Maintainer: Andre Spiegel <spiegel@inf.fu-berlin.de> |
| 7 | 7 | ||
| 8 | ;; $Id: vc.el,v 1.211 1998/03/18 13:25:00 spiegel Exp spiegel $ | 8 | ;; $Id: vc.el,v 1.212 1998/03/20 15:40:24 spiegel Exp spiegel $ |
| 9 | 9 | ||
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | 11 | ||
| @@ -781,14 +781,13 @@ before the filename." | |||
| 781 | "Buffer %s modified; merge file on disc anyhow? " | 781 | "Buffer %s modified; merge file on disc anyhow? " |
| 782 | (buffer-name buffer))))) | 782 | (buffer-name buffer))))) |
| 783 | (error "Merge aborted")) | 783 | (error "Merge aborted")) |
| 784 | (if (not (zerop (vc-backend-merge-news file))) | 784 | (let ((status (vc-backend-merge-news file))) |
| 785 | ;; Overlaps detected - what now? Should use some | 785 | (and buffer |
| 786 | ;; fancy RCS conflict resolving package, or maybe | 786 | (vc-resynch-buffer file t |
| 787 | ;; emerge, but for now, simply warn the user with a | 787 | (not (buffer-modified-p buffer)))) |
| 788 | ;; message. | 788 | (if (not (zerop status)) |
| 789 | (message "Conflicts detected!")) | 789 | (if (y-or-n-p "Conflicts detected. Resolve them now? ") |
| 790 | (and buffer | 790 | (vc-resolve-conflicts))))) |
| 791 | (vc-resynch-buffer file t (not (buffer-modified-p buffer))))) | ||
| 792 | (error "%s needs update" (buffer-name)))) | 791 | (error "%s needs update" (buffer-name)))) |
| 793 | 792 | ||
| 794 | ;; For CVS files with implicit checkout: if unmodified, don't do anything | 793 | ;; For CVS files with implicit checkout: if unmodified, don't do anything |
| @@ -867,7 +866,7 @@ before the filename." | |||
| 867 | (if (yes-or-no-p "Replace file on disk with buffer contents? ") | 866 | (if (yes-or-no-p "Replace file on disk with buffer contents? ") |
| 868 | (write-file (buffer-file-name)) | 867 | (write-file (buffer-file-name)) |
| 869 | (error "Aborted")) | 868 | (error "Aborted")) |
| 870 | ;; give luser a chance to save before checking in. | 869 | ;; if buffer is not saved, give user a chance to do it |
| 871 | (vc-buffer-sync)) | 870 | (vc-buffer-sync)) |
| 872 | 871 | ||
| 873 | ;; Revert if file is unchanged and buffer is too. | 872 | ;; Revert if file is unchanged and buffer is too. |
| @@ -1204,9 +1203,6 @@ May be useful as a `vc-checkin-hook' to update change logs automatically." | |||
| 1204 | ;; Check and record the comment, if any. | 1203 | ;; Check and record the comment, if any. |
| 1205 | (if (not nocomment) | 1204 | (if (not nocomment) |
| 1206 | (progn | 1205 | (progn |
| 1207 | (goto-char (point-max)) | ||
| 1208 | (if (not (bolp)) | ||
| 1209 | (newline)) | ||
| 1210 | ;; Comment too long? | 1206 | ;; Comment too long? |
| 1211 | (vc-backend-logentry-check vc-log-file) | 1207 | (vc-backend-logentry-check vc-log-file) |
| 1212 | ;; Record the comment in the comment ring | 1208 | ;; Record the comment in the comment ring |
| @@ -1488,6 +1484,86 @@ the variable `vc-header-alist'." | |||
| 1488 | (replace-match "$\\1$"))) | 1484 | (replace-match "$\\1$"))) |
| 1489 | (vc-restore-buffer-context context))) | 1485 | (vc-restore-buffer-context context))) |
| 1490 | 1486 | ||
| 1487 | (defun vc-resolve-conflicts () | ||
| 1488 | "Invoke ediff to resolve conflicts in the current buffer. | ||
| 1489 | The conflicts must be marked with rcsmerge conflict markers." | ||
| 1490 | (interactive) | ||
| 1491 | (let* ((found nil) | ||
| 1492 | (file-name (file-name-nondirectory buffer-file-name)) | ||
| 1493 | (your-buffer (generate-new-buffer | ||
| 1494 | (concat "*" file-name " WORKFILE*"))) | ||
| 1495 | (other-buffer (generate-new-buffer | ||
| 1496 | (concat "*" file-name " CHECKED-IN*"))) | ||
| 1497 | (result-buffer (current-buffer))) | ||
| 1498 | (save-excursion | ||
| 1499 | (set-buffer your-buffer) | ||
| 1500 | (erase-buffer) | ||
| 1501 | (insert-buffer result-buffer) | ||
| 1502 | (goto-char (point-min)) | ||
| 1503 | (while (re-search-forward (concat "^<<<<<<< " | ||
| 1504 | (regexp-quote file-name) "\n") nil t) | ||
| 1505 | (setq found t) | ||
| 1506 | (replace-match "") | ||
| 1507 | (if (not (re-search-forward "^=======\n" nil t)) | ||
| 1508 | (error "Malformed conflict marker")) | ||
| 1509 | (replace-match "") | ||
| 1510 | (let ((start (point))) | ||
| 1511 | (if (not (re-search-forward "^>>>>>>> [0-9.]+\n" nil t)) | ||
| 1512 | (error "Malformed conflict marker")) | ||
| 1513 | (delete-region start (point)))) | ||
| 1514 | (if (not found) | ||
| 1515 | (progn | ||
| 1516 | (kill-buffer your-buffer) | ||
| 1517 | (kill-buffer other-buffer) | ||
| 1518 | (error "No conflict markers found"))) | ||
| 1519 | (set-buffer other-buffer) | ||
| 1520 | (erase-buffer) | ||
| 1521 | (insert-buffer result-buffer) | ||
| 1522 | (goto-char (point-min)) | ||
| 1523 | (while (re-search-forward (concat "^<<<<<<< " | ||
| 1524 | (regexp-quote file-name) "\n") nil t) | ||
| 1525 | (let ((start (match-beginning 0))) | ||
| 1526 | (if (not (re-search-forward "^=======\n" nil t)) | ||
| 1527 | (error "Malformed conflict marker")) | ||
| 1528 | (delete-region start (point)) | ||
| 1529 | (if (not (re-search-forward "^>>>>>>> [0-9.]+\n" nil t)) | ||
| 1530 | (error "Malformed conflict marker")) | ||
| 1531 | (replace-match ""))) | ||
| 1532 | (let ((config (current-window-configuration)) | ||
| 1533 | (ediff-default-variant 'default-B)) | ||
| 1534 | |||
| 1535 | ;; Fire up ediff. | ||
| 1536 | |||
| 1537 | (set-buffer (ediff-merge-buffers your-buffer other-buffer)) | ||
| 1538 | |||
| 1539 | ;; Ediff is now set up, and we are in the control buffer. | ||
| 1540 | ;; Do a few further adjustments and take precautions for exit. | ||
| 1541 | |||
| 1542 | (make-local-variable 'vc-ediff-windows) | ||
| 1543 | (setq vc-ediff-windows config) | ||
| 1544 | (make-local-variable 'vc-ediff-result) | ||
| 1545 | (setq vc-ediff-result result-buffer) | ||
| 1546 | (make-local-variable 'ediff-quit-hook) | ||
| 1547 | (setq ediff-quit-hook | ||
| 1548 | (function | ||
| 1549 | (lambda () | ||
| 1550 | (let ((buffer-A ediff-buffer-A) | ||
| 1551 | (buffer-B ediff-buffer-B) | ||
| 1552 | (buffer-C ediff-buffer-C) | ||
| 1553 | (result vc-ediff-result) | ||
| 1554 | (windows vc-ediff-windows)) | ||
| 1555 | (ediff-cleanup-mess) | ||
| 1556 | (set-buffer result) | ||
| 1557 | (erase-buffer) | ||
| 1558 | (insert-buffer buffer-C) | ||
| 1559 | (kill-buffer buffer-A) | ||
| 1560 | (kill-buffer buffer-B) | ||
| 1561 | (kill-buffer buffer-C) | ||
| 1562 | (set-window-configuration windows) | ||
| 1563 | (message "Conflict resolution finished; you may save the buffer"))))) | ||
| 1564 | (message "Please resolve conflicts now; exit ediff when done") | ||
| 1565 | nil)))) | ||
| 1566 | |||
| 1491 | ;; The VC directory major mode. Coopt Dired for this. | 1567 | ;; The VC directory major mode. Coopt Dired for this. |
| 1492 | ;; All VC commands get mapped into logical equivalents. | 1568 | ;; All VC commands get mapped into logical equivalents. |
| 1493 | 1569 | ||
| @@ -1850,11 +1926,11 @@ locked are updated to the latest versions." | |||
| 1850 | 1926 | ||
| 1851 | ;;;###autoload | 1927 | ;;;###autoload |
| 1852 | (defun vc-revert-buffer () | 1928 | (defun vc-revert-buffer () |
| 1853 | "Revert the current buffer's file back to the latest checked-in version. | 1929 | "Revert the current buffer's file back to the version it was based on. |
| 1854 | This asks for confirmation if the buffer contents are not identical | 1930 | This asks for confirmation if the buffer contents are not identical |
| 1855 | to that version. | 1931 | to that version. Note that for RCS and CVS, this function does not |
| 1856 | If the back-end is CVS, this will give you the most recent revision of | 1932 | automatically pick up newer changes found in the master file; |
| 1857 | the file on the branch you are editing." | 1933 | use C-u \\[vc-next-action] RET to do so." |
| 1858 | (interactive) | 1934 | (interactive) |
| 1859 | (if vc-dired-mode | 1935 | (if vc-dired-mode |
| 1860 | (find-file-other-window (dired-get-filename))) | 1936 | (find-file-other-window (dired-get-filename))) |
| @@ -2636,8 +2712,7 @@ THRESHOLD, nil otherwise" | |||
| 2636 | (message "Checking in %s...done" file)) | 2712 | (message "Checking in %s...done" file)) |
| 2637 | 2713 | ||
| 2638 | (defun vc-backend-revert (file) | 2714 | (defun vc-backend-revert (file) |
| 2639 | ;; Revert file to latest checked-in version. | 2715 | ;; Revert file to the version it was based on. |
| 2640 | ;; (for RCS, to workfile version) | ||
| 2641 | (message "Reverting %s..." file) | 2716 | (message "Reverting %s..." file) |
| 2642 | (vc-file-clear-masterprops file) | 2717 | (vc-file-clear-masterprops file) |
| 2643 | (vc-backend-dispatch | 2718 | (vc-backend-dispatch |
| @@ -2645,14 +2720,19 @@ THRESHOLD, nil otherwise" | |||
| 2645 | ;; SCCS | 2720 | ;; SCCS |
| 2646 | (progn | 2721 | (progn |
| 2647 | (vc-do-command nil 0 "unget" file 'MASTER nil) | 2722 | (vc-do-command nil 0 "unget" file 'MASTER nil) |
| 2648 | (vc-do-command nil 0 "get" file 'MASTER nil)) | 2723 | (vc-do-command nil 0 "get" file 'MASTER nil) |
| 2724 | ;; Checking out explicit versions is not supported under SCCS, yet. | ||
| 2725 | ;; We always "revert" to the latest version; therefore | ||
| 2726 | ;; vc-workfile-version is cleared here so that it gets recomputed. | ||
| 2727 | (vc-file-setprop 'vc-workfile-version nil)) | ||
| 2649 | ;; RCS | 2728 | ;; RCS |
| 2650 | (vc-do-command nil 0 "co" file 'MASTER | 2729 | (vc-do-command nil 0 "co" file 'MASTER |
| 2651 | "-f" (concat "-u" (vc-workfile-version file))) | 2730 | "-f" (concat "-u" (vc-workfile-version file))) |
| 2652 | ;; CVS | 2731 | ;; CVS |
| 2653 | (progn | 2732 | (progn |
| 2654 | (delete-file file) | 2733 | (delete-file file) |
| 2655 | (vc-do-command nil 0 "cvs" file 'WORKFILE "update"))) | 2734 | (vc-do-command nil 0 "cvs" file 'WORKFILE "update" |
| 2735 | (concat "-r" (vc-workfile-version file))))) | ||
| 2656 | (vc-file-setprop file 'vc-locking-user 'none) | 2736 | (vc-file-setprop file 'vc-locking-user 'none) |
| 2657 | (vc-file-setprop file 'vc-checkout-time (nth 5 (file-attributes file))) | 2737 | (vc-file-setprop file 'vc-checkout-time (nth 5 (file-attributes file))) |
| 2658 | (message "Reverting %s...done" file) | 2738 | (message "Reverting %s...done" file) |