Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Checking vc-state recursively under a directory

1 view
Skip to first unread message

Nordlöw

unread,
Jul 23, 2008, 6:16:15 AM7/23/08
to
Is it somehow possible to check whether all the files under a version-
controlled directory are all up-to-date (updated)? That is like vc-
state() but recursively for a directory?

My reason for asking is that I am writing some emacs lisp snippets
that auto-update-and-rebuild() my Emacs add-ons directly from within
their vc-repositories.

Thanks in advance,
Nordlöw

Nikolaj Schumacher

unread,
Jul 23, 2008, 9:03:50 AM7/23/08
to Nordlöw, help-gn...@gnu.org
Nordlöw <per.n...@gmail.com> wrote:

> Is it somehow possible to check whether all the files under a version-
> controlled directory are all up-to-date (updated)? That is like vc-
> state() but recursively for a directory?

What do you mean? up-to-date or updated? up-to-date means
(not (vc-workfile-unchanged-p "file")), while updated means something like
(file-newer-than-file-p "file.elc" "file.el")

> My reason for asking is that I am writing some emacs lisp snippets
> that auto-update-and-rebuild() my Emacs add-ons directly from within
> their vc-repositories.

Maybe `byte-recompile-directory' could be of help.


regards,
Nikolaj Schumacher


Nordlöw

unread,
Jul 23, 2008, 9:30:08 AM7/23/08
to
On 23 Juli, 15:03, Nikolaj Schumacher <n_schumac...@web.de> wrote:

> Nordlöw <per.nord...@gmail.com> wrote:
> > Is it somehow possible to check whether all the files under a version-
> > controlled directory are all up-to-date (updated)? That is like vc-
> > state() but recursively for a directory?
>
> What do you mean?  up-to-date or updated?  up-to-date means
> (not (vc-workfile-unchanged-p "file")), while updated means something like
> (file-newer-than-file-p "file.elc" "file.el")

I mean like vc-state but for a whole repository, say vc-dir-state(DIR)
and should be behave something like the following (using CVS as
example):
A function that runs "cvs update" and return, say 'up-to-date, if no
file in repository was changed otherwise say 'patched.
If this function returns 'patched we know that something was changed
and we need to rebuild things...

/Nordlöw

Nordlöw

unread,
Jul 23, 2008, 9:39:06 AM7/23/08
to
On 23 Juli, 15:03, Nikolaj Schumacher <n_schumac...@web.de> wrote:
> Nordlöw <per.nord...@gmail.com> wrote:
> > Is it somehow possible to check whether all the files under a version-
> > controlled directory are all up-to-date (updated)? That is like vc-
> > state() but recursively for a directory?
>
> What do you mean?  up-to-date or updated?  up-to-date means
> (not (vc-workfile-unchanged-p "file")), while updated means something like
> (file-newer-than-file-p "file.elc" "file.el")

I looking for a function, say vc-dir-update(DIR), that does "cvs
update" under DIR and returns 'up-to-date if no file was changed or
'patched if some file was updated.

/Nordlöw

Nikolaj Schumacher

unread,
Jul 23, 2008, 10:00:16 AM7/23/08
to Nordlöw, help-gn...@gnu.org
Nordlöw <per.n...@gmail.com> wrote:

I've never used CVS, so think SVN when reading... :)

Since you don't have a revision to compare against that function would
not be idempotent, and if you called "cvs update" manually in-between,
it wouldn't catch the change, either. That's different from what
`vc-state' does, which compares the working copy against the
checkout-out revision (like "svn status"), but doesn't check if the
repository has something newer.

So "like `vc-state'" and what you described are different. Which one do
you want? :)

In SVN you could store the revision when doing a build, and then compare
it to HEAD when deciding whether to do a rebuild.


regards,
Nikolaj Schumacher


Thr4wn

unread,
Jul 25, 2008, 2:59:41 PM7/25/08
to

I think that 'vc-recompute-state is what you want, as it will actually
run "cvs update".

try something like the following (this currently doesn't work because
directory-files is also returning things like the CVS folder which vc-
recompute-state throws an error because it doesn't know how to handle
it):

(progn
(let ((retval nil))
(dolist (cur-file (directory-files dir-path t "^[^\.]") retval)
(push (vc-recompute-state cur-file) retval))))

hopefully that is close to what you're looking for :-)

-Thr4wn

Colin S. Miller

unread,
Jul 28, 2008, 3:31:33 PM7/28/08
to
Nikolaj Schumacher wrote:
>
> Since you don't have a revision to compare against that function would
> not be idempotent, and if you called "cvs update" manually in-between,
> it wouldn't catch the change, either. That's different from what
> `vc-state' does, which compares the working copy against the
> checkout-out revision (like "svn status"), but doesn't check if the
> repository has something newer.
>
In this case, the OP would want to use (nth (file-attributes filename) 5)
for all files in the directory of interest.
This gives the mtime of the file as a list, in the same format as (current-time)
except that (current-time) gives usec as well.


>
>
> regards,
> Nikolaj Schumacher
>
>


--
Replace the obvious in my email address with the first three letters of the hostname to reply.

0 new messages