diff options
| author | Dan Nicolaescu | 2008-06-25 03:19:14 +0000 |
|---|---|---|
| committer | Dan Nicolaescu | 2008-06-25 03:19:14 +0000 |
| commit | 2913a58d6ea483da82a580ae8180cf8b6554add3 (patch) | |
| tree | 984712c4994eba077767453f691d374ff2cdec96 | |
| parent | 40ef884328121bd551af787475d9b1c2c9c0f7cd (diff) | |
| download | emacs-2913a58d6ea483da82a580ae8180cf8b6554add3.tar.gz emacs-2913a58d6ea483da82a580ae8180cf8b6554add3.zip | |
* vc-dir.el (vc-dir-marked-only-files-and-states): Rename from
vc-dir-marked-only-files. Change the return value.
(vc-dir-child-files-and-states): Rename from vc-dir-child-files.
Change the return value.
(vc-dir-deduce-fileset): New function broken out from ...
* vc.el (vc-deduce-fileset): ... here and ...
(vc-deduce-fileset): ... here.
| -rw-r--r-- | lisp/ChangeLog | 8 | ||||
| -rw-r--r-- | lisp/vc-dir.el | 61 | ||||
| -rw-r--r-- | lisp/vc.el | 69 |
3 files changed, 94 insertions, 44 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index cfcab7b773c..35365ed4ce2 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,13 @@ | |||
| 1 | 2008-06-25 Dan Nicolaescu <dann@ics.uci.edu> | 1 | 2008-06-25 Dan Nicolaescu <dann@ics.uci.edu> |
| 2 | 2 | ||
| 3 | * vc-dir.el (vc-dir-marked-only-files-and-states): Rename from | ||
| 4 | vc-dir-marked-only-files. Change the return value. | ||
| 5 | (vc-dir-child-files-and-states): Rename from vc-dir-child-files. | ||
| 6 | Change the return value. | ||
| 7 | (vc-dir-deduce-fileset): New function broken out from ... | ||
| 8 | * vc.el (vc-deduce-fileset): ... here and ... | ||
| 9 | (vc-deduce-fileset): ... here. | ||
| 10 | |||
| 3 | * vc-svn.el (vc-annotate-parent-rev): Pacify byte compiler. | 11 | * vc-svn.el (vc-annotate-parent-rev): Pacify byte compiler. |
| 4 | 12 | ||
| 5 | 2008-06-25 Andreas Schwab <schwab@suse.de> | 13 | 2008-06-25 Andreas Schwab <schwab@suse.de> |
diff --git a/lisp/vc-dir.el b/lisp/vc-dir.el index 3db5366c230..7963d9cd388 100644 --- a/lisp/vc-dir.el +++ b/lisp/vc-dir.el | |||
| @@ -690,14 +690,16 @@ that share the same state." | |||
| 690 | (lambda (elem) (expand-file-name (vc-dir-fileinfo->name elem))) | 690 | (lambda (elem) (expand-file-name (vc-dir-fileinfo->name elem))) |
| 691 | (ewoc-collect vc-ewoc 'vc-dir-fileinfo->marked))) | 691 | (ewoc-collect vc-ewoc 'vc-dir-fileinfo->marked))) |
| 692 | 692 | ||
| 693 | (defun vc-dir-marked-only-files () | 693 | (defun vc-dir-marked-only-files-and-states () |
| 694 | "Return the list of marked files, for marked directories return child files." | 694 | "Return the list of conses (FILE . STATE) for the marked files. |
| 695 | For marked directories return the corresponding conses for the | ||
| 696 | child files." | ||
| 695 | (let ((crt (ewoc-nth vc-ewoc 0)) | 697 | (let ((crt (ewoc-nth vc-ewoc 0)) |
| 696 | result) | 698 | result) |
| 697 | (while crt | 699 | (while crt |
| 698 | (let ((crt-data (ewoc-data crt))) | 700 | (let ((crt-data (ewoc-data crt))) |
| 699 | (if (vc-dir-fileinfo->marked crt-data) | 701 | (if (vc-dir-fileinfo->marked crt-data) |
| 700 | ;; FIXME: use vc-dir-child-files here instead of duplicating it. | 702 | ;; FIXME: use vc-dir-child-files-and-states here instead of duplicating it. |
| 701 | (if (vc-dir-fileinfo->directory crt-data) | 703 | (if (vc-dir-fileinfo->directory crt-data) |
| 702 | (let* ((dir (vc-dir-fileinfo->directory crt-data)) | 704 | (let* ((dir (vc-dir-fileinfo->directory crt-data)) |
| 703 | (dirlen (length dir)) | 705 | (dirlen (length dir)) |
| @@ -709,15 +711,20 @@ that share the same state." | |||
| 709 | (setq data (ewoc-data crt)) | 711 | (setq data (ewoc-data crt)) |
| 710 | (vc-dir-node-directory crt)))) | 712 | (vc-dir-node-directory crt)))) |
| 711 | (unless (vc-dir-fileinfo->directory data) | 713 | (unless (vc-dir-fileinfo->directory data) |
| 712 | (push (expand-file-name (vc-dir-fileinfo->name data)) result)))) | 714 | (push |
| 713 | (push (expand-file-name (vc-dir-fileinfo->name crt-data)) result) | 715 | (cons (expand-file-name (vc-dir-fileinfo->name data)) |
| 716 | (vc-dir-fileinfo->state data)) | ||
| 717 | result)))) | ||
| 718 | (push (cons (expand-file-name (vc-dir-fileinfo->name crt-data)) | ||
| 719 | (vc-dir-fileinfo->state crt-data)) | ||
| 720 | result) | ||
| 714 | (setq crt (ewoc-next vc-ewoc crt))) | 721 | (setq crt (ewoc-next vc-ewoc crt))) |
| 715 | (setq crt (ewoc-next vc-ewoc crt))))) | 722 | (setq crt (ewoc-next vc-ewoc crt))))) |
| 716 | result)) | 723 | result)) |
| 717 | 724 | ||
| 718 | (defun vc-dir-child-files () | 725 | (defun vc-dir-child-files-and-states () |
| 719 | "Return the list of child files for the current entry if it's a directory. | 726 | "Return the list of conses (FILE . STATE) for child files of the current entry if it's a directory. |
| 720 | If it is a file, return the file itself." | 727 | If it is a file, return the corresponding cons for the file itself." |
| 721 | (let* ((crt (ewoc-locate vc-ewoc)) | 728 | (let* ((crt (ewoc-locate vc-ewoc)) |
| 722 | (crt-data (ewoc-data crt)) | 729 | (crt-data (ewoc-data crt)) |
| 723 | result) | 730 | result) |
| @@ -731,8 +738,13 @@ If it is a file, return the file itself." | |||
| 731 | (setq data (ewoc-data crt)) | 738 | (setq data (ewoc-data crt)) |
| 732 | (vc-dir-node-directory crt)))) | 739 | (vc-dir-node-directory crt)))) |
| 733 | (unless (vc-dir-fileinfo->directory data) | 740 | (unless (vc-dir-fileinfo->directory data) |
| 734 | (push (expand-file-name (vc-dir-fileinfo->name data)) result)))) | 741 | (push |
| 735 | (push (expand-file-name (vc-dir-fileinfo->name crt-data)) result)) | 742 | (cons (expand-file-name (vc-dir-fileinfo->name data)) |
| 743 | (vc-dir-fileinfo->state data)) | ||
| 744 | result)))) | ||
| 745 | (push | ||
| 746 | (cons (expand-file-name (vc-dir-fileinfo->name crt-data)) | ||
| 747 | (vc-dir-fileinfo->state crt-data)) result)) | ||
| 736 | result)) | 748 | result)) |
| 737 | 749 | ||
| 738 | (defun vc-dir-resynch-file (&optional fname) | 750 | (defun vc-dir-resynch-file (&optional fname) |
| @@ -932,6 +944,35 @@ outside of VC) and one wants to do some operation on it." | |||
| 932 | (defun vc-dir-status-printer (fileentry) | 944 | (defun vc-dir-status-printer (fileentry) |
| 933 | (vc-call-backend vc-dir-backend 'status-printer fileentry)) | 945 | (vc-call-backend vc-dir-backend 'status-printer fileentry)) |
| 934 | 946 | ||
| 947 | (defun vc-dir-deduce-fileset (&optional state-model-only-files) | ||
| 948 | (let ((marked (vc-dir-marked-files)) | ||
| 949 | files | ||
| 950 | only-files-list | ||
| 951 | state | ||
| 952 | model) | ||
| 953 | (if marked | ||
| 954 | (progn | ||
| 955 | (setq files marked) | ||
| 956 | (when state-model-only-files | ||
| 957 | (setq only-files-list (vc-dir-marked-only-files-and-states)))) | ||
| 958 | (let ((crt (vc-dir-current-file))) | ||
| 959 | (setq files (list crt)) | ||
| 960 | (when state-model-only-files | ||
| 961 | (setq only-files-list (vc-dir-child-files-and-states))))) | ||
| 962 | |||
| 963 | (when state-model-only-files | ||
| 964 | (setq state (cdar only-files-list)) | ||
| 965 | ;; Check that all files are in a consistent state, since we use that | ||
| 966 | ;; state to decide which operation to perform. | ||
| 967 | (dolist (crt (cdr only-files-list)) | ||
| 968 | (unless (vc-compatible-state (cdr crt) state) | ||
| 969 | (error "%s:%s clashes with %s:%s" | ||
| 970 | (car crt) (cdr crt) (caar only-files-list) state))) | ||
| 971 | (setq only-files-list (mapcar 'car only-files-list)) | ||
| 972 | (when (and state (not (eq state 'unregistered))) | ||
| 973 | (setq model (vc-checkout-model vc-dir-backend only-files-list)))) | ||
| 974 | (list vc-dir-backend files only-files-list state model))) | ||
| 975 | |||
| 935 | ;;;###autoload | 976 | ;;;###autoload |
| 936 | (defun vc-dir (dir backend) | 977 | (defun vc-dir (dir backend) |
| 937 | "Show the VC status for DIR. | 978 | "Show the VC status for DIR. |
diff --git a/lisp/vc.el b/lisp/vc.el index b1e5fd29346..6a5d420ccf9 100644 --- a/lisp/vc.el +++ b/lisp/vc.el | |||
| @@ -643,6 +643,9 @@ | |||
| 643 | ;; | 643 | ;; |
| 644 | ;; - vc-dir toolbar needs more icons. | 644 | ;; - vc-dir toolbar needs more icons. |
| 645 | ;; | 645 | ;; |
| 646 | ;; - vc-dir-hide-up-to-date needs to hide directories that do not have | ||
| 647 | ;; any children anymore. | ||
| 648 | ;; | ||
| 646 | ;;; Code: | 649 | ;;; Code: |
| 647 | 650 | ||
| 648 | (require 'vc-hooks) | 651 | (require 'vc-hooks) |
| @@ -903,38 +906,39 @@ Within directories, only files already under version control are noticed." | |||
| 903 | ;; (vc-backend (car cooked))))) | 906 | ;; (vc-backend (car cooked))))) |
| 904 | ;; (cons backend selection))) | 907 | ;; (cons backend selection))) |
| 905 | 908 | ||
| 906 | (declare-function vc-dir-child-files "vc-dir" ()) | ||
| 907 | (declare-function vc-dir-current-file "vc-dir" ()) | 909 | (declare-function vc-dir-current-file "vc-dir" ()) |
| 908 | (declare-function vc-dir-marked-files "vc-dir" ()) | 910 | (declare-function vc-dir-deduce-fileset "vc-dir" (&optional state-model-only-files)) |
| 909 | (declare-function vc-dir-marked-only-files "vc-dir" ()) | ||
| 910 | 911 | ||
| 911 | (defun vc-deduce-fileset (&optional observer allow-unregistered only-files) | 912 | (defun vc-deduce-fileset (&optional observer allow-unregistered |
| 913 | state-model-only-files) | ||
| 912 | "Deduce a set of files and a backend to which to apply an operation. | 914 | "Deduce a set of files and a backend to which to apply an operation. |
| 913 | 915 | ||
| 914 | Return (BACKEND FILESET FILESET-ONLY-FILES). | 916 | Return (BACKEND FILESET FILESET-ONLY-FILES STATE CHECKOUT-MODEL). |
| 915 | If we're in VC-dir mode, the fileset is the list of marked files. | 917 | If we're in VC-dir mode, the fileset is the list of marked files. |
| 916 | Otherwise, if we're looking at a buffer visiting a version-controlled file, | 918 | Otherwise, if we're looking at a buffer visiting a version-controlled file, |
| 917 | the fileset is a singleton containing this file. | 919 | the fileset is a singleton containing this file. |
| 918 | If none of these conditions is met, but ALLOW_UNREGISTERED is on and the | 920 | If none of these conditions is met, but ALLOW_UNREGISTERED is on and the |
| 919 | visited file is not registered, return a singleton fileset containing it. | 921 | visited file is not registered, return a singleton fileset containing it. |
| 920 | Otherwise, throw an error. | 922 | Otherwise, throw an error. |
| 921 | ONLY-FILES if non-nil, means that the caller needs to FILESET-ONLY-FILES | 923 | |
| 922 | info. Otherwise, that part may be skipped. | 924 | STATE-MODEL-ONLY-FILES if non-nil, means that the caller needs |
| 923 | BEWARE: this function may change the current buffer." | 925 | the FILESET-ONLY-FILES STATE and MODEL info. Otherwise, that |
| 926 | part may be skipped. | ||
| 927 | BEWARE: this function may change the | ||
| 928 | current buffer." | ||
| 924 | ;; FIXME: OBSERVER is unused. The name is not intuitive and is not | 929 | ;; FIXME: OBSERVER is unused. The name is not intuitive and is not |
| 925 | ;; documented. It's set to t when called from diff and print-log. | 930 | ;; documented. It's set to t when called from diff and print-log. |
| 926 | (let (backend) | 931 | (let (backend) |
| 927 | (cond | 932 | (cond |
| 928 | ((derived-mode-p 'vc-dir-mode) | 933 | ((derived-mode-p 'vc-dir-mode) |
| 929 | (let ((marked (vc-dir-marked-files))) | 934 | (vc-dir-deduce-fileset state-model-only-files)) |
| 930 | (if marked | ||
| 931 | (list vc-dir-backend marked | ||
| 932 | (if only-files (vc-dir-marked-only-files))) | ||
| 933 | (let ((crt (vc-dir-current-file))) | ||
| 934 | (list vc-dir-backend (list crt) | ||
| 935 | (if only-files (vc-dir-child-files))))))) | ||
| 936 | ((setq backend (vc-backend buffer-file-name)) | 935 | ((setq backend (vc-backend buffer-file-name)) |
| 937 | (list backend (list buffer-file-name) (list buffer-file-name))) | 936 | (if state-model-only-files |
| 937 | (list backend (list buffer-file-name) | ||
| 938 | (list buffer-file-name) | ||
| 939 | (vc-state buffer-file-name) | ||
| 940 | (vc-checkout-model backend buffer-file-name)) | ||
| 941 | (list backend (list buffer-file-name)))) | ||
| 938 | ((and (buffer-live-p vc-parent-buffer) | 942 | ((and (buffer-live-p vc-parent-buffer) |
| 939 | ;; FIXME: Why this test? --Stef | 943 | ;; FIXME: Why this test? --Stef |
| 940 | (or (buffer-file-name vc-parent-buffer) | 944 | (or (buffer-file-name vc-parent-buffer) |
| @@ -942,19 +946,26 @@ BEWARE: this function may change the current buffer." | |||
| 942 | (eq major-mode 'vc-dir-mode)))) | 946 | (eq major-mode 'vc-dir-mode)))) |
| 943 | (progn ;FIXME: Why not `with-current-buffer'? --Stef. | 947 | (progn ;FIXME: Why not `with-current-buffer'? --Stef. |
| 944 | (set-buffer vc-parent-buffer) | 948 | (set-buffer vc-parent-buffer) |
| 945 | (vc-deduce-fileset observer allow-unregistered only-files))) | 949 | (vc-deduce-fileset observer allow-unregistered state-model-only-files))) |
| 946 | ((not buffer-file-name) | 950 | ((not buffer-file-name) |
| 947 | (error "Buffer %s is not associated with a file" (buffer-name))) | 951 | (error "Buffer %s is not associated with a file" (buffer-name))) |
| 948 | ((and allow-unregistered (not (vc-registered buffer-file-name))) | 952 | ((and allow-unregistered (not (vc-registered buffer-file-name))) |
| 949 | (list (vc-responsible-backend | 953 | (if state-model-only-files |
| 950 | (file-name-directory (buffer-file-name))) | 954 | (list (vc-responsible-backend |
| 951 | (list buffer-file-name) (list buffer-file-name))) | 955 | (file-name-directory (buffer-file-name))) |
| 956 | (list buffer-file-name) | ||
| 957 | (list buffer-file-name) | ||
| 958 | (when state-model-only-files 'unregistered) | ||
| 959 | nil) | ||
| 960 | (list (vc-responsible-backend | ||
| 961 | (file-name-directory (buffer-file-name))) | ||
| 962 | (list buffer-file-name)))) | ||
| 952 | (t (error "No fileset is available here."))))) | 963 | (t (error "No fileset is available here."))))) |
| 953 | 964 | ||
| 954 | (defun vc-ensure-vc-buffer () | 965 | (defun vc-ensure-vc-buffer () |
| 955 | "Make sure that the current buffer visits a version-controlled file." | 966 | "Make sure that the current buffer visits a version-controlled file." |
| 956 | (cond | 967 | (cond |
| 957 | ((vc-dispatcher-browsing) | 968 | ((derived-mode-p 'vc-dir-mode) |
| 958 | (set-buffer (find-file-noselect (vc-dir-current-file)))) | 969 | (set-buffer (find-file-noselect (vc-dir-current-file)))) |
| 959 | (t | 970 | (t |
| 960 | (while (and vc-parent-buffer | 971 | (while (and vc-parent-buffer |
| @@ -1019,27 +1030,17 @@ with the logmessage as change commentary. A writable file is retained. | |||
| 1019 | If the repository file is changed, you are asked if you want to | 1030 | If the repository file is changed, you are asked if you want to |
| 1020 | merge in the changes into your working copy." | 1031 | merge in the changes into your working copy." |
| 1021 | (interactive "P") | 1032 | (interactive "P") |
| 1022 | (let* ((vc-fileset (vc-deduce-fileset nil t 'only-files)) | 1033 | (let* ((vc-fileset (vc-deduce-fileset nil t 'state-model-only-files)) |
| 1023 | (backend (car vc-fileset)) | 1034 | (backend (car vc-fileset)) |
| 1024 | (files (nth 1 vc-fileset)) | 1035 | (files (nth 1 vc-fileset)) |
| 1025 | (fileset-only-files (nth 2 vc-fileset)) | 1036 | (fileset-only-files (nth 2 vc-fileset)) |
| 1026 | ;; FIXME: We used to call `vc-recompute-state' here. | 1037 | ;; FIXME: We used to call `vc-recompute-state' here. |
| 1027 | (state (vc-state (car fileset-only-files))) | 1038 | (state (nth 3 vc-fileset)) |
| 1028 | ;; The backend should check that the checkout-model is consistent | 1039 | ;; The backend should check that the checkout-model is consistent |
| 1029 | ;; among all the `files'. | 1040 | ;; among all the `files'. |
| 1030 | (model | 1041 | (model (nth 4 vc-fileset)) |
| 1031 | ;; FIXME: This is not very elegant... | ||
| 1032 | (when (and state (not (eq state 'unregistered))) | ||
| 1033 | (vc-checkout-model backend files))) | ||
| 1034 | revision) | 1042 | revision) |
| 1035 | 1043 | ||
| 1036 | ;; Check that all files are in a consistent state, since we use that | ||
| 1037 | ;; state to decide which operation to perform. | ||
| 1038 | (dolist (file (cdr fileset-only-files)) | ||
| 1039 | (unless (vc-compatible-state (vc-state file) state) | ||
| 1040 | (error "%s:%s clashes with %s:%s" | ||
| 1041 | file (vc-state file) (car fileset-only-files) state))) | ||
| 1042 | |||
| 1043 | ;; Do the right thing | 1044 | ;; Do the right thing |
| 1044 | (cond | 1045 | (cond |
| 1045 | ((eq state 'missing) | 1046 | ((eq state 'missing) |