diff -r b3edfead728b -r d9694ca1b7fc log.pl --- a/log.pl Tue Feb 03 11:00:50 2009 +0000 +++ b/log.pl Wed Feb 11 10:34:18 2009 +0000 @@ -20,12 +20,13 @@ use File::Basename; use File::Temp qw(tempfile); use File::stat; -use File::Which; use Getopt::Long; use Mail::Mailer; use DBI; use MIME::QuotedPrint; +use Logbuch::HG; + use lib "/etc/logbuch"; use config; @@ -53,8 +54,8 @@ my $EDITOR = $ENV{VISUAL} || $ENV{EDITOR} || "vim"; my $MAGIC = "#--- all changes below are ignored ---#\n"; -my $opt_db = 0; -my $opt_mail = 0; +my $opt_db = 1; +my $opt_mail = 1; my $opt_message = ""; my $opt_apt = ""; my $opt_initdir = ""; @@ -99,22 +100,16 @@ } if ($opt_initdir) { - print "$ME: Trying to initialize $opt_initdir as mercurial repository.\n"; - -d $opt_initdir or - die "$ME: directory $opt_initdir does not exist!"; + my $repo = Logbuch::HG->new( repo => $opt_initdir ); - system("hg status $opt_initdir > /dev/null 2>&1"); - if (($? >> 8) == 0) { + $repo->is_repository() and die "$ME: directory already initialized, skipping\n"; - } - system("hg init $opt_initdir"); - if ( ($? >> 8) != 0) { + $repo->init() or die "E: initialization failed\n"; - } else { - system("cd $opt_initdir && hg addremove && hg commit -m 'initial autocommit'"); - print "$ME: initialization done.\n"; - } + + $repo->addremove(); + $repo->commit("initial check in"); exit 0; } @@ -125,13 +120,14 @@ -d $dir or next; print "$ME: Checking $dir for modifications\n"; - -d "$dir/.hg" or - die "$ME: directory $dir not initialized pleas call: \n", + + my $repo = Logbuch::HG->new( repo => $dir ); + $repo->is_repository() or + die "$ME: directory $dir not initialized please call: \n", " # $ME --init-dir $dir \n"; - system("hg addremove $dir"); - - $hg_status_text .= `cd / && hg status $dir`; + $repo->addremove(); + $hg_status_text .= $repo->status(); } } @@ -236,7 +232,8 @@ foreach my $dir (@config::notify_dirs) { -d $dir or next; - system("cd $dir && hg commit -m 'autocommit by logbuch'"); + my $repo = Logbuch::HG->new( repo => $dir ); + $repo->commit(); } } } @@ -274,8 +271,9 @@ sub check_hg_bin() { - if (not defined which('hg')) { - print STDERR << 'EOF'; + if (not Logbuch::HG::hg_available()) { + + die <<'EOF'; You requested an operation based on hg/mercurial but this tool is not installed! @@ -284,11 +282,10 @@ remove lines starting with @notify_dirs, or you could simply install the required packages: - # aptitude install mercurial + # aptitude install mercurial rcs Exiting! EOF - exit 1; } }