Mercurial > emacs
changeset 105591:6e1befdc92ef
(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.
author | Dan Nicolaescu <dann@ics.uci.edu> |
---|---|
date | Wed, 14 Oct 2009 06:08:47 +0000 |
parents | 7e0a5f5d7775 |
children | 7460402f0b1a |
files | etc/NEWS lisp/ChangeLog lisp/vc.el |
diffstat | 3 files changed, 58 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/etc/NEWS Wed Oct 14 06:00:51 2009 +0000 +++ b/etc/NEWS Wed Oct 14 06:08:47 2009 +0000 @@ -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.
--- a/lisp/ChangeLog Wed Oct 14 06:00:51 2009 +0000 +++ b/lisp/ChangeLog Wed Oct 14 06:08:47 2009 +0000 @@ -1,4 +1,9 @@ -2009-10-13 Dan Nicolaescu <dann@ics.uci.edu> +2009-10-14 Dan Nicolaescu <dann@ics.uci.edu> + + * 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:
--- a/lisp/vc.el Wed Oct 14 06:00:51 2009 +0000 +++ b/lisp/vc.el Wed Oct 14 06:08:47 2009 +0000 @@ -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 - (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"))))) + (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"))))) (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")))))