running bzr commit on only modified files as a daily cron job

Matt Nordhoff mnordhoff at mattnordhoff.com
Thu Apr 3 02:58:44 BST 2008


Rahul Nabar wrote:
> A while ago I had posted on the group about versioning config and
> script files scattered throughout my linux home dir using bazaar. I
> got a good system up and running after many excellent suggestions I
> got from other posters. (including a .bzignore with * etc.)
> 
> Here's a new idea I wanted more opinions  on: Frequently I edit a
> script and forget to do a bzr commit. Could I set up a daily cron job
> that does this (pseudocode):
> 
> foreach (filename in bzr inventory)
> {
>            if (`bzr status filename` == M)
>            {
>                    `bzr commit  --message="todays date" filename`
>            }
> }
> 
> Shouldn't this "idiot proof" my attempt to keep a versioned copy of
> all my scripts and configs? i.e. if I did remember to commit then the
> bazaar status will exclude that file from the daily cronjob. But for
> those that I did forget I have a spare "daily" snapshot? ( I can
> always keep doing manual commits after important changes just as
> normal.)
> 
> Any pitfalls or other advice from other users? Pros / cons?
> 
> -Rahul

As Martin Pool said, why not commit the whole tree? Also, you don't need
to check if there are modified files. If you just try "bzr commit" and
there are no changes, it won't do anything.

Also, if you did want to commit each file separately for some reason,
doing a "status" on each file in the inventory isn't very efficient. You
could parse the output from a "bzr status" on the whole tree. It would
probably be even better to write the script in Python and use bzrlib's API..
-- 



More information about the bazaar mailing list