diff options
| author | Dan Nicolaescu | 2008-04-30 05:40:25 +0000 |
|---|---|---|
| committer | Dan Nicolaescu | 2008-04-30 05:40:25 +0000 |
| commit | 5bd20ee6943ce1bdc255c5c527a4d7fd0eb364dc (patch) | |
| tree | b5cb5d6cc2b613fdc11c989fc43a6414a2784ffc | |
| parent | b00942d090e6699acc639dafd2ae0c4f9e29d506 (diff) | |
| download | emacs-5bd20ee6943ce1bdc255c5c527a4d7fd0eb364dc.tar.gz emacs-5bd20ee6943ce1bdc255c5c527a4d7fd0eb364dc.zip | |
(vc-deduce-fileset): Add new parameter.
(vc-dir-marked-only-files): New function.
(vc-next-action): Don't ignore directories, look at the files
inside them.
(vc-dir-mode): Document how the mark/unmark commands work.
| -rw-r--r-- | lisp/ChangeLog | 8 | ||||
| -rw-r--r-- | lisp/vc.el | 118 |
2 files changed, 100 insertions, 26 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 516c4f65462..e6e6db5a833 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2008-04-30 Dan Nicolaescu <dann@ics.uci.edu> | ||
| 2 | |||
| 3 | * vc.el (vc-deduce-fileset): Add new parameter. | ||
| 4 | (vc-dir-marked-only-files): New function. | ||
| 5 | (vc-next-action): Don't ignore directories, look at the files | ||
| 6 | inside them. | ||
| 7 | (vc-dir-mode): Document how the mark/unmark commands work. | ||
| 8 | |||
| 1 | 2008-04-30 Stefan Monnier <monnier@iro.umontreal.ca> | 9 | 2008-04-30 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 10 | ||
| 3 | * minibuffer.el (completion--do-completion): Move point even if the | 11 | * minibuffer.el (completion--do-completion): Move point even if the |
diff --git a/lisp/vc.el b/lisp/vc.el index 4d71b614665..89e419bc5a8 100644 --- a/lisp/vc.el +++ b/lisp/vc.el | |||
| @@ -613,9 +613,6 @@ | |||
| 613 | ;; changeset, especially for VC systems that have per repository | 613 | ;; changeset, especially for VC systems that have per repository |
| 614 | ;; version numbers. log-view should take advantage of this. | 614 | ;; version numbers. log-view should take advantage of this. |
| 615 | ;; | 615 | ;; |
| 616 | ;; - a way to do repository wide log (instead of just per | ||
| 617 | ;; file/fileset) is needed. | ||
| 618 | ;; | ||
| 619 | ;; - the *VC-log* buffer needs font-locking. | 616 | ;; - the *VC-log* buffer needs font-locking. |
| 620 | ;; | 617 | ;; |
| 621 | ;; - make it easier to write logs. Maybe C-x 4 a should add to the log | 618 | ;; - make it easier to write logs. Maybe C-x 4 a should add to the log |
| @@ -624,6 +621,9 @@ | |||
| 624 | ;; - make vc-state for all backends return 'unregistered instead of | 621 | ;; - make vc-state for all backends return 'unregistered instead of |
| 625 | ;; nil for unregistered files, then update vc-next-action. | 622 | ;; nil for unregistered files, then update vc-next-action. |
| 626 | ;; | 623 | ;; |
| 624 | ;; - vc-default-registered should return 'unregistered not nil for | ||
| 625 | ;; unregistered files. | ||
| 626 | ;; | ||
| 627 | ;; - vc-register should register a fileset at a time. The backends | 627 | ;; - vc-register should register a fileset at a time. The backends |
| 628 | ;; already support this, only the front-end needs to be changed to | 628 | ;; already support this, only the front-end needs to be changed to |
| 629 | ;; handle multiple files at a time. | 629 | ;; handle multiple files at a time. |
| @@ -633,8 +633,18 @@ | |||
| 633 | ;; - vc-next-action should do something about 'missing files. Maybe | 633 | ;; - vc-next-action should do something about 'missing files. Maybe |
| 634 | ;; just warn, or offer to checkout. | 634 | ;; just warn, or offer to checkout. |
| 635 | ;; | 635 | ;; |
| 636 | ;; - display the directory names in vc-dir, similar to what PCL-CVS | 636 | ;; - When vc-next-action calls vc-checkin it could pre-fill the |
| 637 | ;; does. | 637 | ;; *VC-log* buffer with some obvious items: the list of files that |
| 638 | ;; were added, the list of files that were removed. If the diff is | ||
| 639 | ;; available, maybe it could even call something like | ||
| 640 | ;; `diff-add-change-log-entries-other-window' to create a detailed | ||
| 641 | ;; skeleton for the log... | ||
| 642 | ;; | ||
| 643 | ;; - Set `vc-dir-insert-directories' to t and check what operations | ||
| 644 | ;; and backends do not support directory arguments and fix them. | ||
| 645 | ;; | ||
| 646 | ;; - a way to do repository wide log (instead of just per | ||
| 647 | ;; file/fileset) is needed. Doing it per directory might be enough... | ||
| 638 | ;; | 648 | ;; |
| 639 | ;; - most vc-dir backends need more work. They might need to | 649 | ;; - most vc-dir backends need more work. They might need to |
| 640 | ;; provide custom headers, use the `extra' field and deal with all | 650 | ;; provide custom headers, use the `extra' field and deal with all |
| @@ -648,9 +658,8 @@ | |||
| 648 | ;; | 658 | ;; |
| 649 | ;; - vc-dir toolbar needs more icons. | 659 | ;; - vc-dir toolbar needs more icons. |
| 650 | ;; | 660 | ;; |
| 651 | ;; - implement `vc-dir-parent-marked-p' and `vc-dir-children-marked-p'. | 661 | ;; - vc-dir-next-line should not print an "end of buffer" message when |
| 652 | ;; | 662 | ;; invoked with the cursor on the last file. |
| 653 | ;; - test operations on directories in vc-dir. | ||
| 654 | ;; | 663 | ;; |
| 655 | ;; - vc-diff, vc-annotate, etc. need to deal better with unregistered | 664 | ;; - vc-diff, vc-annotate, etc. need to deal better with unregistered |
| 656 | ;; files. Now that unregistered and ignored files are shown in | 665 | ;; files. Now that unregistered and ignored files are shown in |
| @@ -660,6 +669,11 @@ | |||
| 660 | ;; - do not default to RCS anymore when the current directory is not | 669 | ;; - do not default to RCS anymore when the current directory is not |
| 661 | ;; controlled by any VCS and the user does C-x v v | 670 | ;; controlled by any VCS and the user does C-x v v |
| 662 | ;; | 671 | ;; |
| 672 | ;; - vc-cvs-delete-file should not do a "cvs commit" immediately after | ||
| 673 | ;; removing the file. | ||
| 674 | ;; | ||
| 675 | ;; - vc-create-snapshot and vc-retrieve-snapshot should update the | ||
| 676 | ;; buffers that might be visiting the affected files. | ||
| 663 | 677 | ||
| 664 | ;;; Code: | 678 | ;;; Code: |
| 665 | 679 | ||
| @@ -1426,7 +1440,8 @@ Only files already under version control are noticed." | |||
| 1426 | node (lambda (f) (when (vc-backend f) (push f flattened))))) | 1440 | node (lambda (f) (when (vc-backend f) (push f flattened))))) |
| 1427 | (nreverse flattened))) | 1441 | (nreverse flattened))) |
| 1428 | 1442 | ||
| 1429 | (defun vc-deduce-fileset (&optional allow-directory-wildcard allow-unregistered) | 1443 | (defun vc-deduce-fileset (&optional allow-directory-wildcard allow-unregistered |
| 1444 | include-files-not-directories) | ||
| 1430 | "Deduce a set of files and a backend to which to apply an operation. | 1445 | "Deduce a set of files and a backend to which to apply an operation. |
| 1431 | 1446 | ||
| 1432 | Return (BACKEND . FILESET). | 1447 | Return (BACKEND . FILESET). |
| @@ -1435,8 +1450,11 @@ Otherwise, if we're looking at a buffer visiting a version-controlled file, | |||
| 1435 | the fileset is a singleton containing this file. | 1450 | the fileset is a singleton containing this file. |
| 1436 | If neither of these things is true, but ALLOW-DIRECTORY-WILDCARD is on | 1451 | If neither of these things is true, but ALLOW-DIRECTORY-WILDCARD is on |
| 1437 | and we're in a dired buffer, select the current directory. | 1452 | and we're in a dired buffer, select the current directory. |
| 1438 | If none of these conditions is met, but ALLOW_UNREGISTERED is in and the | 1453 | If none of these conditions is met, but ALLOW_UNREGISTERED is on and the |
| 1439 | visited file is not registered, return a singletin fileset containing it. | 1454 | visited file is not registered, return a singleton fileset containing it. |
| 1455 | If INCLUDE-FILES-NOT-DIRECTORIES then if directories are marked, | ||
| 1456 | return the list of files VC files in those directories instead of | ||
| 1457 | the directories themselves. | ||
| 1440 | Otherwise, throw an error." | 1458 | Otherwise, throw an error." |
| 1441 | (let (backend) | 1459 | (let (backend) |
| 1442 | (cond | 1460 | (cond |
| @@ -1454,8 +1472,11 @@ Otherwise, throw an error." | |||
| 1454 | ;; FIXME: Maybe the backend should be stored in a buffer-local | 1472 | ;; FIXME: Maybe the backend should be stored in a buffer-local |
| 1455 | ;; variable? | 1473 | ;; variable? |
| 1456 | (cons (vc-responsible-backend default-directory) | 1474 | (cons (vc-responsible-backend default-directory) |
| 1457 | (or (vc-dir-marked-files) | 1475 | (or |
| 1458 | (list (vc-dir-current-file))))) | 1476 | (if include-files-not-directories |
| 1477 | (vc-dir-marked-only-files) | ||
| 1478 | (vc-dir-marked-files)) | ||
| 1479 | (list (vc-dir-current-file))))) | ||
| 1459 | ((setq backend (vc-backend buffer-file-name)) | 1480 | ((setq backend (vc-backend buffer-file-name)) |
| 1460 | (cons backend (list buffer-file-name))) | 1481 | (cons backend (list buffer-file-name))) |
| 1461 | ((and vc-parent-buffer (or (buffer-file-name vc-parent-buffer) | 1482 | ((and vc-parent-buffer (or (buffer-file-name vc-parent-buffer) |
| @@ -1588,26 +1609,20 @@ with the logmessage as change commentary. A writable file is retained. | |||
| 1588 | merge in the changes into your working copy." | 1609 | merge in the changes into your working copy." |
| 1589 | (interactive "P") | 1610 | (interactive "P") |
| 1590 | (let* ((vc-fileset (vc-deduce-fileset nil t)) | 1611 | (let* ((vc-fileset (vc-deduce-fileset nil t)) |
| 1612 | (vc-fileset-only-files (vc-deduce-fileset nil t t)) | ||
| 1613 | (only-files (cdr vc-fileset-only-files)) | ||
| 1591 | (backend (car vc-fileset)) | 1614 | (backend (car vc-fileset)) |
| 1592 | (files (cdr vc-fileset)) | 1615 | (files (cdr vc-fileset)) |
| 1593 | state | 1616 | (state (vc-state (car only-files))) |
| 1594 | (model (vc-checkout-model backend files)) | 1617 | (model (vc-checkout-model backend files)) |
| 1595 | revision) | 1618 | revision) |
| 1596 | ;; Check if there's at least one file present, and get `state' and | ||
| 1597 | ;; `model' from it. | ||
| 1598 | ;;FIXME: do something about the case when only directories are | ||
| 1599 | ;; present, or `files' is nil. | ||
| 1600 | (dolist (file files) | ||
| 1601 | (unless (file-directory-p file) | ||
| 1602 | (setq state (vc-state file)) | ||
| 1603 | (return))) | ||
| 1604 | 1619 | ||
| 1605 | ;; Verify that the fileset is homogeneous | 1620 | ;; Verify that the fileset is homogeneous |
| 1606 | (dolist (file (cdr files)) | 1621 | (dolist (file (cdr only-files)) |
| 1607 | ;; Ignore directories, they are compatible with anything. | 1622 | ;; Ignore directories, they are compatible with anything. |
| 1608 | (unless (file-directory-p file) | 1623 | (unless (file-directory-p file) |
| 1609 | (unless (vc-compatible-state (vc-state file) state) | 1624 | (unless (vc-compatible-state (vc-state file) state) |
| 1610 | (error "Fileset is in a mixed-up state")) | 1625 | (error "Fileset is in a mixed-up state %s %s" state (vc-state file))) |
| 1611 | (unless (eq (vc-checkout-model backend file) model) | 1626 | (unless (eq (vc-checkout-model backend file) model) |
| 1612 | (error "Fileset has mixed checkout models")))) | 1627 | (error "Fileset has mixed checkout models")))) |
| 1613 | ;; Check for buffers in the fileset not matching the on-disk contents. | 1628 | ;; Check for buffers in the fileset not matching the on-disk contents. |
| @@ -3036,7 +3051,25 @@ specific headers." | |||
| 3036 | "The buffer used for the asynchronous call that computes the VC status.") | 3051 | "The buffer used for the asynchronous call that computes the VC status.") |
| 3037 | 3052 | ||
| 3038 | (defun vc-dir-mode () | 3053 | (defun vc-dir-mode () |
| 3039 | "Major mode for VC status. | 3054 | "Major mode for showing the VC status for a directory. |
| 3055 | Marking/Unmarking key bindings and actions: | ||
| 3056 | m - marks a file/directory or ff the region is active, mark all the files | ||
| 3057 | in region. | ||
| 3058 | Restrictions: - a file cannot be marked if any parent directory is marked | ||
| 3059 | - a directory cannot be marked if any child file or | ||
| 3060 | directory is marked | ||
| 3061 | u - marks a file/directory or if the region is active, unmark all the files | ||
| 3062 | in region. | ||
| 3063 | M - if the cursor is on a file: mark all the files with the same VC state as | ||
| 3064 | the current file | ||
| 3065 | - if the cursor is on a directory: mark all child files | ||
| 3066 | - with a prefix argument: mark all files | ||
| 3067 | U - if the cursor is on a file: unmark all the files with the same VC state | ||
| 3068 | as the current file | ||
| 3069 | - if the cursor is on a directory: unmark all child files | ||
| 3070 | - with a prefix argument: unmark all files | ||
| 3071 | |||
| 3072 | |||
| 3040 | \\{vc-dir-mode-map}" | 3073 | \\{vc-dir-mode-map}" |
| 3041 | (setq mode-name "VC Status") | 3074 | (setq mode-name "VC Status") |
| 3042 | (setq major-mode 'vc-dir-mode) | 3075 | (setq major-mode 'vc-dir-mode) |
| @@ -3544,11 +3577,44 @@ outside of VC) and one wants to do some operation on it." | |||
| 3544 | (expand-file-name (vc-dir-fileinfo->name (ewoc-data node))))) | 3577 | (expand-file-name (vc-dir-fileinfo->name (ewoc-data node))))) |
| 3545 | 3578 | ||
| 3546 | (defun vc-dir-marked-files () | 3579 | (defun vc-dir-marked-files () |
| 3547 | "Return the list of marked files" | 3580 | "Return the list of marked files." |
| 3548 | (mapcar | 3581 | (mapcar |
| 3549 | (lambda (elem) (expand-file-name (vc-dir-fileinfo->name elem))) | 3582 | (lambda (elem) (expand-file-name (vc-dir-fileinfo->name elem))) |
| 3550 | (ewoc-collect vc-ewoc 'vc-dir-fileinfo->marked))) | 3583 | (ewoc-collect vc-ewoc 'vc-dir-fileinfo->marked))) |
| 3551 | 3584 | ||
| 3585 | (defun vc-dir-marked-only-files () | ||
| 3586 | "Return the list of marked files, for marked directories, return child files." | ||
| 3587 | |||
| 3588 | (let ((crt (ewoc-nth vc-ewoc 0)) | ||
| 3589 | result) | ||
| 3590 | (while crt | ||
| 3591 | (let ((crt-data (ewoc-data crt))) | ||
| 3592 | (if (vc-dir-fileinfo->marked crt-data) | ||
| 3593 | (if (vc-dir-fileinfo->directory crt-data) | ||
| 3594 | (let* ((dir (vc-dir-fileinfo->directory crt-data)) | ||
| 3595 | (dirlen (length dir)) | ||
| 3596 | data) | ||
| 3597 | (while | ||
| 3598 | (and (setq crt (ewoc-next vc-ewoc crt)) | ||
| 3599 | (string-equal | ||
| 3600 | (substring | ||
| 3601 | (progn | ||
| 3602 | (setq data (ewoc-data crt)) | ||
| 3603 | (let ((crtdir (vc-dir-fileinfo->directory data))) | ||
| 3604 | (if crtdir | ||
| 3605 | crtdir | ||
| 3606 | (file-name-directory | ||
| 3607 | (expand-file-name | ||
| 3608 | (vc-dir-fileinfo->name data)))))) | ||
| 3609 | 0 dirlen) | ||
| 3610 | dir)) | ||
| 3611 | (unless (vc-dir-fileinfo->directory data) | ||
| 3612 | (push (vc-dir-fileinfo->name data) result)))) | ||
| 3613 | (push (expand-file-name (vc-dir-fileinfo->name crt-data)) result) | ||
| 3614 | (setq crt (ewoc-next vc-ewoc crt))) | ||
| 3615 | (setq crt (ewoc-next vc-ewoc crt))))) | ||
| 3616 | result)) | ||
| 3617 | |||
| 3552 | (defun vc-dir-hide-up-to-date () | 3618 | (defun vc-dir-hide-up-to-date () |
| 3553 | "Hide up-to-date items from display." | 3619 | "Hide up-to-date items from display." |
| 3554 | (interactive) | 3620 | (interactive) |