diff options
| author | André Spiegel | 1997-07-18 16:06:57 +0000 |
|---|---|---|
| committer | André Spiegel | 1997-07-18 16:06:57 +0000 |
| commit | d5859f32d974ee27b859759d9a885b679048d06d (patch) | |
| tree | 01db854caaee9abf8c3222c4fdc8eaf58352ef18 | |
| parent | 702220f3d8aaad081030fe0a337a5698f4190dc5 (diff) | |
| download | emacs-d5859f32d974ee27b859759d9a885b679048d06d.tar.gz emacs-d5859f32d974ee27b859759d9a885b679048d06d.zip | |
(vc-diff): If file is unchanged, ask for the version
number to compare with.
(vc-retrieve-snapshot): If no NAME is specified, check out
latest versions of all unlocked files.
(vc-next-action-on-file): For CVS files with implicit checkout: if
unmodified, don't do anything.
(vc-clear-headers): Regexp more restricted, so as not to destroy file
contents by mistake.
(vc-backend-merge-news): Better analysis of status reported by CVS.
Set file properties accordingly.
| -rw-r--r-- | lisp/vc.el | 166 |
1 files changed, 109 insertions, 57 deletions
diff --git a/lisp/vc.el b/lisp/vc.el index f88a36871a2..3c160132af2 100644 --- a/lisp/vc.el +++ b/lisp/vc.el | |||
| @@ -740,12 +740,19 @@ to an optional list of FLAGS." | |||
| 740 | (vc-resynch-buffer file t (not (buffer-modified-p buffer))))) | 740 | (vc-resynch-buffer file t (not (buffer-modified-p buffer))))) |
| 741 | (error "%s needs update" (buffer-name)))) | 741 | (error "%s needs update" (buffer-name)))) |
| 742 | 742 | ||
| 743 | ;; For CVS files with implicit checkout: if unmodified, don't do anything | ||
| 744 | ((and (eq vc-type 'CVS) | ||
| 745 | (eq (vc-checkout-model file) 'implicit) | ||
| 746 | (not (vc-locking-user file)) | ||
| 747 | (not verbose)) | ||
| 748 | (message "%s is up to date" (buffer-name))) | ||
| 749 | |||
| 743 | ;; If there is no lock on the file, assert one and get it. | 750 | ;; If there is no lock on the file, assert one and get it. |
| 744 | ;; (With implicit checkout, make sure not to lose unsaved changes.) | 751 | ((not (setq owner (vc-locking-user file))) |
| 745 | ((progn (and (eq (vc-checkout-model file) 'implicit) | 752 | ;; With implicit checkout, make sure not to lose unsaved changes. |
| 746 | (buffer-modified-p buffer) | 753 | (and (eq (vc-checkout-model file) 'implicit) |
| 747 | (vc-buffer-sync)) | 754 | (buffer-modified-p buffer) |
| 748 | (not (setq owner (vc-locking-user file)))) | 755 | (vc-buffer-sync)) |
| 749 | (if (and vc-checkout-carefully | 756 | (if (and vc-checkout-carefully |
| 750 | (not (vc-workfile-unchanged-p file t))) | 757 | (not (vc-workfile-unchanged-p file t))) |
| 751 | (if (save-window-excursion | 758 | (if (save-window-excursion |
| @@ -1246,30 +1253,33 @@ and two version designators specifying which versions to compare." | |||
| 1246 | "There is no version-control master associated with this buffer")) | 1253 | "There is no version-control master associated with this buffer")) |
| 1247 | (let ((file buffer-file-name) | 1254 | (let ((file buffer-file-name) |
| 1248 | unchanged) | 1255 | unchanged) |
| 1249 | (or (and file (vc-name file)) | 1256 | (if (not (vc-locking-user file)) |
| 1250 | (vc-registration-error file)) | 1257 | ;; if the file is not locked, ask for older version to compare with |
| 1251 | (vc-buffer-sync not-urgent) | 1258 | (let ((old (read-string |
| 1252 | (setq unchanged (vc-workfile-unchanged-p buffer-file-name)) | 1259 | "File is unchanged; version to compare with: "))) |
| 1253 | (if unchanged | 1260 | (vc-version-diff file old "")) |
| 1254 | (message "No changes to %s since latest version" file) | 1261 | (vc-buffer-sync not-urgent) |
| 1255 | (vc-backend-diff file) | 1262 | (setq unchanged (vc-workfile-unchanged-p buffer-file-name)) |
| 1256 | ;; Ideally, we'd like at this point to parse the diff so that | 1263 | (if unchanged |
| 1257 | ;; the buffer effectively goes into compilation mode and we | 1264 | (message "No changes to %s since latest version" file) |
| 1258 | ;; can visit the old and new change locations via next-error. | 1265 | (vc-backend-diff file) |
| 1259 | ;; Unfortunately, this is just too painful to do. The basic | 1266 | ;; Ideally, we'd like at this point to parse the diff so that |
| 1260 | ;; problem is that the `old' file doesn't exist to be | 1267 | ;; the buffer effectively goes into compilation mode and we |
| 1261 | ;; visited. This plays hell with numerous assumptions in | 1268 | ;; can visit the old and new change locations via next-error. |
| 1262 | ;; the diff.el and compile.el machinery. | 1269 | ;; Unfortunately, this is just too painful to do. The basic |
| 1263 | (set-buffer "*vc-diff*") | 1270 | ;; problem is that the `old' file doesn't exist to be |
| 1264 | (setq default-directory (file-name-directory file)) | 1271 | ;; visited. This plays hell with numerous assumptions in |
| 1265 | (if (= 0 (buffer-size)) | 1272 | ;; the diff.el and compile.el machinery. |
| 1266 | (progn | 1273 | (set-buffer "*vc-diff*") |
| 1267 | (setq unchanged t) | 1274 | (setq default-directory (file-name-directory file)) |
| 1268 | (message "No changes to %s since latest version" file)) | 1275 | (if (= 0 (buffer-size)) |
| 1269 | (pop-to-buffer "*vc-diff*") | 1276 | (progn |
| 1270 | (goto-char (point-min)) | 1277 | (setq unchanged t) |
| 1271 | (shrink-window-if-larger-than-buffer))) | 1278 | (message "No changes to %s since latest version" file)) |
| 1272 | (not unchanged)))) | 1279 | (pop-to-buffer "*vc-diff*") |
| 1280 | (goto-char (point-min)) | ||
| 1281 | (shrink-window-if-larger-than-buffer))) | ||
| 1282 | (not unchanged))))) | ||
| 1273 | 1283 | ||
| 1274 | (defun vc-version-diff (file rel1 rel2) | 1284 | (defun vc-version-diff (file rel1 rel2) |
| 1275 | "For FILE, report diffs between two stored versions REL1 and REL2 of it. | 1285 | "For FILE, report diffs between two stored versions REL1 and REL2 of it. |
| @@ -1369,9 +1379,13 @@ the variable `vc-header-alist'." | |||
| 1369 | ;; Clear all version headers in the current buffer, i.e. reset them | 1379 | ;; Clear all version headers in the current buffer, i.e. reset them |
| 1370 | ;; to the nonexpanded form. Only implemented for RCS, yet. | 1380 | ;; to the nonexpanded form. Only implemented for RCS, yet. |
| 1371 | ;; Don't lose point and mark during this. | 1381 | ;; Don't lose point and mark during this. |
| 1372 | (let ((context (vc-buffer-context))) | 1382 | (let ((context (vc-buffer-context)) |
| 1383 | (case-fold-search nil)) | ||
| 1373 | (goto-char (point-min)) | 1384 | (goto-char (point-min)) |
| 1374 | (while (re-search-forward "\\$\\([A-Za-z]+\\): [^\\$]+\\$" nil t) | 1385 | (while (re-search-forward |
| 1386 | (concat "\\$\\(Author\\|Date\\|Header\\|Id\\|Locker\\|Name\\|" | ||
| 1387 | "RCSfile\\|Revision\\|Source\\|State\\): [^\\$\\n]+\\$") | ||
| 1388 | nil t) | ||
| 1375 | (replace-match "$\\1$")) | 1389 | (replace-match "$\\1$")) |
| 1376 | (vc-restore-buffer-context context))) | 1390 | (vc-restore-buffer-context context))) |
| 1377 | 1391 | ||
| @@ -1651,25 +1665,36 @@ version becomes part of the named configuration." | |||
| 1651 | 1665 | ||
| 1652 | ;;;###autoload | 1666 | ;;;###autoload |
| 1653 | (defun vc-retrieve-snapshot (name) | 1667 | (defun vc-retrieve-snapshot (name) |
| 1654 | "Retrieve the snapshot called NAME. | 1668 | "Retrieve the snapshot called NAME, or latest versions if NAME is empty. |
| 1655 | This function fails if any files are locked at or below the current directory | 1669 | When retrieving a snapshot, there must not be any locked files at or below |
| 1656 | Otherwise, all registered files are checked out (unlocked) at their version | 1670 | the current directory. If none are locked, all registered files are |
| 1657 | levels in the snapshot." | 1671 | checked out (unlocked) at their version levels in the snapshot NAME. |
| 1658 | (interactive "sSnapshot name to retrieve: ") | 1672 | If NAME is the empty string, all registered files that are not currently |
| 1659 | (let ((result (vc-snapshot-precondition)) | 1673 | locked are updated to the latest versions." |
| 1660 | (update nil)) | 1674 | (interactive "sSnapshot name to retrieve (default latest versions): ") |
| 1661 | (if (stringp result) | 1675 | (let ((update (yes-or-no-p "Update any affected buffers? "))) |
| 1662 | (error "File %s is locked" result) | 1676 | (if (string= name "") |
| 1663 | (if (eq result 'visited) | 1677 | (progn |
| 1664 | (setq update (yes-or-no-p "Update the affected buffers? "))) | 1678 | (vc-file-tree-walk |
| 1665 | (vc-file-tree-walk | 1679 | default-directory |
| 1666 | default-directory | 1680 | (function (lambda (f) (and |
| 1667 | (function (lambda (f) (and | 1681 | (vc-registered f) |
| 1668 | (vc-name f) | 1682 | (not (vc-locking-user f)) |
| 1669 | (vc-error-occurred | 1683 | (vc-error-occurred |
| 1670 | (vc-backend-checkout f nil name) | 1684 | (vc-backend-checkout f nil "") |
| 1671 | (if update (vc-resynch-buffer f t t))))))) | 1685 | (if update (vc-resynch-buffer f t t)))))))) |
| 1672 | ))) | 1686 | (let ((result (vc-snapshot-precondition))) |
| 1687 | (if (stringp result) | ||
| 1688 | (error "File %s is locked" result) | ||
| 1689 | (setq update (and (eq result 'visited) update)) | ||
| 1690 | (vc-file-tree-walk | ||
| 1691 | default-directory | ||
| 1692 | (function (lambda (f) (and | ||
| 1693 | (vc-name f) | ||
| 1694 | (vc-error-occurred | ||
| 1695 | (vc-backend-checkout f nil name) | ||
| 1696 | (if update (vc-resynch-buffer f t t))))))) | ||
| 1697 | ))))) | ||
| 1673 | 1698 | ||
| 1674 | ;; Miscellaneous other entry points | 1699 | ;; Miscellaneous other entry points |
| 1675 | 1700 | ||
| @@ -2651,16 +2676,43 @@ Return the first cons which CAR is not less than THRESHOLD, nil otherwise" | |||
| 2651 | (vc-file-clear-masterprops file) | 2676 | (vc-file-clear-masterprops file) |
| 2652 | (vc-file-setprop file 'vc-workfile-version nil) | 2677 | (vc-file-setprop file 'vc-workfile-version nil) |
| 2653 | (vc-file-setprop file 'vc-locking-user nil) | 2678 | (vc-file-setprop file 'vc-locking-user nil) |
| 2679 | (vc-file-setprop file 'vc-checkout-time nil) | ||
| 2654 | (vc-do-command nil 0 "cvs" file 'WORKFILE "update") | 2680 | (vc-do-command nil 0 "cvs" file 'WORKFILE "update") |
| 2655 | ;; CVS doesn't return an error code if conflicts are detected. | 2681 | ;; Analyze the merge result reported by CVS, and set |
| 2656 | ;; Since we want to warn the user about it (and possibly start | 2682 | ;; file properties accordingly. |
| 2657 | ;; emerge later), scan the output and see if this occurred. | ||
| 2658 | (set-buffer (get-buffer "*vc*")) | 2683 | (set-buffer (get-buffer "*vc*")) |
| 2659 | (goto-char (point-min)) | 2684 | (goto-char (point-min)) |
| 2660 | (if (re-search-forward "^cvs update: conflicts found in .*" nil t) | 2685 | ;; get new workfile version |
| 2661 | 1 ;; error code for caller | 2686 | (if (re-search-forward (concat "^Merging differences between " |
| 2662 | 0 ;; no conflict detected | 2687 | "[01234567890.]* and " |
| 2663 | ))) | 2688 | "\\([01234567890.]*\\) into") |
| 2689 | nil t) | ||
| 2690 | (vc-file-setprop file 'vc-workfile-version (match-string 1))) | ||
| 2691 | ;; get file status | ||
| 2692 | (if (re-search-forward | ||
| 2693 | (concat "^\\([CMU]\\) " | ||
| 2694 | (regexp-quote (file-name-nondirectory file))) | ||
| 2695 | nil t) | ||
| 2696 | (cond | ||
| 2697 | ;; Merge successful, we are in sync with repository now | ||
| 2698 | ((string= (match-string 1) "U") | ||
| 2699 | (vc-file-setprop file 'vc-locking-user 'none) | ||
| 2700 | (vc-file-setprop file 'vc-checkout-time | ||
| 2701 | (nth 5 (file-attributes file))) | ||
| 2702 | 0) ;; indicate success to the caller | ||
| 2703 | ;; Merge successful, but our own changes are still in the file | ||
| 2704 | ((string= (match-string 1) "M") | ||
| 2705 | (vc-file-setprop file 'vc-locking-user (vc-file-owner file)) | ||
| 2706 | (vc-file-setprop file 'vc-checkout-time 0) | ||
| 2707 | 0) ;; indicate success to the caller | ||
| 2708 | ;; Conflicts detected! | ||
| 2709 | ((string= (match-string 1) "C") | ||
| 2710 | (vc-file-setprop file 'vc-locking-user (vc-file-owner file)) | ||
| 2711 | (vc-file-setprop file 'vc-checkout-time 0) | ||
| 2712 | 1) ;; signal the error to the caller | ||
| 2713 | ) | ||
| 2714 | (pop-to-buffer "*vc*") | ||
| 2715 | (error "Couldn't analyze cvs update result")))) | ||
| 2664 | (message "Merging changes into %s...done" file))) | 2716 | (message "Merging changes into %s...done" file))) |
| 2665 | 2717 | ||
| 2666 | (defun vc-check-headers () | 2718 | (defun vc-check-headers () |