aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Nicolaescu2009-10-14 06:08:47 +0000
committerDan Nicolaescu2009-10-14 06:08:47 +0000
commitb4e813cad10fd57e0a82352b0cd7262822272034 (patch)
tree6393189a0dd62bebf22a8638b583337f39f1c8ef
parent1043ce19c83a7fc4ef59462108e65431f410a9b9 (diff)
downloademacs-b4e813cad10fd57e0a82352b0cd7262822272034.tar.gz
emacs-b4e813cad10fd57e0a82352b0cd7262822272034.zip
(vc-responsible-backend): When a directory is passed for
for registration create a VC repository if no backend is responsible for the directory argument. (vc-deduce-fileset): Tell vc-responsible-backend to register.
-rw-r--r--etc/NEWS5
-rw-r--r--lisp/ChangeLog7
-rw-r--r--lisp/vc.el60
3 files changed, 58 insertions, 14 deletions
diff --git a/etc/NEWS b/etc/NEWS
index ef66fe6ea93..a9fb6bb55d1 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -185,6 +185,11 @@ new connection methods "dav", "davs", "obex" and "synce".
185 185
186** VC and related modes 186** VC and related modes
187 187
188*** When using C-x v v or C-x v i on a unregistered file that is in a
189directory not controlled by any VCS, ask the user what VC backend to
190use to create a repository, create a new repository and register the
191file.
192
188*** FIXME: add info about the new VC functions: vc-root-diff and 193*** FIXME: add info about the new VC functions: vc-root-diff and
189vc-root-print-log once they stabilize. 194vc-root-print-log once they stabilize.
190 195
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index cffa6651ecf..b10a077b810 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,4 +1,9 @@
12009-10-13 Dan Nicolaescu <dann@ics.uci.edu> 12009-10-14 Dan Nicolaescu <dann@ics.uci.edu>
2
3 * vc.el (vc-responsible-backend): When a directory is passed for
4 for registration create a VC repository if no backend is
5 responsible for the directory argument.
6 (vc-deduce-fileset): Tell vc-responsible-backend to register.
2 7
3 * vc.el: Move comments about RCS and SCCS ... 8 * vc.el: Move comments about RCS and SCCS ...
4 * vc-rcs.el: 9 * vc-rcs.el:
diff --git a/lisp/vc.el b/lisp/vc.el
index 515fcbcdde6..87cade8485c 100644
--- a/lisp/vc.el
+++ b/lisp/vc.el
@@ -551,9 +551,6 @@
551;; 551;;
552;;;; Default Behavior: 552;;;; Default Behavior:
553;; 553;;
554;; - do not default to RCS anymore when the current directory is not
555;; controlled by any VCS and the user does C-x v v
556;;
557;; - vc-responsible-backend should not return RCS if no backend 554;; - vc-responsible-backend should not return RCS if no backend
558;; declares itself responsible. 555;; declares itself responsible.
559;; 556;;
@@ -805,11 +802,14 @@ The optional argument REGISTER means that a backend suitable for
805registration should be found. 802registration should be found.
806 803
807If REGISTER is nil, then if FILE is already registered, return the 804If REGISTER is nil, then if FILE is already registered, return the
808backend of FILE. If FILE is not registered, or a directory, then the 805backend of FILE. If FILE is not registered, then the
809first backend in `vc-handled-backends' that declares itself 806first backend in `vc-handled-backends' that declares itself
810responsible for FILE is returned. If no backend declares itself 807responsible for FILE is returned. If no backend declares itself
811responsible, return the first backend. 808responsible, return the first backend.
812 809
810If REGISTER is non-nil and FILE is a directory, create a VC
811repository that can be used to register FILE.
812
813If REGISTER is non-nil, return the first responsible backend under 813If REGISTER is non-nil, return the first responsible backend under
814which FILE is not yet registered. If there is no such backend, return 814which FILE is not yet registered. If there is no such backend, return
815the first backend under which FILE is not yet registered, but could 815the first backend under which FILE is not yet registered, but could
@@ -829,13 +829,47 @@ be registered."
829 (if (not register) 829 (if (not register)
830 ;; if this is not for registration, the first backend must do 830 ;; if this is not for registration, the first backend must do
831 (car vc-handled-backends) 831 (car vc-handled-backends)
832 ;; for registration, we need to find a new backend that 832 (if (file-directory-p file)
833 ;; could register FILE 833 (let* ((possible-backends
834 (dolist (backend vc-handled-backends) 834 (let (pos)
835 (and (not (vc-call-backend backend 'registered file)) 835 (dolist (crt vc-handled-backends)
836 (vc-call-backend backend 'could-register file) 836 (when (vc-find-backend-function crt 'create-repo)
837 (throw 'found backend))) 837 (push crt pos)))
838 (error "No backend that could register"))))) 838 pos))
839 (bk
840 (intern
841 ;; Read the VC backend from the user, only
842 ;; complete with the backends that have the
843 ;; 'create-repo method.
844 (completing-read
845 (format "%s is not in a version controlled directory.\nUse VC backend: " file)
846 (mapcar 'symbol-name possible-backends) nil t)))
847 (repo-dir
848 (file-name-as-directory
849 (let ((def-dir file))
850 ;; read the directory where to create the
851 ;; repository, make sure it's a parent of
852 ;; file.
853 (read-file-name
854 (format "create %s repository in: " bk)
855 default-directory nil t nil
856 (lambda (arg)
857 (and (file-directory-p arg)
858 (vc-string-prefix-p (expand-file-name arg) def-dir))))))))
859 (let ((default-directory repo-dir))
860 (vc-call-backend bk 'create-repo))
861 (throw 'found bk))
862
863 ;; FIXME: this case does not happen with the current code.
864 ;; Should we keep it?
865 ;;
866 ;; For registration, we need to find a new backend that
867 ;; could register FILE.
868 (dolist (backend vc-handled-backends)
869 (and (not (vc-call-backend backend 'registered file))
870 (vc-call-backend backend 'could-register file)
871 (throw 'found backend))))
872 (error "no backend that could register")))))
839 873
840(defun vc-expand-dirs (file-or-dir-list) 874(defun vc-expand-dirs (file-or-dir-list)
841 "Expands directories in a file list specification. 875 "Expands directories in a file list specification.
@@ -896,13 +930,13 @@ current buffer."
896 ((and allow-unregistered (not (vc-registered buffer-file-name))) 930 ((and allow-unregistered (not (vc-registered buffer-file-name)))
897 (if state-model-only-files 931 (if state-model-only-files
898 (list (vc-responsible-backend 932 (list (vc-responsible-backend
899 (file-name-directory (buffer-file-name))) 933 (file-name-directory (buffer-file-name)) t)
900 (list buffer-file-name) 934 (list buffer-file-name)
901 (list buffer-file-name) 935 (list buffer-file-name)
902 (when state-model-only-files 'unregistered) 936 (when state-model-only-files 'unregistered)
903 nil) 937 nil)
904 (list (vc-responsible-backend 938 (list (vc-responsible-backend
905 (file-name-directory (buffer-file-name))) 939 (file-name-directory (buffer-file-name)) t)
906 (list buffer-file-name)))) 940 (list buffer-file-name))))
907 (t (error "No fileset is available here"))))) 941 (t (error "No fileset is available here")))))
908 942