15 sa [options] [status|update|checkout] [directories to sync]
18 --quick, -Q don't update external projects
19 --verbose, -v be more verbose
21 --debug, -d debugging level (Default 0)
22 --help, -h display this help
23 --man, -m display manual
31 Debug verbosity. (Default 0)
35 Display brief useage information.
51 use vars qw($DEBUG $VERBOSE);
53 my %options = (quick => 1,
62 GetOptions(\%options,'quick|Q+','quiet|q!','debug|d+','help|h|?','man|m','verbose|v+','hooks_only|hooks-only');
64 pod2usage() if $options{help};
65 pod2usage({verbose=>2}) if $options{man};
67 # parse configuration file
71 Reads configuration information from Start by parsing /etc/sa.conf,
72 then the contents of ~/sa.d/ which match ^[\w\d][\w\d_.-]+$
74 The configuration file contains a list of svn repositories which
75 should be queried; each line can contain a tab, which indicates that
76 the command following the tab should be run after the svn directory is
79 The configuration files are read in the order given above.
83 sub parse_config_file {
84 my ($repos,$filename,$home) = @_;
85 return unless -e $filename and -r _;
86 my $fh = new IO::File $filename, 'r' or die "Unable to read configuration file $filename $!";
90 my ($repo,$command) = split /\t/,$_,2;
91 $repo =~ s/^\~/$home/;
92 $$repos{$repo} = $command;
97 my $HOSTNAME=qx(hostname);
99 my $CAN_IGNORE_EXTERNALS = 0;
100 qx(svn --version) =~ /\(r(\d+)\)/;
102 $CAN_IGNORE_EXTERNALS = 1;
105 sub available_config_files{
107 opendir($dir, "$HOME/.sa.d/") or return ();
108 return map {"$HOME/.sa.d/$_"} grep /^[\w\d][\w\d_.-]+$/, readdir $dir;
112 for ('/etc/sa.conf', available_config_files()) {
114 parse_config_file(\%repos,$_,$HOME);
118 $DEBUG = $options{debug};
119 $VERBOSE = $options{verbose};
123 if (@ARGV and $ARGV[0] =~ /^(st(?:atus)?|up(?:date)?|checkout)$/) {
130 while (my ($repo,$run_after) = each(%repos)) {
131 print "Checking [$repo]\n";
132 if (-e "$repo/.svn" and not $options{hooks_only}) {
135 (not $VERBOSE and $options{quiet})?'-q':(),
136 ($VERBOSE >= 2)?'-v':(),
137 ($options{quick} and $CAN_IGNORE_EXTERNALS)?'--ignore-externals':(),
138 $options{quick}>1?'-N':(),
142 if ($command =~ /^up(?:date)?|checkout$/) {
143 system('sh', '-c',"$run_after $repo") if defined $run_after and length $run_after;