emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] emacs etc/NEWS lisp/ChangeLog lisp/vc.el


From: Dan Nicolaescu
Subject: [Emacs-diffs] emacs etc/NEWS lisp/ChangeLog lisp/vc.el
Date: Wed, 14 Oct 2009 06:08:53 +0000

CVSROOT:        /cvsroot/emacs
Module name:    emacs
Changes by:     Dan Nicolaescu <dann>   09/10/14 06:08:53

Modified files:
        etc            : NEWS 
        lisp           : ChangeLog vc.el 

Log message:
        (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.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/emacs/etc/NEWS?cvsroot=emacs&r1=1.2101&r2=1.2102
http://cvs.savannah.gnu.org/viewcvs/emacs/lisp/ChangeLog?cvsroot=emacs&r1=1.16420&r2=1.16421
http://cvs.savannah.gnu.org/viewcvs/emacs/lisp/vc.el?cvsroot=emacs&r1=1.733&r2=1.734

Patches:
Index: etc/NEWS
===================================================================
RCS file: /cvsroot/emacs/emacs/etc/NEWS,v
retrieving revision 1.2101
retrieving revision 1.2102
diff -u -b -r1.2101 -r1.2102
--- etc/NEWS    10 Oct 2009 23:43:27 -0000      1.2101
+++ etc/NEWS    14 Oct 2009 06:08:47 -0000      1.2102
@@ -185,6 +185,11 @@
 
 ** VC and related modes
 
+*** When using C-x v v or C-x v i on a unregistered file that is in a
+directory not controlled by any VCS, ask the user what VC backend to
+use to create a repository, create a new repository and register the
+file.
+
 *** FIXME: add info about the new VC functions: vc-root-diff and
 vc-root-print-log once they stabilize.
 

Index: lisp/ChangeLog
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/ChangeLog,v
retrieving revision 1.16420
retrieving revision 1.16421
diff -u -b -r1.16420 -r1.16421
--- lisp/ChangeLog      14 Oct 2009 06:00:51 -0000      1.16420
+++ lisp/ChangeLog      14 Oct 2009 06:08:49 -0000      1.16421
@@ -1,4 +1,9 @@
-2009-10-13  Dan Nicolaescu  <address@hidden>
+2009-10-14  Dan Nicolaescu  <address@hidden>
+
+       * vc.el (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.
 
        * vc.el: Move comments about RCS and SCCS ...
        * vc-rcs.el:

Index: lisp/vc.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/vc.el,v
retrieving revision 1.733
retrieving revision 1.734
diff -u -b -r1.733 -r1.734
--- lisp/vc.el  14 Oct 2009 06:00:55 -0000      1.733
+++ lisp/vc.el  14 Oct 2009 06:08:53 -0000      1.734
@@ -551,9 +551,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.
 ;;
@@ -805,11 +802,14 @@
 registration should be found.
 
 If REGISTER is nil, then if FILE is already registered, return the
-backend of FILE.  If FILE is not registered, or a directory, then the
+backend of FILE.  If FILE is not registered, then the
 first backend in `vc-handled-backends' that declares itself
 responsible for FILE is returned.  If no backend declares itself
 responsible, return the first backend.
 
+If REGISTER is non-nil and FILE is a directory, create a VC
+repository that can be used to register FILE.
+
 If REGISTER is non-nil, return the first responsible backend under
 which FILE is not yet registered.  If there is no such backend, return
 the first backend under which FILE is not yet registered, but could
@@ -829,13 +829,47 @@
        (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
+         (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
+                      ;; Read the VC backend from the user, only
+                      ;; complete with the backends that have the
+                      ;; 'create-repo method.
+                      (completing-read
+                       (format "%s is not in a version controlled 
directory.\nUse VC backend: " file)
+                       (mapcar 'symbol-name possible-backends) nil t)))
+                    (repo-dir
+                     (file-name-as-directory
+                      (let ((def-dir file))
+                        ;; read the directory where to create the
+                        ;; repository, make sure it's a parent of
+                        ;; file.
+                        (read-file-name
+                         (format "create %s repository in: " bk)
+                         default-directory nil t nil
+                         (lambda (arg)
+                           (and (file-directory-p arg)
+                                (vc-string-prefix-p (expand-file-name arg) 
def-dir))))))))
+               (let ((default-directory repo-dir))
+                 (vc-call-backend bk 'create-repo))
+               (throw 'found bk))
+
+           ;; FIXME: this case does not happen with the current code.
+           ;; Should we keep it?
+           ;;
+           ;; 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")))))
+                  (throw 'found backend))))
+         (error "no backend that could register")))))
 
 (defun vc-expand-dirs (file-or-dir-list)
   "Expands directories in a file list specification.
@@ -896,13 +930,13 @@
      ((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]