[Top][All Lists]

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

Re: How to test if a directory is under version control ?

From: Stefan Monnier
Subject: Re: How to test if a directory is under version control ?
Date: Wed, 05 Nov 2003 14:15:07 GMT
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

> I am trying to write a simple function that would alert me when I edit
> a file which is not under version-control, while the directory is.

> To test if the file is under VC, I found vc-registered. For the
> directory, if I do not find a more elegant way, I will end up looking
> for a 'CVS' directory at the file's location, as I use CVS. But I
> thought that there may be better solution ...

VC has two related operations: `responsible-p' and `could-register'.
They're used in the function `vc-responsible-backend'.  But this function
will not give you what you want because it'll always find a backend (in the
worst case it'll just use RCS which does not need any `RCS' subdirectory and
is thus always potentially ready to control a file).

I guess your best bet is something like:

   (defun my-vc-responsible-backend (file)
     "Return the backend responsible for the unregistered FILE.
   Like `vc-responsible-backend' but only returns a responsible backend."
     (let ((bs vc-handled-backends))
       (while (consp bs)
         (setq bs 
               (if (vc-call-backend (car bs) 'responsible-p file)
                   (car bs)
                 (cdr bs))))

-- Stefan

reply via email to

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