diff options
| author | André Spiegel | 1998-04-05 18:45:06 +0000 |
|---|---|---|
| committer | André Spiegel | 1998-04-05 18:45:06 +0000 |
| commit | ccb141e8e1d5584d29ff0e41c637cfc0a64177e6 (patch) | |
| tree | ee21dc003276555b4e30334c98cb6eb4f965df8a | |
| parent | e27827ddcc91e77f68c3af495354cb61229b7319 (diff) | |
| download | emacs-ccb141e8e1d5584d29ff0e41c637cfc0a64177e6.tar.gz emacs-ccb141e8e1d5584d29ff0e41c637cfc0a64177e6.zip | |
(vc-merge, vc-backend-merge): New functions.
(vc-resolve-conflicts): Added optional parameters for buffer names.
(vc-branch-p): New function.
| -rw-r--r-- | lisp/vc.el | 84 |
1 files changed, 80 insertions, 4 deletions
diff --git a/lisp/vc.el b/lisp/vc.el index 503e4f6e290..4751b0de090 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.216 1998/04/04 05:22:37 rms Exp spiegel $ | 8 | ;; $Id: vc.el,v 1.217 1998/04/05 18:43:15 spiegel Exp spiegel $ |
| 9 | 9 | ||
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | 11 | ||
| @@ -388,6 +388,10 @@ If nil, VC itself computes this value when it is first needed." | |||
| 388 | ;; return t if REV is a revision on the trunk | 388 | ;; return t if REV is a revision on the trunk |
| 389 | (not (eq nil (string-match "\\`[0-9]+\\.[0-9]+\\'" rev)))) | 389 | (not (eq nil (string-match "\\`[0-9]+\\.[0-9]+\\'" rev)))) |
| 390 | 390 | ||
| 391 | (defun vc-branch-p (rev) | ||
| 392 | ;; return t if REV is a branch revision | ||
| 393 | (not (eq nil (string-match "\\`[0-9]+\\(\\.[0-9]+\\.[0-9]+\\)*\\'" rev)))) | ||
| 394 | |||
| 391 | (defun vc-branch-part (rev) | 395 | (defun vc-branch-part (rev) |
| 392 | ;; return the branch part of a revision number REV | 396 | ;; return the branch part of a revision number REV |
| 393 | (substring rev 0 (string-match "\\.[0-9]+\\'" rev))) | 397 | (substring rev 0 (string-match "\\.[0-9]+\\'" rev))) |
| @@ -1457,7 +1461,51 @@ the variable `vc-header-alist'." | |||
| 1457 | (vc-restore-buffer-context context))) | 1461 | (vc-restore-buffer-context context))) |
| 1458 | 1462 | ||
| 1459 | ;;;###autoload | 1463 | ;;;###autoload |
| 1460 | (defun vc-resolve-conflicts () | 1464 | (defun vc-merge () |
| 1465 | (interactive) | ||
| 1466 | (vc-ensure-vc-buffer) | ||
| 1467 | (vc-buffer-sync) | ||
| 1468 | (let* ((file buffer-file-name) | ||
| 1469 | (backend (vc-backend file)) | ||
| 1470 | first-version second-version locking-user) | ||
| 1471 | (if (eq backend 'SCCS) | ||
| 1472 | (error "Sorry, merging is not implemented for SCCS") | ||
| 1473 | (setq locking-user (vc-locking-user file)) | ||
| 1474 | (if (eq (vc-checkout-model file) 'manual) | ||
| 1475 | (if (not locking-user) | ||
| 1476 | (if (not (y-or-n-p | ||
| 1477 | (format "File must be %s for merging. %s now? " | ||
| 1478 | (if (eq backend 'RCS) "locked" "writable") | ||
| 1479 | (if (eq backend 'RCS) "Lock" "Check out")))) | ||
| 1480 | (error "Merge aborted") | ||
| 1481 | (vc-checkout file t)) | ||
| 1482 | (if (not (string= locking-user (vc-user-login-name))) | ||
| 1483 | (error "File is locked by %s" locking-user)))) | ||
| 1484 | (setq first-version (read-string "Branch or version to merge from: ")) | ||
| 1485 | (if (and (>= (elt first-version 0) ?0) | ||
| 1486 | (<= (elt first-version 0) ?9)) | ||
| 1487 | (if (not (vc-branch-p first-version)) | ||
| 1488 | (setq second-version | ||
| 1489 | (read-string "Second version: " | ||
| 1490 | (concat (vc-branch-part first-version) "."))) | ||
| 1491 | ;; We want to merge an entire branch. Set versions | ||
| 1492 | ;; accordingly, so that vc-backend-merge understands us. | ||
| 1493 | (setq second-version first-version) | ||
| 1494 | ;; first-version must be the starting point of the branch | ||
| 1495 | (setq first-version (vc-branch-part first-version)))) | ||
| 1496 | (let ((status (vc-backend-merge file first-version second-version))) | ||
| 1497 | (if (and (eq (vc-checkout-model file) 'implicit) | ||
| 1498 | (not (vc-locking-user file))) | ||
| 1499 | (vc-file-setprop file 'vc-locking-user nil)) | ||
| 1500 | (vc-resynch-buffer file t t) | ||
| 1501 | (if (not (zerop status)) | ||
| 1502 | (if (y-or-n-p "Conflicts detected. Resolve them now? ") | ||
| 1503 | (vc-resolve-conflicts "WORKFILE" "MERGE SOURCE") | ||
| 1504 | (message "File contains conflict markers")) | ||
| 1505 | (message "Merge successful")))))) | ||
| 1506 | |||
| 1507 | ;;;###autoload | ||
| 1508 | (defun vc-resolve-conflicts (&optional name-A name-B) | ||
| 1461 | "Invoke ediff to resolve conflicts in the current buffer. | 1509 | "Invoke ediff to resolve conflicts in the current buffer. |
| 1462 | The conflicts must be marked with rcsmerge conflict markers." | 1510 | The conflicts must be marked with rcsmerge conflict markers." |
| 1463 | (interactive) | 1511 | (interactive) |
| @@ -1465,9 +1513,11 @@ The conflicts must be marked with rcsmerge conflict markers." | |||
| 1465 | (let* ((found nil) | 1513 | (let* ((found nil) |
| 1466 | (file-name (file-name-nondirectory buffer-file-name)) | 1514 | (file-name (file-name-nondirectory buffer-file-name)) |
| 1467 | (your-buffer (generate-new-buffer | 1515 | (your-buffer (generate-new-buffer |
| 1468 | (concat "*" file-name " WORKFILE*"))) | 1516 | (concat "*" file-name |
| 1517 | " " (or name-A "WORKFILE") "*"))) | ||
| 1469 | (other-buffer (generate-new-buffer | 1518 | (other-buffer (generate-new-buffer |
| 1470 | (concat "*" file-name " CHECKED-IN*"))) | 1519 | (concat "*" file-name |
| 1520 | " " (or name-B "CHECKED-IN") "*"))) | ||
| 1471 | (result-buffer (current-buffer))) | 1521 | (result-buffer (current-buffer))) |
| 1472 | (save-excursion | 1522 | (save-excursion |
| 1473 | (set-buffer your-buffer) | 1523 | (set-buffer your-buffer) |
| @@ -2802,6 +2852,32 @@ THRESHOLD, nil otherwise" | |||
| 2802 | (error "Couldn't analyze cvs update result")))) | 2852 | (error "Couldn't analyze cvs update result")))) |
| 2803 | (message "Merging changes into %s...done" file))) | 2853 | (message "Merging changes into %s...done" file))) |
| 2804 | 2854 | ||
| 2855 | (defun vc-backend-merge (file first-version &optional second-version) | ||
| 2856 | ;; Merge the changes between FIRST-VERSION and SECOND-VERSION into | ||
| 2857 | ;; the current working copy of FILE. It is assumed that FILE is | ||
| 2858 | ;; locked and writable (vc-merge ensures this). | ||
| 2859 | (vc-backend-dispatch file | ||
| 2860 | ;; SCCS | ||
| 2861 | (error "Sorry, merging is not implemented for SCCS") | ||
| 2862 | ;; RCS | ||
| 2863 | (vc-do-command nil 1 "rcsmerge" file 'MASTER | ||
| 2864 | "-kk" ;; ignore keyword conflicts | ||
| 2865 | (concat "-r" first-version) | ||
| 2866 | (if second-version (concat "-r" second-version))) | ||
| 2867 | ;; CVS | ||
| 2868 | (progn | ||
| 2869 | (vc-do-command nil 0 "cvs" file 'WORKFILE | ||
| 2870 | "update" "-kk" | ||
| 2871 | (concat "-j" first-version) | ||
| 2872 | (concat "-j" second-version)) | ||
| 2873 | (save-excursion | ||
| 2874 | (set-buffer (get-buffer "*vc*")) | ||
| 2875 | (goto-char (point-min)) | ||
| 2876 | (if (re-search-forward "conflicts during merge" nil t) | ||
| 2877 | 1 ;; signal error | ||
| 2878 | 0 ;; signal success | ||
| 2879 | ))))) | ||
| 2880 | |||
| 2805 | (defun vc-check-headers () | 2881 | (defun vc-check-headers () |
| 2806 | "Check if the current file has any headers in it." | 2882 | "Check if the current file has any headers in it." |
| 2807 | (interactive) | 2883 | (interactive) |