97 if (defined @config::notify_dirs || $opt_initdir) { |
98 if (defined @config::notify_dirs || $opt_initdir) { |
98 check_hg_bin(); |
99 check_hg_bin(); |
99 } |
100 } |
100 |
101 |
101 if ($opt_initdir) { |
102 if ($opt_initdir) { |
102 print "$ME: Trying to initialize $opt_initdir as mercurial repository.\n"; |
103 my $repo = Logbuch::HG->new( repo => $opt_initdir ); |
103 -d $opt_initdir or |
104 |
104 die "$ME: directory $opt_initdir does not exist!"; |
105 $repo->is_repository() and |
105 |
|
106 system("hg status $opt_initdir > /dev/null 2>&1"); |
|
107 if (($? >> 8) == 0) { |
|
108 die "$ME: directory already initialized, skipping\n"; |
106 die "$ME: directory already initialized, skipping\n"; |
109 } |
107 |
110 |
108 $repo->init() or |
111 system("hg init $opt_initdir"); |
|
112 if ( ($? >> 8) != 0) { |
|
113 die "E: initialization failed\n"; |
109 die "E: initialization failed\n"; |
114 } else { |
110 |
115 system("cd $opt_initdir && hg addremove && hg commit -m 'initial autocommit'"); |
111 $repo->addremove(); |
116 print "$ME: initialization done.\n"; |
112 $repo->commit("initial check in"); |
117 } |
|
118 |
113 |
119 exit 0; |
114 exit 0; |
120 } |
115 } |
121 |
116 |
122 my $hg_status_text = ""; |
117 my $hg_status_text = ""; |
123 if (defined @config::notify_dirs) { |
118 if (defined @config::notify_dirs) { |
124 foreach my $dir (@config::notify_dirs) { |
119 foreach my $dir (@config::notify_dirs) { |
125 -d $dir or next; |
120 -d $dir or next; |
126 |
121 |
127 print "$ME: Checking $dir for modifications\n"; |
122 print "$ME: Checking $dir for modifications\n"; |
128 -d "$dir/.hg" or |
123 |
129 die "$ME: directory $dir not initialized pleas call: \n", |
124 my $repo = Logbuch::HG->new( repo => $dir ); |
|
125 $repo->is_repository() or |
|
126 die "$ME: directory $dir not initialized please call: \n", |
130 " # $ME --init-dir $dir \n"; |
127 " # $ME --init-dir $dir \n"; |
131 |
128 |
132 system("hg addremove $dir"); |
129 $repo->addremove(); |
133 |
130 $hg_status_text .= $repo->status(); |
134 $hg_status_text .= `cd / && hg status $dir`; |
|
135 } |
131 } |
136 } |
132 } |
137 |
133 |
138 if ($opt_db) { |
134 if ($opt_db) { |
139 $Dbh = DBI->connect($DSN, $USER, $PW, {RaiseError => 1}) |
135 $Dbh = DBI->connect($DSN, $USER, $PW, {RaiseError => 1}) |
272 } |
269 } |
273 |
270 |
274 |
271 |
275 sub check_hg_bin() |
272 sub check_hg_bin() |
276 { |
273 { |
277 if (not defined which('hg')) { |
274 if (not Logbuch::HG::hg_available()) { |
278 print STDERR << 'EOF'; |
275 |
|
276 die <<'EOF'; |
279 |
277 |
280 You requested an operation based on hg/mercurial but this tool is |
278 You requested an operation based on hg/mercurial but this tool is |
281 not installed! |
279 not installed! |
282 |
280 |
283 Either you could change the configuration in /etc/lobbuch/config.pm and |
281 Either you could change the configuration in /etc/lobbuch/config.pm and |
284 remove lines starting with @notify_dirs, or you could simply install the |
282 remove lines starting with @notify_dirs, or you could simply install the |
285 required packages: |
283 required packages: |
286 |
284 |
287 # aptitude install mercurial |
285 # aptitude install mercurial rcs |
288 |
286 |
289 Exiting! |
287 Exiting! |
290 EOF |
288 EOF |
291 exit 1; |
|
292 } |
289 } |
293 } |
290 } |
294 |
291 |
295 |
292 |
296 # vim:sts=4 sw=4 aw ai sm: |
293 # vim:sts=4 sw=4 aw ai sm: |