unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* allow C-x v i / C-x v v to create a repository if none is available
@ 2009-10-08 20:47 Dan Nicolaescu
  2009-10-08 21:10 ` Chong Yidong
  2009-10-09 19:18 ` Stefan Monnier
  0 siblings, 2 replies; 29+ messages in thread
From: Dan Nicolaescu @ 2009-10-08 20:47 UTC (permalink / raw)
  To: emacs-devel


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")))))




^ permalink raw reply	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2009-10-27  3:22 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-08 20:47 allow C-x v i / C-x v v to create a repository if none is available Dan Nicolaescu
2009-10-08 21:10 ` Chong Yidong
2009-10-09 19:18 ` Stefan Monnier
2009-10-09 19:32   ` Dan Nicolaescu
2009-10-13 18:40     ` Stefan Monnier
2009-10-13 15:59   ` Dan Nicolaescu
2009-10-21 19:06   ` Dan Nicolaescu
2009-10-23  7:45     ` Dan Nicolaescu
2009-10-23 13:12       ` Stefan Monnier
2009-10-24  2:34       ` Miles Bader
2009-10-24  6:35         ` Dan Nicolaescu
2009-10-22 18:56   ` Code for converting between Elisp and Calc floats Jay Belanger
2009-10-22 20:04     ` James Cloos
2009-10-23  0:50     ` Stefan Monnier
2009-10-24 20:03       ` Jay Belanger
2009-10-25  0:56         ` Stefan Monnier
2009-10-25  5:36           ` David Kastrup
2009-10-25 11:36             ` Vincent Belaïche
2009-10-25 14:11               ` Chong Yidong
2009-10-25 19:29                 ` Vincent Belaïche
2009-10-26  2:30                   ` Stefan Monnier
2009-10-26 12:48                     ` Vincent Belaïche
2009-10-27  3:22                       ` Stefan Monnier
2009-10-25 13:57             ` Stefan Monnier
2009-10-25 18:35               ` Eli Zaretskii
2009-10-26  2:02                 ` Large files (was: Code for converting between Elisp and Calc floats) Stefan Monnier
2009-10-23 13:11     ` Code for converting between Elisp and Calc floats Richard Stallman
2009-10-23 13:26       ` David Kastrup
2009-10-24 17:34         ` Richard Stallman

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).