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 if (not $options{hooks_only}) {
101 qx(svn --version) =~ /\(r(\d+)\)/;
103 $CAN_IGNORE_EXTERNALS = 1;
107 sub available_config_files{
109 opendir($dir, "$HOME/.sa.d/") or return ();
110 return map {"$HOME/.sa.d/$_"} grep /^[\w\d][\w\d_.-]+$/, readdir $dir;
114 for ('/etc/sa.conf', available_config_files()) {
116 parse_config_file(\%repos,$_,$HOME);
120 $DEBUG = $options{debug};
121 $VERBOSE = $options{verbose};
125 if (@ARGV and $ARGV[0] =~ /^(st(?:atus)?|up(?:date)?|checkout)$/) {
132 while (my ($repo,$run_after) = each(%repos)) {
133 print "Checking [$repo]\n";
134 if (-e "$repo/.svn" and not $options{hooks_only}) {
137 (not $VERBOSE and $options{quiet})?'-q':(),
138 ($VERBOSE >= 2)?'-v':(),
139 ($options{quick} and $CAN_IGNORE_EXTERNALS)?'--ignore-externals':(),
140 $options{quick}>1?'-N':(),
144 if ($command =~ /^up(?:date)?|checkout$/) {
145 system('sh', '-c',"$run_after $repo") if defined $run_after and length $run_after;