Changeset 196 for trunk/dasscm


Ignore:
Timestamp:
Dec 6, 2004, 5:42:11 PM (19 years ago)
Author:
joergs
Message:

add -m Option. Unified add and commit. svn update without --username to prevent that the password had to be typed every time

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dasscm/dasscm

    r195 r196  
    1212use File::Copy;
    1313#use POSIX qw/getpgrp tcgetpgrp/;
     14use Getopt::Long;
    1415
    1516#####################################################################
     
    1920my $SVN = "svn ";
    2021my $svnOptions = "";
     22# command line options get stored in options hash
     23my %options = ();
     24my $command;
    2125
    2226#####################################################################
     
    7579                $DASSCM_USER=$USER;
    7680        }
    77         $svnOptions .= " --username $DASSCM_USER "     
     81        #$svnOptions .= " --username $DASSCM_USER "     
    7882}
    7983
     
    107111}
    108112
     113
    109114sub run_command
    110115{
     
    125130
    126131
     132
     133sub run_interactive
     134{
     135        system( @_ );
     136        if ($? == -1) {
     137                printf "failed to execute: $!\n";
     138        } elsif ($? & 127) {
     139                printf "child died with signal %d, %s coredump\n",
     140                        ($? & 127),  ($? & 128) ? 'with' : 'without';
     141        } elsif( $? >> 8 != 0 ) {
     142                        printf "child exited with value %d\n", $? >> 8;
     143                }
     144        }
     145        return( $? >> 8 );
     146}
     147
     148
    127149#####################################################################
    128150#
     
    138160}
    139161
     162#
     163# add (is used for command add and commit)
     164#
    140165sub add(@)
    141166{
     
    145170        (my $basename, my $dirname_prod, my $dirname_repo, my $filename_prod, my $filename_repo) = get_filenames($_[0]);
    146171               
    147         mkpath($dirname_repo);
     172        if( $command eq "add" ) {
     173                mkpath($dirname_repo);
     174        }
    148175       
    149176        # update complete repository
    150 #       (my $retcode, my @result)=run_command( "$SVN update $DASSCM_REPO" );
    151 #       if( $retcode != 0 ) {
    152 #               print @result;
    153 #               die;
    154 #       }
    155         system( "$SVN update $svnOptions $DASSCM_REPO" );
     177        my $retcode = run_interactive( "$SVN update $svnOptions $DASSCM_REPO" );
    156178
    157179        copy( $filename_prod, $filename_repo ) or die $!;
    158180       
    159         # already checked in?
    160         chdir($DASSCM_REPO);
    161         # also add the path to filename.
    162         for my $dir (split('/', $dirname_prod) ) {
    163                 if( $dir ) {
    164                         run_command( "$SVN add --non-recursive $dir" );
    165                         chdir $dir;
     181        if( $command eq "add" ) {
     182                # already checked in?
     183                chdir($DASSCM_REPO);
     184                # also add the path to filename.
     185                for my $dir (split('/', $dirname_prod) ) {
     186                        if( $dir ) {
     187                                run_command( "$SVN add --non-recursive $dir" );
     188                                chdir $dir;
     189                        }
    166190                }
    167         }
    168         run_command( "$SVN add $basename" );
     191                run_command( "$SVN add $basename" );
     192        }
     193       
     194        if( $options{'message'} ) {
     195                $svnOptions .= " --message $options{'message'} ";
     196        }
    169197
    170198        # commit calls $EDITOR. uses "system" here, to display output
    171         system( "$SVN commit $svnOptions $DASSCM_REPO" );
    172         # TODO: commit (-m)
     199        my $retcode = run_interactive( "$SVN commit $svnOptions --username $DASSCM_USER $DASSCM_REPO" );
    173200
    174201        print $filename_prod."\n";
     
    184211        (my $basename, my $dirname_prod, my $dirname_repo, my $filename_prod, my $filename_repo) = get_filenames($_[0]);
    185212
    186         system( "$SVN blame $svnOptions $filename_repo" );
    187 }
    188 
    189 
    190 
    191 sub commit(@)
    192 {
    193         check_parameter(@_,1);
    194         check_env();
    195        
    196         (my $basename, my $dirname_prod, my $dirname_repo, my $filename_prod, my $filename_repo) = get_filenames($_[0]);
    197 
    198 #       (my $rc_update, my @result)=run_command( "$SVN update $filename_repo" );
    199 #       if( $rc_update != 0 ) {
    200 #               print @result;
    201 #               die;
    202 #       }
    203         system( "$SVN update $svnOptions $DASSCM_REPO" );
    204        
    205         copy( $filename_prod, $filename_repo ) or die $!;
    206 
    207         # commit calls $EDITOR. uses "system" here, to display output
    208         system( "$SVN commit $svnOptions $filename_repo" );
    209         # TODO: commit (-m)
    210 }
     213        my $retcode = run_interactive( "$SVN blame $svnOptions $filename_repo" );
     214}
     215
     216
    211217
    212218sub diff(@)
     
    238244
    239245if ($number_arguments > 0) {
    240         my $command = $ARGV[0];
     246        # get subcommand and remove it from @ARGV
     247        $command = $ARGV[0];
    241248        shift @ARGV;
    242         #$command =~ s/[A-Z]/[a-z]/m;
    243         #print "$command\n";
     249
     250
     251        # get command line options and store them in options hash
     252        my $result = GetOptions ( \%options, 'message=s' );
     253        foreach my $option (keys %options) {
     254                print $option.": ".$options{$option}."\n";
     255        }
    244256
    245257        $_=$command;
     
    247259                help(@ARGV);
    248260        } elsif (m/add/i) {
    249                 add(@ARGV);
     261                # rewrite command. just to make sure
     262                $command = "add";
     263                add( @ARGV);
     264        } elsif (m/commit/i) {
     265                # rewrite command. just to make sure   
     266                $command = "commit";   
     267                add( @ARGV);
    250268        } elsif (m/blame/i) {
    251269                blame(@ARGV);                   
    252         } elsif (m/commit/i) {
    253                 commit(@ARGV);
    254270        } elsif (m/diff/i) {
    255271                diff(@ARGV);
Note: See TracChangeset for help on using the changeset viewer.