Mercurial > emacs
comparison lisp/vc.el @ 94481:ad6c174910db
Make `checkout-model' apply to filesets.
* vc-hooks.el (vc-checkout-model): Rewrite.
(vc-before-save, vc-after-save): Adjust callers accordingly.
* vc.el (vc-editable-p, vc-next-action, vc-checkout, vc-update)
(vc-transfer-file): Adjust callers accordingly.
* vc-rcs.el (vc-rcs-checkout-model): Adjust arg.
(vc-rcs-state, vc-rcs-state-heuristic, vc-rcs-receive-file)
(vc-rcs-checkout, vc-rcs-fetch-master-state): Use vc-rcs-checkout-model
instead of vc-checkout-model.
* vc-mcvs.el (vc-mcvs-revert):
Use vc-mcvs-checkout-model i.s.o vc-checkout-model.
* vc-cvs.el (vc-cvs-checkout-model): Adjust arg.
(vc-cvs-revert): Use vc-cvs-checkout-model i.s.o vc-checkout-model.
* vc-svn.el (vc-svn-checkout-model):
* vc-hg.el (vc-hg-checkout-model):
* vc-git.el (vc-git-checkout-model):
* vc-bzr.el (vc-bzr-checkout-model): Adjust arg.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Tue, 29 Apr 2008 15:32:56 +0000 |
parents | 618e87ee72c0 |
children | d3100c0eddb7 |
comparison
equal
deleted
inserted
replaced
94480:cf998cc4d006 | 94481:ad6c174910db |
---|---|
226 ;; Return non-nil if the working revision of FILE is the latest revision | 226 ;; Return non-nil if the working revision of FILE is the latest revision |
227 ;; on its branch (many VCSes call this the 'tip' or 'head' revision). | 227 ;; on its branch (many VCSes call this the 'tip' or 'head' revision). |
228 ;; The default implementation always returns t, which means that | 228 ;; The default implementation always returns t, which means that |
229 ;; working with non-current revisions is not supported by default. | 229 ;; working with non-current revisions is not supported by default. |
230 ;; | 230 ;; |
231 ;; * checkout-model (file) | 231 ;; * checkout-model (files) |
232 ;; | 232 ;; |
233 ;; Indicate whether FILE needs to be "checked out" before it can be | 233 ;; Indicate whether FILES need to be "checked out" before they can be |
234 ;; edited. See `vc-checkout-model' for a list of possible values. | 234 ;; edited. See `vc-checkout-model' for a list of possible values. |
235 ;; | 235 ;; |
236 ;; - workfile-unchanged-p (file) | 236 ;; - workfile-unchanged-p (file) |
237 ;; | 237 ;; |
238 ;; Return non-nil if FILE is unchanged from the working revision. | 238 ;; Return non-nil if FILE is unchanged from the working revision. |
1504 (if (not buffer-file-name) | 1504 (if (not buffer-file-name) |
1505 (error "Buffer %s is not associated with a file" (buffer-name)) | 1505 (error "Buffer %s is not associated with a file" (buffer-name)) |
1506 (unless (vc-backend buffer-file-name) | 1506 (unless (vc-backend buffer-file-name) |
1507 (error "File %s is not under version control" buffer-file-name)))))) | 1507 (error "File %s is not under version control" buffer-file-name)))))) |
1508 | 1508 |
1509 ;;; Support for the C-x v v command. This is where all the single-file-oriented | 1509 ;;; Support for the C-x v v command. |
1510 ;;; code from before the fileset rewrite lives. | 1510 ;; This is where all the single-file-oriented code from before the fileset |
1511 ;; rewrite lives. | |
1511 | 1512 |
1512 (defsubst vc-editable-p (file) | 1513 (defsubst vc-editable-p (file) |
1513 "Return non-nil if FILE can be edited." | 1514 "Return non-nil if FILE can be edited." |
1514 (or (eq (vc-checkout-model file) 'implicit) | 1515 (let ((backend (vc-backend file))) |
1515 (memq (vc-state file) '(edited needs-merge conflict)))) | 1516 (and backend |
1517 (or (eq (vc-checkout-model backend file) 'implicit) | |
1518 (memq (vc-state file) '(edited needs-merge conflict)))))) | |
1516 | 1519 |
1517 (defun vc-revert-buffer-internal (&optional arg no-confirm) | 1520 (defun vc-revert-buffer-internal (&optional arg no-confirm) |
1518 "Revert buffer, keeping point and mark where user expects them. | 1521 "Revert buffer, keeping point and mark where user expects them. |
1519 Try to be clever in the face of changes due to expanded version-control | 1522 Try to be clever in the face of changes due to expanded version-control |
1520 key words. This is important for typeahead to work as expected. | 1523 key words. This is important for typeahead to work as expected. |
1583 with the logmessage as change commentary. A writable file is retained. | 1586 with the logmessage as change commentary. A writable file is retained. |
1584 If the repository file is changed, you are asked if you want to | 1587 If the repository file is changed, you are asked if you want to |
1585 merge in the changes into your working copy." | 1588 merge in the changes into your working copy." |
1586 (interactive "P") | 1589 (interactive "P") |
1587 (let* ((vc-fileset (vc-deduce-fileset nil t)) | 1590 (let* ((vc-fileset (vc-deduce-fileset nil t)) |
1591 (backend (car vc-fileset)) | |
1588 (files (cdr vc-fileset)) | 1592 (files (cdr vc-fileset)) |
1589 state | 1593 state |
1590 model | 1594 (model (vc-checkout-model backend files)) |
1591 revision) | 1595 revision) |
1592 ;; Check if there's at least one file present, and get `state' and | 1596 ;; Check if there's at least one file present, and get `state' and |
1593 ;; `model' from it. | 1597 ;; `model' from it. |
1594 ;;FIXME: do something about the case when only directories are | 1598 ;;FIXME: do something about the case when only directories are |
1595 ;; present, or `files' is nil. | 1599 ;; present, or `files' is nil. |
1596 (dolist (file files) | 1600 (dolist (file files) |
1597 (unless (file-directory-p file) | 1601 (unless (file-directory-p file) |
1598 (setq model (vc-checkout-model (car files))) | |
1599 (setq state (vc-state file)) | 1602 (setq state (vc-state file)) |
1600 (return))) | 1603 (return))) |
1601 | 1604 |
1602 ;; Verify that the fileset is homogeneous | 1605 ;; Verify that the fileset is homogeneous |
1603 (dolist (file (cdr files)) | 1606 (dolist (file (cdr files)) |
1604 ;; Ignore directories, they are compatible with anything. | 1607 ;; Ignore directories, they are compatible with anything. |
1605 (unless (file-directory-p file) | 1608 (unless (file-directory-p file) |
1606 (unless (vc-compatible-state (vc-state file) state) | 1609 (unless (vc-compatible-state (vc-state file) state) |
1607 (error "Fileset is in a mixed-up state")) | 1610 (error "Fileset is in a mixed-up state")) |
1608 (unless (eq (vc-checkout-model file) model) | 1611 (unless (eq (vc-checkout-model backend file) model) |
1609 (error "Fileset has mixed checkout models")))) | 1612 (error "Fileset has mixed checkout models")))) |
1610 ;; Check for buffers in the fileset not matching the on-disk contents. | 1613 ;; Check for buffers in the fileset not matching the on-disk contents. |
1611 (dolist (file files) | 1614 (dolist (file files) |
1612 (let ((visited (get-file-buffer file))) | 1615 (let ((visited (get-file-buffer file))) |
1613 (when visited | 1616 (when visited |
1930 (and writable | 1933 (and writable |
1931 (not rev) | 1934 (not rev) |
1932 (vc-call make-version-backups-p file) | 1935 (vc-call make-version-backups-p file) |
1933 (vc-up-to-date-p file) | 1936 (vc-up-to-date-p file) |
1934 (vc-make-version-backup file)) | 1937 (vc-make-version-backup file)) |
1935 (with-vc-properties | 1938 (let ((backend (vc-backend file))) |
1936 (list file) | 1939 (with-vc-properties (list file) |
1937 (condition-case err | 1940 (condition-case err |
1938 (vc-call checkout file writable rev) | 1941 (vc-call-backend 'checkout file writable rev) |
1939 (file-error | 1942 (file-error |
1940 ;; Maybe the backend is not installed ;-( | 1943 ;; Maybe the backend is not installed ;-( |
1941 (when writable | 1944 (when writable |
1942 (let ((buf (get-file-buffer file))) | 1945 (let ((buf (get-file-buffer file))) |
1943 (when buf (with-current-buffer buf (toggle-read-only -1))))) | 1946 (when buf (with-current-buffer buf (toggle-read-only -1))))) |
1944 (signal (car err) (cdr err)))) | 1947 (signal (car err) (cdr err)))) |
1945 `((vc-state . ,(if (or (eq (vc-checkout-model file) 'implicit) | 1948 `((vc-state . ,(if (or (eq (vc-checkout-model backend file) 'implicit) |
1946 (not writable)) | 1949 (not writable)) |
1947 (if (vc-call latest-on-branch-p file) | 1950 (if (vc-call latest-on-branch-p file) |
1948 'up-to-date | 1951 'up-to-date |
1949 'needs-patch) | 1952 'needs-patch) |
1950 'edited)) | 1953 'edited)) |
1951 (vc-checkout-time . ,(nth 5 (file-attributes file))))) | 1954 (vc-checkout-time . ,(nth 5 (file-attributes file)))))) |
1952 (vc-resynch-buffer file t t) | 1955 (vc-resynch-buffer file t t) |
1953 (run-hooks 'vc-checkout-hook)) | 1956 (run-hooks 'vc-checkout-hook)) |
1954 | 1957 |
1955 (defun vc-mark-resolved (files) | 1958 (defun vc-mark-resolved (files) |
1956 (with-vc-properties | 1959 (with-vc-properties |
3767 (when (let ((buf (get-file-buffer file))) | 3770 (when (let ((buf (get-file-buffer file))) |
3768 (and buf (buffer-modified-p buf))) | 3771 (and buf (buffer-modified-p buf))) |
3769 (error "Please kill or save all modified buffers before updating.")) | 3772 (error "Please kill or save all modified buffers before updating.")) |
3770 (if (vc-up-to-date-p file) | 3773 (if (vc-up-to-date-p file) |
3771 (vc-checkout file nil t) | 3774 (vc-checkout file nil t) |
3772 (if (eq (vc-checkout-model file) 'locking) | 3775 (if (eq (vc-checkout-model backend file) 'locking) |
3773 (if (eq (vc-state file) 'edited) | 3776 (if (eq (vc-state file) 'edited) |
3774 (error "%s" | 3777 (error "%s" |
3775 (substitute-command-keys | 3778 (substitute-command-keys |
3776 "File is locked--type \\[vc-revert] to discard changes")) | 3779 "File is locked--type \\[vc-revert] to discard changes")) |
3777 (error "Unexpected file state (%s) -- type %s" | 3780 (error "Unexpected file state (%s) -- type %s" |
3894 (when (y-or-n-p "Get base revision from master? ") | 3897 (when (y-or-n-p "Get base revision from master? ") |
3895 (vc-revert-file file)))) | 3898 (vc-revert-file file)))) |
3896 (vc-call-backend new-backend 'receive-file file rev)) | 3899 (vc-call-backend new-backend 'receive-file file rev)) |
3897 (when modified-file | 3900 (when modified-file |
3898 (vc-switch-backend file new-backend) | 3901 (vc-switch-backend file new-backend) |
3899 (unless (eq (vc-checkout-model file) 'implicit) | 3902 (unless (eq (vc-checkout-model new-backend file) 'implicit) |
3900 (vc-checkout file t nil)) | 3903 (vc-checkout file t nil)) |
3901 (rename-file modified-file file 'ok-if-already-exists) | 3904 (rename-file modified-file file 'ok-if-already-exists) |
3902 (vc-file-setprop file 'vc-checkout-time nil))))) | 3905 (vc-file-setprop file 'vc-checkout-time nil))))) |
3903 (when move | 3906 (when move |
3904 (vc-switch-backend file old-backend) | 3907 (vc-switch-backend file old-backend) |