Changeset 187 for trunk/dasscm/dasscm


Ignore:
Timestamp:
Nov 9, 2004, 10:17:50 PM (19 years ago)
Author:
joergs
Message:

added diff, commit

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dasscm/dasscm

    r186 r187  
    1717
    1818# util functions
     19sub usage()
     20{
     21        print "dasscm is intended to help versioning configuration files\n";
     22}
     23
    1924sub check_env()
    2025{
     
    4348}
    4449
    45 sub run_command
    46 {
    47   my $command = shift;
    48 
    49   print "executing command: " . $command . "\n";
    50 
    51   open(RESULT, $command . ' 2>&1 |' );
    52   my @result = <RESULT>;
    53   close(RESULT);
    54   my $retcode = $?>>8;
    55 
    56   print @result;
    57   if( $retcode ) { print "return code: " . $retcode . "\n"; }
    58 
    59   return($retcode, @result);
    60 }
    61 
    62 
    63 
    64 # functions
    65 
    66 sub help(;@)
    67 {
    68         print "help for @_\n";
    69 }
    70 
    71 sub add(@)
    72 {
    73         check_parameter(@_,1);
    74         check_env();
     50sub get_filenames(@)
     51{
    7552        my $filename_prod = $_[0];
    7653        if ( !($filename_prod =~ m/^\//) ) {
     
    9370        my $filename_repo = "$dirname_repo/$basename";
    9471       
     72        return ($basename,$dirname_prod,$dirname_repo,$filename_prod,$filename_repo);
     73}
     74
     75sub run_command
     76{
     77  my $command = shift;
     78
     79  #print "executing command: " . $command . "\n";
     80
     81  open(RESULT, $command . ' 2>&1 |' );
     82  my @result = <RESULT>;
     83  close(RESULT);
     84  my $retcode = $?>>8;
     85
     86  #print @result;
     87  #if( $retcode ) { print "return code: " . $retcode . "\n"; }
     88
     89  return($retcode, @result);
     90}
     91
     92
     93
     94# functions
     95
     96sub help(;@)
     97{
     98        print "help for @_\n";
     99}
     100
     101sub add(@)
     102{
     103        check_parameter(@_,1);
     104        check_env();
     105       
     106        (my $basename, my $dirname_prod, my $dirname_repo, my $filename_prod, my $filename_repo) = get_filenames($_[0]);
     107               
    95108        mkpath($dirname_repo);
    96109       
    97110        # update complete repository
    98         run_command( "$SVN update $DASSCM_REPO" );
     111        (my $retcode, my @result)=run_command( "$SVN update $DASSCM_REPO" );
     112        if( $retcode != 0 ) {
     113                print @result;
     114                die;
     115        }
    99116
    100117        copy( $filename_prod, $filename_repo ) or die $!;
     
    119136}
    120137
     138sub commit(@)
     139{
     140        check_parameter(@_,1);
     141        check_env();
     142       
     143        (my $basename, my $dirname_prod, my $dirname_repo, my $filename_prod, my $filename_repo) = get_filenames($_[0]);
     144
     145        (my $rc_update, my @result)=run_command( "$SVN update $filename_repo" );
     146        if( $rc_update != 0 ) {
     147                print @result;
     148                die;
     149        }
     150
     151        # commit calls $EDITOR. uses "system" here, to display output
     152        system( "$SVN commit $DASSCM_REPO" );
     153        # TODO: commit (-m)
     154}
     155
     156sub diff(@)
     157{
     158        check_parameter(@_,1);
     159        check_env();
     160       
     161        (my $basename, my $dirname_prod, my $dirname_repo, my $filename_prod, my $filename_repo) = get_filenames($_[0]);
     162               
     163        #print "$basename,$dirname_prod,$dirname_repo\n";
     164
     165        (my $rc_update, my @result)=run_command( "$SVN update $filename_repo" );
     166        if( $rc_update != 0 ) {
     167                print @result;
     168                die;
     169        }
     170       
     171        (my $rc_diff, my @diff)=run_command( "diff $filename_repo $filename_prod" );
     172        print @diff;   
     173}
    121174
    122175# main
    123176
    124177my $number_arguments = @ARGV;
    125 print "$number_arguments\n";
     178#print "$number_arguments\n";
    126179
    127180if ($number_arguments > 0) {
     
    142195        } elsif (m/activate/i) {
    143196                activate(@ARGV);
    144         }
    145 }
     197        } else {
     198                usage();
     199                check_env();
     200        }
     201}
Note: See TracChangeset for help on using the changeset viewer.