[186] | 1 | #!/usr/bin/perl -w
|
---|
| 2 |
|
---|
| 3 | # $Id: dasscm 251 2008-10-15 12:29:56Z joergs $
|
---|
| 4 |
|
---|
| 5 | use strict;
|
---|
| 6 |
|
---|
[208] | 7 | use Env
|
---|
[235] | 8 | qw($DASSCM_PROD $DASSCM_REPO $USER $DASSCM_USERNAME $DASSCM_USER $DASSCM_PASSWORD $SHELL);
|
---|
[186] | 9 | use Cwd;
|
---|
[214] | 10 | use Getopt::Long;
|
---|
[186] | 11 | use File::Basename;
|
---|
[209] | 12 | use File::Compare;
|
---|
| 13 | use File::Copy;
|
---|
[237] | 14 | use File::Find;
|
---|
[186] | 15 | use File::stat;
|
---|
| 16 | use File::Path;
|
---|
[214] | 17 | use Term::ReadKey;
|
---|
[239] | 18 |
|
---|
[234] | 19 | #use Data::Dumper;
|
---|
[186] | 20 |
|
---|
[189] | 21 | #####################################################################
|
---|
| 22 | #
|
---|
[186] | 23 | # global
|
---|
[189] | 24 | #
|
---|
[205] | 25 |
|
---|
[215] | 26 | # file to store permissions
|
---|
| 27 | my $permissions_file = "/etc/permissions.d/dasscm.permission_backup";
|
---|
[220] | 28 |
|
---|
[238] | 29 | # documentation file (for usage)
|
---|
| 30 | my $doc_file = "/usr/share/doc/packages/dasscm/dasscm_howto.txt";
|
---|
| 31 |
|
---|
[215] | 32 | # configuration file
|
---|
[205] | 33 | my $config_file = "/etc/dasscm.conf";
|
---|
[234] | 34 | my $config = get_config($config_file);
|
---|
[205] | 35 | my $DASSCM_LOCAL_REPOSITORY_BASE;
|
---|
| 36 | my $DASSCM_REPOSITORY_NAME;
|
---|
| 37 | my $DASSCM_SVN_REPOSITORY;
|
---|
[247] | 38 | my $DASSCM_CHECKOUT_USERNAME;
|
---|
| 39 | my $DASSCM_CHECKOUT_PASSWORD;
|
---|
[205] | 40 |
|
---|
[247] | 41 |
|
---|
[238] | 42 | # current directory at program start
|
---|
| 43 | my $StartDirectory = cwd();
|
---|
| 44 |
|
---|
[205] | 45 | my $SVN = "svn ";
|
---|
| 46 | my $svnOptions = "";
|
---|
| 47 | my $svnCheckoutCredentials = "";
|
---|
| 48 | my $svnPasswordCredentials = "";
|
---|
[238] | 49 | my $diff = "diff --exclude .svn ";
|
---|
[205] | 50 |
|
---|
[196] | 51 | # command line options get stored in options hash
|
---|
[205] | 52 | my %options = ();
|
---|
| 53 |
|
---|
[197] | 54 | # subcommand, that gets executed (add, commit, ...)
|
---|
[196] | 55 | my $command;
|
---|
[186] | 56 |
|
---|
[205] | 57 | my $verbose = 0;
|
---|
| 58 |
|
---|
[189] | 59 | #####################################################################
|
---|
| 60 | #
|
---|
[186] | 61 | # util functions
|
---|
[189] | 62 | #
|
---|
[187] | 63 | sub usage()
|
---|
| 64 | {
|
---|
[205] | 65 | print "usage: dasscm <subcommand> [options] [args]\n";
|
---|
| 66 | print "\n";
|
---|
| 67 | print "dasscm is intended to help versioning configuration files\n";
|
---|
| 68 | print "\n";
|
---|
| 69 | print "Available subcommands:\n";
|
---|
[215] | 70 | print " help <subcommand>\n";
|
---|
[205] | 71 | print " init\n";
|
---|
| 72 | print " login\n";
|
---|
[215] | 73 | print " up\n";
|
---|
| 74 | print " ls\n";
|
---|
[205] | 75 | print " add <filename>\n";
|
---|
| 76 | print " commit <filename>\n";
|
---|
| 77 | print " diff <filename>\n";
|
---|
[236] | 78 | print " status\n";
|
---|
[215] | 79 | print " permissions\n";
|
---|
[205] | 80 | print "\n";
|
---|
[238] | 81 | print "preparation:\n", " if dasscm is already configured,\n",
|
---|
[236] | 82 | " use 'dasscm login' and then eg. 'add'.\n",
|
---|
[220] | 83 | " The environment variables\n", " DASSCM_REPO\n", " DASSCM_PROD\n",
|
---|
| 84 | " DASSCM_USERNAME\n", " DASSCM_PASSWORD\n",
|
---|
| 85 | " are evaluated, but set automatically by 'dasscm login'.\n", "\n",
|
---|
[239] | 86 | " If dasscm is not yet configured, read", " $doc_file\n";
|
---|
[187] | 87 | }
|
---|
| 88 |
|
---|
[233] | 89 | sub warning(@)
|
---|
| 90 | {
|
---|
| 91 | print "Warning: " . join( "\n ", @_ ) . "\n";
|
---|
| 92 | }
|
---|
| 93 |
|
---|
| 94 | sub error(@)
|
---|
| 95 | {
|
---|
| 96 | print "Error: " . join( "\n ", @_ ) . "\n";
|
---|
| 97 | }
|
---|
| 98 |
|
---|
| 99 | sub fatalerror(@)
|
---|
| 100 | {
|
---|
[239] | 101 | error(@_);
|
---|
| 102 |
|
---|
[233] | 103 | #print "Exiting\n";
|
---|
[239] | 104 | exit 1;
|
---|
[233] | 105 | }
|
---|
| 106 |
|
---|
[238] | 107 | #
|
---|
| 108 | # reading config file and return key/value pairs as hash
|
---|
| 109 | #
|
---|
[234] | 110 | sub get_config
|
---|
| 111 | {
|
---|
[239] | 112 | my $file = $_[0];
|
---|
[234] | 113 |
|
---|
[239] | 114 | if ( !$file ) {
|
---|
[234] | 115 | fatalerror( "failed to open config file" . $file );
|
---|
| 116 | }
|
---|
| 117 |
|
---|
| 118 | my $data = {};
|
---|
| 119 |
|
---|
| 120 | # try to open config file
|
---|
| 121 | if ( !open( FH, $file ) ) {
|
---|
| 122 | fatalerror( "failed to open config file" . $file );
|
---|
| 123 | } else {
|
---|
| 124 | while (<FH>) {
|
---|
| 125 | chomp;
|
---|
| 126 | if (/^#/) {
|
---|
| 127 | next;
|
---|
| 128 | }
|
---|
| 129 | if ( $_ =~ /=/g ) {
|
---|
[239] | 130 |
|
---|
[238] | 131 | # splitting in 2 fields at maximum
|
---|
[234] | 132 | my ( $option, $value ) = split( /=/, $_, 2 );
|
---|
| 133 | $option =~ s/^\s+//g;
|
---|
| 134 | $option =~ s/\s+$//g;
|
---|
| 135 | $option =~ s/\"+//g;
|
---|
| 136 | $value =~ s/^\s+//g;
|
---|
| 137 | $value =~ s/\s+$//g;
|
---|
| 138 | $value =~ s/\"+//g;
|
---|
| 139 |
|
---|
| 140 | if ( length($option) ) {
|
---|
| 141 | $data->{$option} = $value;
|
---|
| 142 | }
|
---|
| 143 | }
|
---|
| 144 | }
|
---|
| 145 | }
|
---|
| 146 | close(FH);
|
---|
| 147 |
|
---|
| 148 | return $data;
|
---|
| 149 | }
|
---|
| 150 |
|
---|
[186] | 151 | sub check_env()
|
---|
| 152 | {
|
---|
[205] | 153 |
|
---|
| 154 | # DASSCM_PROD
|
---|
| 155 | if ( !$DASSCM_PROD ) {
|
---|
| 156 | $DASSCM_PROD = "/";
|
---|
| 157 | }
|
---|
| 158 |
|
---|
| 159 | if ( !-d $DASSCM_PROD ) {
|
---|
| 160 | die "DASSCM_PROD ($DASSCM_PROD) is not set to a directory.\n";
|
---|
| 161 | }
|
---|
| 162 | if ($verbose) { print "DASSCM_PROD: " . $DASSCM_PROD . "\n"; }
|
---|
| 163 |
|
---|
| 164 | # DASSCM_REPOSITORY_NAME
|
---|
[208] | 165 | if ( !$DASSCM_REPOSITORY_NAME ) {
|
---|
| 166 | die
|
---|
| 167 | "Variable DASSCM_REPOSITORY_NAME is not defined.\nIt needs to be a unique name.\nNormally the full qualified host name is used.\nUse file $config_file to configure it.\n";
|
---|
| 168 | }
|
---|
[205] | 169 |
|
---|
| 170 | # DASSCM_REPO
|
---|
| 171 | if ( !$DASSCM_REPO ) {
|
---|
| 172 | if ( $DASSCM_LOCAL_REPOSITORY_BASE && $DASSCM_REPOSITORY_NAME ) {
|
---|
| 173 | $DASSCM_REPO =
|
---|
| 174 | $DASSCM_LOCAL_REPOSITORY_BASE . "/" . $DASSCM_REPOSITORY_NAME;
|
---|
| 175 | } else {
|
---|
| 176 | die
|
---|
| 177 | "Envirnonment variable DASSCM_REPO not set.\nSet DASSCM_REPO to the directory of the versioning system checkout for this machine.\n";
|
---|
| 178 | }
|
---|
| 179 | }
|
---|
[215] | 180 | if ($verbose) { print "DASSCM_REPO: " . $DASSCM_REPO . "\n"; }
|
---|
[205] | 181 |
|
---|
[248] | 182 |
|
---|
[205] | 183 | #
|
---|
[248] | 184 | # subversion checkout user
|
---|
| 185 | #
|
---|
| 186 | if( ! $DASSCM_CHECKOUT_USERNAME ) {
|
---|
| 187 | fatalerror(
|
---|
| 188 | "variable DASSCM_CHECKOUT_USERNAME is not defined.",
|
---|
| 189 | "Use file $config_file to configure it." );
|
---|
| 190 | }
|
---|
| 191 |
|
---|
| 192 | if( ! $DASSCM_CHECKOUT_PASSWORD ) {
|
---|
| 193 | fatalerror(
|
---|
| 194 | "variable DASSCM_CHECKOUT_PASSWORD is not defined.",
|
---|
| 195 | "Use file $config_file to configure it." );
|
---|
| 196 | }
|
---|
| 197 |
|
---|
| 198 |
|
---|
| 199 | #
|
---|
[239] | 200 | # check if local repository directory exist
|
---|
[235] | 201 | # (if not creating by init)
|
---|
[205] | 202 | #
|
---|
| 203 | if ( $command ne "init" ) {
|
---|
| 204 | if ( not -d $DASSCM_REPO ) {
|
---|
| 205 | die
|
---|
[208] | 206 | "Can't access local repository DASSCM_REPO\n($DASSCM_REPO)\nCheck configuration and execute\n dasscm init\n";
|
---|
[205] | 207 | }
|
---|
[208] | 208 |
|
---|
[205] | 209 | #
|
---|
| 210 | # user settings
|
---|
| 211 | #
|
---|
[208] | 212 |
|
---|
[205] | 213 | # DASSCM_USER is legacy. Use DASSCM_USERNAME instead
|
---|
[208] | 214 | if ( !$DASSCM_USERNAME ) {
|
---|
| 215 | $DASSCM_USERNAME = $DASSCM_USER;
|
---|
[205] | 216 | }
|
---|
| 217 |
|
---|
| 218 | # user root is not allowed for checkins.
|
---|
| 219 | # if user is root, DASSCM_USER has to be set,
|
---|
| 220 | # otherwise USER can be used
|
---|
| 221 | if ( "$USER" eq "root" ) {
|
---|
[208] | 222 | if ( ( not $DASSCM_USERNAME ) and ( $command ne "login" ) ) {
|
---|
[247] | 223 | fatalerror( "Envirnonment variable DASSCM_USERNAME not set.", "Set DASSCM_USERNAME to your subversion user account or", "use 'dasscm login'" );
|
---|
[205] | 224 | }
|
---|
| 225 | $svnOptions .= " --no-auth-cache ";
|
---|
| 226 | } elsif ( !$DASSCM_USERNAME ) {
|
---|
| 227 | $DASSCM_USERNAME = $USER;
|
---|
| 228 | }
|
---|
| 229 |
|
---|
| 230 | #
|
---|
| 231 | # password
|
---|
| 232 | #
|
---|
[208] | 233 | if ($DASSCM_PASSWORD) {
|
---|
[205] | 234 | $svnPasswordCredentials = " --password $DASSCM_PASSWORD ";
|
---|
| 235 | }
|
---|
| 236 | }
|
---|
| 237 |
|
---|
| 238 | #$svnOptions .= " --username $DASSCM_USERNAME "
|
---|
[186] | 239 | }
|
---|
| 240 |
|
---|
| 241 | sub check_parameter(@)
|
---|
| 242 | {
|
---|
| 243 | }
|
---|
| 244 |
|
---|
[238] | 245 | #
|
---|
[239] | 246 | # generate from (relative) filename
|
---|
[238] | 247 | # all required file and directory names:
|
---|
| 248 | # $basename, $dirname_prod, $dirname_repo,
|
---|
| 249 | # $filename_prod, $filename_repo
|
---|
| 250 | #
|
---|
[187] | 251 | sub get_filenames(@)
|
---|
| 252 | {
|
---|
[250] | 253 | my $filename_prod = $_[0] || ".";
|
---|
[237] | 254 |
|
---|
[238] | 255 | # make filename absolut
|
---|
[205] | 256 | if ( !( $filename_prod =~ m/^\// ) ) {
|
---|
| 257 | $filename_prod = cwd() . "/" . $filename_prod;
|
---|
| 258 | }
|
---|
[187] | 259 |
|
---|
[239] | 260 | if ( not -r $filename_prod ) {
|
---|
| 261 | fatalerror( $filename_prod . " is not accessable" );
|
---|
[233] | 262 | }
|
---|
[205] | 263 |
|
---|
| 264 | # TODO: dirname buggy: eg. "/etc/" is reduced to "/",
|
---|
| 265 | # "/etc" is used as filename
|
---|
| 266 | my $dirname_prod = dirname($filename_prod);
|
---|
[238] | 267 |
|
---|
| 268 | # uses chdir to determine real directory in a unique way
|
---|
[205] | 269 | chdir $dirname_prod or die $!;
|
---|
| 270 | $dirname_prod = cwd();
|
---|
[238] | 271 | chdir $StartDirectory;
|
---|
| 272 |
|
---|
[205] | 273 | my $basename = basename($filename_prod);
|
---|
| 274 |
|
---|
[214] | 275 | if ($verbose) {
|
---|
| 276 | print "dir: " . $dirname_prod . "\n";
|
---|
| 277 | print "fn: " . $basename . "\n";
|
---|
| 278 | }
|
---|
[205] | 279 |
|
---|
| 280 | my $dirname_repo = $DASSCM_REPO . "/" . $dirname_prod;
|
---|
| 281 | my $filename_repo = "$dirname_repo/$basename";
|
---|
| 282 |
|
---|
| 283 | return (
|
---|
| 284 | $basename, $dirname_prod, $dirname_repo,
|
---|
| 285 | $filename_prod, $filename_repo
|
---|
| 286 | );
|
---|
[187] | 287 | }
|
---|
| 288 |
|
---|
[215] | 289 | sub generatePermissionList
|
---|
[209] | 290 | {
|
---|
| 291 |
|
---|
[215] | 292 | # generieren der Zeilen für Permission-Savefile
|
---|
| 293 | my @files = @_;
|
---|
| 294 | my @permlist = ();
|
---|
| 295 | foreach my $file (@files) {
|
---|
[227] | 296 | $file = "/" . $file;
|
---|
[239] | 297 | if ( -e $file ) {
|
---|
| 298 | my $info = stat($file) || die "failed to stat $file: aborting";
|
---|
| 299 | my $mode = get_type( $info->mode ) & 07777;
|
---|
[227] | 300 | my $modestring = sprintf( "%04o", $mode );
|
---|
| 301 | my $uid = $info->uid;
|
---|
| 302 | my $uidname = getpwuid($uid);
|
---|
| 303 | my $gid = $info->gid;
|
---|
| 304 | my $gidname = getgrgid($gid);
|
---|
| 305 | push(
|
---|
| 306 | @permlist,
|
---|
| 307 | sprintf( "%-55s %-17s %4d",
|
---|
| 308 | $file, "${uidname}:${gidname}", $modestring )
|
---|
| 309 | );
|
---|
| 310 | } else {
|
---|
[239] | 311 | print
|
---|
| 312 | "failed to get status of $file. It exists in the repository, but not on the system\n";
|
---|
[227] | 313 | }
|
---|
[215] | 314 | }
|
---|
| 315 | return @permlist;
|
---|
| 316 | }
|
---|
[209] | 317 |
|
---|
[215] | 318 | sub get_type
|
---|
| 319 | {
|
---|
[209] | 320 |
|
---|
[215] | 321 | # Funktion übernommen aus /usr/bin/chkstat
|
---|
| 322 | my $S_IFLNK = 0120000; # symbolic link
|
---|
| 323 | my $S_IFREG = 0100000; # regular file
|
---|
| 324 | my $S_IFDIR = 0040000; # directory
|
---|
| 325 | my $S_IFCHAR = 0020000; # character device
|
---|
| 326 | my $S_IFBLK = 0060000; # block device
|
---|
| 327 | my $S_IFFIFO = 0010000; # fifo
|
---|
| 328 | my $S_IFSOCK = 0140000; # socket
|
---|
| 329 | my $S_IFMT = 0170000; # type of file
|
---|
[209] | 330 |
|
---|
[215] | 331 | my $S_m;
|
---|
| 332 | if ( ( $_[0] & $S_IFMT ) == $S_IFLNK ) { $S_m = $_[0] - $S_IFLNK; }
|
---|
| 333 | elsif ( ( $_[0] & $S_IFMT ) == $S_IFREG ) { $S_m = $_[0] - $S_IFREG; }
|
---|
| 334 | elsif ( ( $_[0] & $S_IFMT ) == $S_IFDIR ) { $S_m = $_[0] - $S_IFDIR; }
|
---|
| 335 | elsif ( ( $_[0] & $S_IFMT ) == $S_IFCHAR ) { $S_m = $_[0] - $S_IFCHAR; }
|
---|
| 336 | elsif ( ( $_[0] & $S_IFMT ) == $S_IFBLK ) { $S_m = $_[0] - $S_IFBLK; }
|
---|
| 337 | elsif ( ( $_[0] & $S_IFMT ) == $S_IFFIFO ) { $S_m = $_[0] - $S_IFFIFO; }
|
---|
| 338 | elsif ( ( $_[0] & $S_IFMT ) == $S_IFSOCK ) { $S_m = $_[0] - $S_IFSOCK; }
|
---|
| 339 | $S_m;
|
---|
[209] | 340 | }
|
---|
| 341 |
|
---|
[186] | 342 | sub run_command
|
---|
| 343 | {
|
---|
[205] | 344 | my $command = shift;
|
---|
[186] | 345 |
|
---|
[205] | 346 | #print "executing command: " . $command . "\n";
|
---|
[186] | 347 |
|
---|
[205] | 348 | open( RESULT, $command . ' 2>&1 |' );
|
---|
| 349 | my @result = <RESULT>;
|
---|
| 350 | close(RESULT);
|
---|
| 351 | my $retcode = $? >> 8;
|
---|
[186] | 352 |
|
---|
[205] | 353 | #print @result;
|
---|
| 354 | #if( $retcode ) { print "return code: " . $retcode . "\n"; }
|
---|
[186] | 355 |
|
---|
[205] | 356 | return ( $retcode, @result );
|
---|
[186] | 357 | }
|
---|
| 358 |
|
---|
[205] | 359 | sub run_interactive
|
---|
| 360 | {
|
---|
[186] | 361 |
|
---|
[208] | 362 | if ($verbose) {
|
---|
[205] | 363 | print "run_interactive:" . join( " ", @_ ) . "\n";
|
---|
| 364 | }
|
---|
[196] | 365 |
|
---|
[205] | 366 | system(@_);
|
---|
| 367 | if ( $? == -1 ) {
|
---|
| 368 | printf "failed to execute: $!\n";
|
---|
| 369 | } elsif ( $? & 127 ) {
|
---|
| 370 | printf "child died with signal %d, %s coredump\n", ( $? & 127 ),
|
---|
| 371 | ( $? & 128 ) ? 'with' : 'without';
|
---|
| 372 | } elsif ( $? >> 8 != 0 ) {
|
---|
| 373 | printf "child exited with value %d\n", $? >> 8;
|
---|
| 374 | }
|
---|
| 375 | return ( $? >> 8 );
|
---|
| 376 | }
|
---|
| 377 |
|
---|
[247] | 378 |
|
---|
| 379 |
|
---|
| 380 | sub svn_check_credentials( $$;$$ )
|
---|
[196] | 381 | {
|
---|
[205] | 382 | my $username = shift;
|
---|
| 383 | my $password = shift;
|
---|
| 384 |
|
---|
[247] | 385 | # check silently are allow user interaction?
|
---|
| 386 | my $interactive = shift || 0;
|
---|
[220] | 387 |
|
---|
[247] | 388 | # default: exit program, if repository is not accessable
|
---|
| 389 | # (do not exit for 'init')
|
---|
| 390 | my $fatalerror = shift || 1;
|
---|
| 391 |
|
---|
| 392 |
|
---|
| 393 |
|
---|
| 394 | print "checking credentials ";
|
---|
| 395 |
|
---|
[239] | 396 | if ( !$username ) {
|
---|
| 397 | fatalerror("no username given");
|
---|
[238] | 398 | }
|
---|
| 399 |
|
---|
[239] | 400 | if ( !$password ) {
|
---|
| 401 | fatalerror("no password given");
|
---|
[238] | 402 | }
|
---|
| 403 |
|
---|
[247] | 404 | print "for " . $username . "@" . $DASSCM_SVN_REPOSITORY . ": ";
|
---|
| 405 |
|
---|
[220] | 406 | # Options for "svn info" are not supported by subversion 1.0.0 (SLES9),
|
---|
| 407 | # therefore switching to "svn status"
|
---|
| 408 | # ( my $rc_update, my @result ) =
|
---|
| 409 | # run_command(
|
---|
| 410 | # "$SVN info --non-interactive --no-auth-cache --username $username --password $password $DASSCM_SVN_REPOSITORY"
|
---|
| 411 | # );
|
---|
| 412 | #print @result;
|
---|
| 413 |
|
---|
[247] | 414 | my $rc_update;
|
---|
| 415 | if( $interactive ) {
|
---|
| 416 | $rc_update = run_interactive( "$SVN ls --no-auth-cache --username $username --password $password $DASSCM_SVN_REPOSITORY" );
|
---|
| 417 | } else {
|
---|
| 418 | ( $rc_update, my @result ) =
|
---|
| 419 | run_command(
|
---|
| 420 | "$SVN ls --non-interactive --no-auth-cache --username $username --password $password $DASSCM_SVN_REPOSITORY"
|
---|
| 421 | );
|
---|
| 422 |
|
---|
| 423 | if ( $rc_update != 0 ) {
|
---|
| 424 | print "\n", @result;
|
---|
| 425 | if( $fatalerror ) {
|
---|
| 426 | fatalerror();
|
---|
| 427 | }
|
---|
| 428 | return;
|
---|
| 429 | }
|
---|
[205] | 430 | }
|
---|
| 431 |
|
---|
[247] | 432 | # return success
|
---|
| 433 | return $rc_update == 0;
|
---|
[196] | 434 | }
|
---|
| 435 |
|
---|
[247] | 436 |
|
---|
| 437 |
|
---|
[205] | 438 | sub svn_update( ;$ )
|
---|
| 439 | {
|
---|
| 440 | my $update_path = shift || $DASSCM_REPO;
|
---|
| 441 | ( my $rc_update, my @result ) =
|
---|
[220] | 442 | run_command(
|
---|
| 443 | "$SVN update --non-interactive $svnCheckoutCredentials $update_path");
|
---|
[215] | 444 | print @result;
|
---|
[205] | 445 | if ( $rc_update != 0 ) {
|
---|
[238] | 446 | fatalerror();
|
---|
[205] | 447 | }
|
---|
[215] | 448 | }
|
---|
[196] | 449 |
|
---|
[215] | 450 | sub svn_getStoredFiles( ;$ )
|
---|
| 451 | {
|
---|
[220] | 452 |
|
---|
[215] | 453 | # TODO: get_filenames?
|
---|
| 454 | #my $rel_path = shift || "";
|
---|
| 455 | #my $path = "${DASSCM_REPO}/${rel_path}";
|
---|
| 456 | my $path = ${DASSCM_REPO};
|
---|
[220] | 457 |
|
---|
[218] | 458 | # svn ls -R is better, but much, much slower
|
---|
| 459 | # ( my $rc, my @result ) = run_command("$SVN ls --recursive $svnCheckoutCredentials $path");
|
---|
[220] | 460 | ( my $rc, my @result ) =
|
---|
| 461 | run_command(
|
---|
[249] | 462 | "cd $path && find | grep -v '/.svn' | sed -e 's/\.\\///' | grep -v '^[\.]\$'"
|
---|
[220] | 463 | );
|
---|
[215] | 464 | if ( $rc != 0 ) {
|
---|
| 465 | print @result;
|
---|
[238] | 466 | fatalerror;
|
---|
[215] | 467 | }
|
---|
| 468 | chomp(@result);
|
---|
| 469 | return @result;
|
---|
[205] | 470 | }
|
---|
| 471 |
|
---|
[238] | 472 | #
|
---|
| 473 | # from an array of files/dirs,
|
---|
| 474 | # generates list of files
|
---|
| 475 | # sorted by type
|
---|
| 476 | #
|
---|
[237] | 477 | sub get_files( @ )
|
---|
| 478 | {
|
---|
| 479 | my @files = ();
|
---|
| 480 | my @links = ();
|
---|
| 481 | my @dirs = ();
|
---|
| 482 | my @others = ();
|
---|
| 483 |
|
---|
[239] | 484 | if (@_) {
|
---|
| 485 | find(
|
---|
| 486 | {
|
---|
| 487 | wanted => sub {
|
---|
| 488 | my $fullname = cwd() . "/" . $_;
|
---|
| 489 | if ( -l $_ ) {
|
---|
| 490 |
|
---|
| 491 | # soft link
|
---|
| 492 | # important: check for links first
|
---|
| 493 | # to exclude them from further checks
|
---|
| 494 | push( @links, $fullname );
|
---|
| 495 | } elsif ( -d $_ ) {
|
---|
| 496 | push( @dirs, $fullname );
|
---|
| 497 | } elsif ( -f $_ ) {
|
---|
| 498 |
|
---|
| 499 | # regular file
|
---|
| 500 | push( @files, $fullname );
|
---|
| 501 | } else {
|
---|
| 502 | push( @others, $fullname );
|
---|
| 503 | }
|
---|
| 504 | }
|
---|
| 505 | },
|
---|
| 506 | @_
|
---|
| 507 | );
|
---|
[237] | 508 | }
|
---|
| 509 |
|
---|
[239] | 510 | # don't rely on others.
|
---|
[237] | 511 | # If more specific file types are needed,
|
---|
| 512 | # they will be added
|
---|
| 513 | return {
|
---|
[239] | 514 | files => \@files,
|
---|
| 515 | links => \@links,
|
---|
| 516 | dirs => \@dirs,
|
---|
| 517 | others => \@others
|
---|
| 518 | };
|
---|
[237] | 519 | }
|
---|
| 520 |
|
---|
[189] | 521 | #####################################################################
|
---|
| 522 | #
|
---|
[186] | 523 | # functions
|
---|
| 524 |
|
---|
| 525 | sub help(;@)
|
---|
| 526 | {
|
---|
[205] | 527 | if ( @_ == 0 ) {
|
---|
| 528 | usage();
|
---|
| 529 | } else {
|
---|
| 530 | print "help for @_: ...\n";
|
---|
[214] | 531 | usage();
|
---|
[205] | 532 | }
|
---|
[186] | 533 | }
|
---|
| 534 |
|
---|
[203] | 535 | sub login(@)
|
---|
| 536 | {
|
---|
[205] | 537 | check_parameter( @_, 1 );
|
---|
| 538 | check_env();
|
---|
[203] | 539 |
|
---|
[235] | 540 | my $input_username = $_[0];
|
---|
[214] | 541 |
|
---|
| 542 | if ( not $input_username ) {
|
---|
| 543 | my $output_username = "";
|
---|
| 544 | if ($DASSCM_USERNAME) {
|
---|
| 545 | $output_username = " ($DASSCM_USERNAME)";
|
---|
| 546 | }
|
---|
| 547 |
|
---|
| 548 | print "Enter DASSCM user name", $output_username, ": ";
|
---|
| 549 | $input_username = <STDIN>;
|
---|
| 550 | chomp($input_username);
|
---|
[247] | 551 |
|
---|
| 552 | $input_username = $input_username || $DASSCM_USERNAME;
|
---|
[205] | 553 | }
|
---|
[203] | 554 |
|
---|
[205] | 555 | # hidden password input
|
---|
[247] | 556 | print "Enter password for $input_username: ";
|
---|
[205] | 557 | ReadMode('noecho');
|
---|
| 558 | my $input_password = <STDIN>;
|
---|
| 559 | ReadMode('normal');
|
---|
| 560 | chomp($input_password);
|
---|
[220] | 561 | print "\n";
|
---|
[203] | 562 |
|
---|
[247] | 563 | # checking checkout username/password
|
---|
| 564 | svn_check_credentials( $DASSCM_CHECKOUT_USERNAME, $DASSCM_CHECKOUT_PASSWORD );
|
---|
| 565 | print "checkout access okay\n";
|
---|
[205] | 566 |
|
---|
[247] | 567 | svn_check_credentials( $input_username, $input_password );
|
---|
| 568 |
|
---|
[205] | 569 | #
|
---|
| 570 | # set environment variables
|
---|
| 571 | #
|
---|
| 572 | $ENV{'DASSCM_USERNAME'} = $input_username;
|
---|
| 573 | $ENV{'DASSCM_PASSWORD'} = $input_password;
|
---|
| 574 |
|
---|
[209] | 575 | print "subversion access okay\n\n", "DASSCM_USERNAME: $input_username\n",
|
---|
| 576 | "DASSCM_PASSWORD: (hidden)\n", "DASSCM_PROD: $DASSCM_PROD\n",
|
---|
| 577 | "DASSCM_REPO: $DASSCM_REPO\n",
|
---|
| 578 | "Server Repository: $DASSCM_SVN_REPOSITORY\n", "\n", "[dasscm shell]\n\n";
|
---|
[205] | 579 |
|
---|
[235] | 580 | my $shell = $SHELL || "bash";
|
---|
| 581 | exec($shell) or die "failed to start new shell";
|
---|
[203] | 582 | }
|
---|
| 583 |
|
---|
[205] | 584 | sub init(@)
|
---|
| 585 | {
|
---|
| 586 | check_parameter( @_, 1 );
|
---|
| 587 | check_env();
|
---|
| 588 |
|
---|
[235] | 589 | # don't do repository creation (svn mkdir) here,
|
---|
| 590 | # because then their must be a lot of prior checks
|
---|
| 591 |
|
---|
[205] | 592 | # update complete repository
|
---|
[216] | 593 | # and create permission file
|
---|
[208] | 594 | my $retcode =
|
---|
| 595 | run_interactive(
|
---|
[225] | 596 | "cd $DASSCM_LOCAL_REPOSITORY_BASE; $SVN checkout $svnCheckoutCredentials $svnOptions $DASSCM_SVN_REPOSITORY; touch $permissions_file"
|
---|
[208] | 597 | );
|
---|
[205] | 598 | }
|
---|
| 599 |
|
---|
[215] | 600 | sub ls(@)
|
---|
[186] | 601 | {
|
---|
[205] | 602 | check_parameter( @_, 1 );
|
---|
| 603 | check_env();
|
---|
[186] | 604 |
|
---|
[215] | 605 | my @files = svn_getStoredFiles(@_);
|
---|
| 606 |
|
---|
| 607 | print join( "\n", @files );
|
---|
| 608 | print "\n";
|
---|
| 609 | }
|
---|
| 610 |
|
---|
| 611 | sub update(@)
|
---|
| 612 | {
|
---|
| 613 | check_parameter( @_, 1 );
|
---|
| 614 | check_env();
|
---|
| 615 |
|
---|
| 616 | #
|
---|
| 617 | # update local repository
|
---|
| 618 | #
|
---|
| 619 | svn_update();
|
---|
| 620 | }
|
---|
| 621 |
|
---|
[237] | 622 | #
|
---|
| 623 | # helper function for "add" command
|
---|
| 624 | #
|
---|
[215] | 625 | sub add_helper(@)
|
---|
| 626 | {
|
---|
[205] | 627 | (
|
---|
| 628 | my $basename,
|
---|
| 629 | my $dirname_prod,
|
---|
| 630 | my $dirname_repo,
|
---|
| 631 | my $filename_prod,
|
---|
| 632 | my $filename_repo
|
---|
| 633 | )
|
---|
| 634 | = get_filenames( $_[0] );
|
---|
[186] | 635 |
|
---|
[205] | 636 | if ( $command eq "add" ) {
|
---|
| 637 | mkpath($dirname_repo);
|
---|
| 638 | }
|
---|
[186] | 639 |
|
---|
[238] | 640 | # TODO: are permissions also copied?
|
---|
[239] | 641 | copy( $filename_prod, $filename_repo )
|
---|
| 642 | or error "failed to copy $filename_prod to repository: $!";
|
---|
[205] | 643 |
|
---|
| 644 | if ( $command eq "add" ) {
|
---|
| 645 |
|
---|
| 646 | # already checked in?
|
---|
[238] | 647 | chdir $DASSCM_REPO;
|
---|
[205] | 648 |
|
---|
| 649 | # also add the path to filename.
|
---|
| 650 | for my $dir ( split( '/', $dirname_prod ) ) {
|
---|
| 651 | if ($dir) {
|
---|
[239] | 652 | my ( $rc, @out ) =
|
---|
| 653 | run_command( "$SVN add --non-recursive \"" . $dir . "\"" );
|
---|
| 654 | if ( $rc > 0 ) {
|
---|
[226] | 655 | print join( "\n", @out );
|
---|
[239] | 656 | }
|
---|
[205] | 657 | chdir $dir;
|
---|
| 658 | }
|
---|
| 659 | }
|
---|
[239] | 660 | my ( $rc, @out ) = run_command( "$SVN add \"" . $basename . "\"" );
|
---|
| 661 | if ( $rc > 0 ) {
|
---|
[226] | 662 | print join( "\n", @out );
|
---|
[239] | 663 | }
|
---|
[238] | 664 | chdir $StartDirectory;
|
---|
[205] | 665 | }
|
---|
[215] | 666 | }
|
---|
[205] | 667 |
|
---|
[215] | 668 | #
|
---|
| 669 | # add (is used for command add and commit)
|
---|
| 670 | #
|
---|
| 671 | sub add(@)
|
---|
| 672 | {
|
---|
| 673 | check_parameter( @_, 1 );
|
---|
| 674 | check_env();
|
---|
| 675 |
|
---|
| 676 | #
|
---|
| 677 | # update local repository
|
---|
| 678 | #
|
---|
| 679 | svn_update();
|
---|
| 680 |
|
---|
[237] | 681 | # get all regular files and links
|
---|
[239] | 682 | my $href_files = get_files(@_);
|
---|
[220] | 683 |
|
---|
[237] | 684 | #print Dumper( $href_files );
|
---|
| 685 |
|
---|
[239] | 686 | my @files = @{ $href_files->{files} };
|
---|
| 687 | my @links = @{ $href_files->{links} };
|
---|
[237] | 688 |
|
---|
[239] | 689 | if (@files) {
|
---|
[237] | 690 | my $number = $#files + 1;
|
---|
| 691 | print "files to check-in ($number): \n";
|
---|
| 692 | print join( "\n", @files );
|
---|
| 693 | print "\n";
|
---|
| 694 | }
|
---|
| 695 |
|
---|
[239] | 696 | if (@links) {
|
---|
[237] | 697 | my $number = $#links + 1;
|
---|
| 698 | print "\n";
|
---|
| 699 | print "ignoring links ($number):\n";
|
---|
| 700 | print join( "\n", @links );
|
---|
| 701 | print "\n";
|
---|
| 702 | }
|
---|
| 703 |
|
---|
[238] | 704 | # TODO: confirm
|
---|
| 705 |
|
---|
[237] | 706 | # copy files one by one to local repository
|
---|
| 707 | for my $file (@files) {
|
---|
[239] | 708 |
|
---|
[233] | 709 | # add file
|
---|
[239] | 710 | add_helper($file);
|
---|
[233] | 711 | }
|
---|
| 712 |
|
---|
[215] | 713 | # create new permissions file
|
---|
| 714 | permissions();
|
---|
[220] | 715 |
|
---|
[215] | 716 | # add permissions file
|
---|
[220] | 717 | add_helper($permissions_file);
|
---|
[215] | 718 |
|
---|
[205] | 719 | if ( $options{'message'} ) {
|
---|
| 720 | $svnOptions .= " --message \"$options{'message'}\" ";
|
---|
| 721 | }
|
---|
| 722 |
|
---|
[239] | 723 | # commit calls $EDITOR.
|
---|
[237] | 724 | # use "interactive" here, to display output
|
---|
[215] | 725 | my $retcode =
|
---|
[205] | 726 | run_interactive(
|
---|
[208] | 727 | "$SVN commit $svnOptions --username $DASSCM_USERNAME $svnPasswordCredentials $DASSCM_REPO"
|
---|
| 728 | );
|
---|
[205] | 729 |
|
---|
[215] | 730 | #print $filename_prod. "\n";
|
---|
| 731 | #print $dirname_repo. "\n";
|
---|
[186] | 732 | }
|
---|
| 733 |
|
---|
[193] | 734 | sub blame(@)
|
---|
| 735 | {
|
---|
[205] | 736 | check_parameter( @_, 1 );
|
---|
| 737 | check_env();
|
---|
[193] | 738 |
|
---|
[205] | 739 | (
|
---|
| 740 | my $basename,
|
---|
| 741 | my $dirname_prod,
|
---|
| 742 | my $dirname_repo,
|
---|
| 743 | my $filename_prod,
|
---|
| 744 | my $filename_repo
|
---|
| 745 | )
|
---|
| 746 | = get_filenames( $_[0] );
|
---|
| 747 |
|
---|
| 748 | my $retcode = run_interactive("$SVN blame $svnOptions $filename_repo");
|
---|
[193] | 749 | }
|
---|
| 750 |
|
---|
[187] | 751 | sub diff(@)
|
---|
| 752 | {
|
---|
[205] | 753 | check_parameter( @_, 1 );
|
---|
| 754 | check_env();
|
---|
[187] | 755 |
|
---|
[205] | 756 | (
|
---|
| 757 | my $basename,
|
---|
| 758 | my $dirname_prod,
|
---|
| 759 | my $dirname_repo,
|
---|
| 760 | my $filename_prod,
|
---|
| 761 | my $filename_repo
|
---|
| 762 | )
|
---|
| 763 | = get_filenames( $_[0] );
|
---|
| 764 |
|
---|
| 765 | #print "$basename,$dirname_prod,$dirname_repo\n";
|
---|
| 766 |
|
---|
| 767 | ( my $rc_update, my @result ) = run_command("$SVN update $filename_repo");
|
---|
| 768 | if ( $rc_update != 0 ) {
|
---|
| 769 | print @result;
|
---|
| 770 | die;
|
---|
| 771 | }
|
---|
| 772 |
|
---|
[238] | 773 | ( my $rc_diff, my @diff_result ) =
|
---|
[239] | 774 | run_command( $diff . " $filename_repo $filename_prod" );
|
---|
[238] | 775 |
|
---|
| 776 | print @diff_result;
|
---|
[187] | 777 | }
|
---|
| 778 |
|
---|
[209] | 779 | sub status(@)
|
---|
| 780 | {
|
---|
| 781 | check_parameter( @_, 1 );
|
---|
| 782 | check_env();
|
---|
| 783 |
|
---|
| 784 | #
|
---|
| 785 | # update local repository
|
---|
| 786 | #
|
---|
| 787 | svn_update();
|
---|
| 788 |
|
---|
| 789 | # TODO: start at subdirectories ?
|
---|
[220] | 790 | my $dir = $DASSCM_REPO;
|
---|
[215] | 791 | my @files = svn_getStoredFiles($dir);
|
---|
[209] | 792 |
|
---|
| 793 | # Liste der geänderten Files ausgeben, falls nicht leer
|
---|
[215] | 794 | if (@files) {
|
---|
[209] | 795 |
|
---|
[215] | 796 | # stores result from status (cvscheck)
|
---|
| 797 | my %removedfiles = ();
|
---|
| 798 | my %changedfiles = ();
|
---|
| 799 |
|
---|
| 800 | foreach my $file (@files) {
|
---|
| 801 |
|
---|
| 802 | my $realfile = "/" . $file;
|
---|
| 803 | my $cvsworkfile = "${DASSCM_REPO}/${file}";
|
---|
| 804 |
|
---|
| 805 | if ( -d $realfile ) {
|
---|
| 806 |
|
---|
| 807 | # directory. do nothing
|
---|
| 808 | } elsif ( !-r $realfile ) {
|
---|
| 809 | $removedfiles{"$realfile"} = $cvsworkfile;
|
---|
| 810 | } else {
|
---|
| 811 | ( -r "$cvsworkfile" )
|
---|
| 812 | || die("Fehler: $cvsworkfile ist nicht lesbar");
|
---|
| 813 | if ( compare( $cvsworkfile, $realfile ) != 0 ) {
|
---|
| 814 | $changedfiles{"$realfile"} = $cvsworkfile;
|
---|
| 815 | }
|
---|
| 816 | }
|
---|
| 817 | }
|
---|
| 818 |
|
---|
| 819 | if (%removedfiles) {
|
---|
| 820 | print "deleted files (found in repository, but not in system):\n";
|
---|
| 821 | foreach my $key ( values %removedfiles ) {
|
---|
[209] | 822 | print "$key\n";
|
---|
| 823 | }
|
---|
| 824 | print "\n";
|
---|
| 825 | }
|
---|
| 826 |
|
---|
[215] | 827 | if (%changedfiles) {
|
---|
[209] | 828 | print "modified files:\n";
|
---|
[215] | 829 | foreach my $key ( keys %changedfiles ) {
|
---|
[209] | 830 | print "$key\n";
|
---|
| 831 | }
|
---|
| 832 | }
|
---|
| 833 | } else {
|
---|
[215] | 834 | print "no modified files found in $dir\n";
|
---|
[209] | 835 | }
|
---|
[215] | 836 |
|
---|
[209] | 837 | print "\n";
|
---|
[215] | 838 | }
|
---|
[209] | 839 |
|
---|
[215] | 840 | sub permissions(@)
|
---|
| 841 | {
|
---|
| 842 | check_parameter( @_, 1 );
|
---|
| 843 | check_env();
|
---|
| 844 |
|
---|
| 845 | #
|
---|
| 846 | # update local repository
|
---|
| 847 | #
|
---|
| 848 | #svn_update();
|
---|
| 849 |
|
---|
| 850 | # TODO: start at subdirectories ?
|
---|
[220] | 851 | my $dir = $DASSCM_REPO;
|
---|
[215] | 852 | my @files = svn_getStoredFiles($dir);
|
---|
| 853 |
|
---|
| 854 | if (@files) {
|
---|
| 855 |
|
---|
| 856 | # generieren der Permissions
|
---|
| 857 | my @permissions = generatePermissionList(@files);
|
---|
| 858 | my $OUTFILE;
|
---|
| 859 | my $tofile = 0; # Status für schreiben in File
|
---|
[220] | 860 |
|
---|
[215] | 861 | if ( -w dirname($permissions_file) ) {
|
---|
| 862 |
|
---|
| 863 | # Verzeichnis existiert => schreiben
|
---|
| 864 | print "storing permissions in file $permissions_file\n";
|
---|
| 865 | open( OUTFILE, ">$permissions_file" )
|
---|
[216] | 866 | || die("failed to write to $permissions_file: $!");
|
---|
[215] | 867 | $tofile = 1; # Merken, daß in File geschrieben wird
|
---|
| 868 | print OUTFILE "#\n";
|
---|
| 869 | print OUTFILE "# created by dasscm permissions\n";
|
---|
[220] | 870 | print OUTFILE
|
---|
| 871 | "# It is intended to be used for restoring permissions\n";
|
---|
[215] | 872 | } else {
|
---|
| 873 |
|
---|
| 874 | # Pfad für Sicherungsdatei existiert nicht => schreiben auf stdout
|
---|
| 875 | # Alias Filehandle für stdout erzeugen
|
---|
| 876 | *OUTFILE = *STDOUT;
|
---|
| 877 | }
|
---|
| 878 | foreach my $line (@permissions) {
|
---|
| 879 | print OUTFILE "$line\n";
|
---|
| 880 | }
|
---|
| 881 |
|
---|
[220] | 882 | if ($tofile) {
|
---|
[215] | 883 | close(OUTFILE);
|
---|
| 884 | }
|
---|
| 885 | }
|
---|
[209] | 886 | }
|
---|
| 887 |
|
---|
[189] | 888 | #####################################################################
|
---|
| 889 | #
|
---|
[186] | 890 | # main
|
---|
[189] | 891 | #
|
---|
[186] | 892 |
|
---|
| 893 | my $number_arguments = @ARGV;
|
---|
| 894 |
|
---|
[205] | 895 | if ( $number_arguments > 0 ) {
|
---|
[186] | 896 |
|
---|
[205] | 897 | # get subcommand and remove it from @ARGV
|
---|
| 898 | $command = $ARGV[0];
|
---|
| 899 | shift @ARGV;
|
---|
[196] | 900 |
|
---|
[205] | 901 | $DASSCM_LOCAL_REPOSITORY_BASE = $config->{'DASSCM_LOCAL_REPOSITORY_BASE'};
|
---|
| 902 | $DASSCM_REPOSITORY_NAME = $config->{'DASSCM_REPOSITORY_NAME'};
|
---|
[196] | 903 |
|
---|
[205] | 904 | # TODO: check variables
|
---|
| 905 | $DASSCM_SVN_REPOSITORY =
|
---|
| 906 | $config->{'DASSCM_SVN_REPOSITORY_BASE'} . "/" . $DASSCM_REPOSITORY_NAME;
|
---|
| 907 |
|
---|
[247] | 908 | $DASSCM_CHECKOUT_USERNAME = $config->{'DASSCM_CHECKOUT_USERNAME'};
|
---|
| 909 | $DASSCM_CHECKOUT_PASSWORD = $config->{'DASSCM_CHECKOUT_PASSWORD'};
|
---|
[205] | 910 |
|
---|
| 911 | #
|
---|
| 912 | # if a user is given by dasscm configuration file, we use it.
|
---|
| 913 | # Otherwise we expect that read-only account is configured
|
---|
| 914 | # as local subversion configuration.
|
---|
| 915 | # If this is also not the case,
|
---|
| 916 | # user is required to type username and password.
|
---|
| 917 | # This will be stored as local subversion configuration thereafter.
|
---|
| 918 | #
|
---|
| 919 | if ( $DASSCM_CHECKOUT_USERNAME && $DASSCM_CHECKOUT_PASSWORD ) {
|
---|
| 920 | $svnCheckoutCredentials =
|
---|
| 921 | " --username $DASSCM_CHECKOUT_USERNAME --password $DASSCM_CHECKOUT_PASSWORD ";
|
---|
| 922 | }
|
---|
| 923 |
|
---|
| 924 | # get command line options and store them in options hash
|
---|
[214] | 925 | my $result = GetOptions( \%options, 'verbose', 'message=s' );
|
---|
[205] | 926 |
|
---|
| 927 | # print options
|
---|
| 928 | foreach my $option ( keys %options ) {
|
---|
[215] | 929 | print "${option}: $options{$option}\n";
|
---|
[205] | 930 | }
|
---|
| 931 |
|
---|
[214] | 932 | # set verbose to command line option
|
---|
| 933 | $verbose = $options{'verbose'};
|
---|
| 934 |
|
---|
| 935 | #
|
---|
| 936 | # action accordinly to command are taken
|
---|
| 937 | # $command is rewritten in standard format,
|
---|
| 938 | # so we can test for it later on more simply
|
---|
| 939 | #
|
---|
[205] | 940 | $_ = $command;
|
---|
| 941 | if (m/help/i) {
|
---|
| 942 | help(@ARGV);
|
---|
| 943 | } elsif (m/login/i) {
|
---|
[208] | 944 | $command = "login";
|
---|
[205] | 945 | login(@ARGV);
|
---|
| 946 | } elsif (m/init/i) {
|
---|
[208] | 947 | $command = "init";
|
---|
[205] | 948 | init(@ARGV);
|
---|
[215] | 949 | } elsif (m/ls/i) {
|
---|
| 950 | $command = "ls";
|
---|
| 951 | ls(@ARGV);
|
---|
[235] | 952 | } elsif ( (m/update/i) || (m/up/i) ) {
|
---|
[215] | 953 | $command = "update";
|
---|
| 954 | update(@ARGV);
|
---|
[205] | 955 | } elsif (m/add/i) {
|
---|
| 956 | $command = "add";
|
---|
| 957 | add(@ARGV);
|
---|
[251] | 958 | } elsif ( (m/commit/i) || (m/ci/i) ) {
|
---|
[205] | 959 | $command = "commit";
|
---|
| 960 | add(@ARGV);
|
---|
| 961 | } elsif (m/blame/i) {
|
---|
[208] | 962 | $command = "blame";
|
---|
[205] | 963 | blame(@ARGV);
|
---|
| 964 | } elsif (m/diff/i) {
|
---|
[208] | 965 | $command = "diff";
|
---|
[205] | 966 | diff(@ARGV);
|
---|
[235] | 967 | } elsif ( (m/status/i) || (m/st/i) ) {
|
---|
[209] | 968 | $command = "status";
|
---|
| 969 | status(@ARGV);
|
---|
[215] | 970 | } elsif (m/permissions/i) {
|
---|
| 971 | $command = "permissions";
|
---|
| 972 | permissions(@ARGV);
|
---|
[205] | 973 | } else {
|
---|
[215] | 974 | print "unknown command: $command\n\n";
|
---|
[205] | 975 | usage();
|
---|
| 976 | check_env();
|
---|
| 977 | }
|
---|
| 978 |
|
---|
[209] | 979 | # cleanup (svn-commit.tmp)
|
---|
[205] | 980 | # commitall
|
---|
| 981 | # revert
|
---|
[215] | 982 | # activate
|
---|
[227] | 983 | # rm
|
---|
[186] | 984 | }
|
---|