emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

allow C-x v i / C-x v v to create a repository if none is available


From: Dan Nicolaescu
Subject: allow C-x v i / C-x v v to create a repository if none is available
Date: Thu, 8 Oct 2009 13:47:46 -0700 (PDT)

When doing C-x v i or C-x v v on an unregistered file that is in a
directory not under any version control, the file will be registered
with RCS.  That is not exactly what most users want.

The patch below asks the user what VC backend to use to create a
repository, it creates it and registers the file.

OK to check in?

Index: vc.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/vc.el,v
retrieving revision 1.732
diff -u -3 -p -u -p -r1.732 vc.el
--- vc.el       3 Oct 2009 18:29:26 -0000       1.732
+++ vc.el       8 Oct 2009 20:39:47 -0000
@@ -564,9 +564,6 @@
 ;;
 ;;;; Default Behavior:
 ;;
-;; - do not default to RCS anymore when the current directory is not
-;;   controlled by any VCS and the user does C-x v v
-;;
 ;; - vc-responsible-backend should not return RCS if no backend
 ;;   declares itself responsible.
 ;;
@@ -842,12 +840,31 @@ be registered."
        (if (not register)
            ;; if this is not for registration, the first backend must do
            (car vc-handled-backends)
-         ;; for registration, we need to find a new backend that
-         ;; could register FILE
-         (dolist (backend vc-handled-backends)
-           (and (not (vc-call-backend backend 'registered file))
-                (vc-call-backend backend 'could-register file)
-                (throw 'found backend)))
+
+         (if (file-directory-p file)
+             (let* ((possible-backends
+                     (let (pos)
+                       (dolist (crt vc-handled-backends)
+                         (when (vc-find-backend-function crt 'create-repo)
+                           (push crt pos)))
+                       pos))
+                   (bk
+                    (intern
+                     (completing-read 
+                      (format "%s is not in a version controlled 
directory.\nWhat VC backend do you want to use to register: " file)
+                      (mapcar 'symbol-name possible-backends) nil t))))
+               ;; FIXME: Maybe we need to let bound defauld-directory
+               ;; around this call to make sure it runs in the right
+               ;; place?
+               (vc-call-backend bk 'create-repo)
+               (throw 'found bk))
+           ;; FIXME: Does this case ever happen?
+           ;; for registration, we need to find a new backend that
+           ;; could register FILE
+           (dolist (backend vc-handled-backends)
+             (and (not (vc-call-backend backend 'registered file))
+                  (vc-call-backend backend 'could-register file)
+                  (throw 'found backend))))
          (error "No backend that could register")))))
 
 (defun vc-expand-dirs (file-or-dir-list)
@@ -909,12 +930,12 @@ current buffer."
      ((and allow-unregistered (not (vc-registered buffer-file-name)))
       (if state-model-only-files
          (list (vc-responsible-backend
-                (file-name-directory (buffer-file-name)))
+                (file-name-directory (buffer-file-name)) t)
                (list buffer-file-name)
                (list buffer-file-name)
                (when state-model-only-files 'unregistered)
                nil)
        (list (vc-responsible-backend
-              (file-name-directory (buffer-file-name)))
+              (file-name-directory (buffer-file-name)) t)
              (list buffer-file-name))))
      (t (error "No fileset is available here")))))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]