Changeset 274 for trunk


Ignore:
Timestamp:
Mar 5, 2009, 12:47:53 AM (16 years ago)
Author:
joergs
Message:

removed commitall again and replced it with improved version of commit. Path handling is improved. Bugfixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dasscm/dasscm

    r271 r274  
    3636# commands that require write access (and therefore a login)
    3737# to the repository server
    38 my @COMMANDS_REQUIRE_WRITE = ( "add", "commit", "commitall" );
     38my @COMMANDS_REQUIRE_WRITE = ( "add", "commit" );
    3939
    4040# configuration file
     
    8181    print "   help <subcommand>\n";
    8282    print "   init\n";
    83     print "   login\n";
    84     print "   up\n";
    85     print "   ls\n";
    86     print "   add <filename>\n";
    87     print "   commit <filename>\n";
    88     print "   commitall\n";
    89     print "   diff <filename>\n";
    90     print "   status\n";
     83    print "   login <username>\n";
     84    print "   up <path>\n";
     85    print "   ls <path>\n";
     86    print "   add <path>\n";
     87    print "   commit <path>\n";
     88    print "   diff <path>\n";
     89    print "   status <path>\n";
     90    print "   cleanup\n";
    9191    print "   permissions\n";
    9292    print "\n";
     
    293293    }
    294294
    295     # TODO: dirname buggy: eg. "/etc/" is reduced to "/",
    296     #   "/etc" is used as filename
    297     #   therefore make sure, that if filename is a directory,
    298     #   it will end by "/"
     295    # dirname buggy: eg. "/etc/" is reduced to "/",
     296    # "/etc" is used as filename
     297    # herefore make sure, that if filename is a directory,
     298    # it will end by "/"
    299299    if( ( -d $filename_prod ) and ( !( $filename_prod =~ m/\/$/ ) ) ) {
    300300        $filename_prod = $filename_prod . '/';
     
    337337
    338338    # TODO: are permissions also copied?
    339 
    340     print "$filename: $filename_prod, $filename_repo\n";
    341339    copy( $filename_prod, $filename_repo )
    342340        or error "failed to copy $filename_prod to repository: $!";
     
    570568
    571569
     570
     571sub svn_revert( ;$ )
     572{
     573    my $path = shift || $DASSCM_REPO;
     574
     575    ( my $rc_update, my @result ) =
     576        run_command( "$SVN revert -R '$path'" );
     577
     578    if ( $rc_update != 0 ) {
     579        print "\n", @result;
     580        error( "failed to revert subversion repository changes" );
     581    }
     582}
     583
     584
    572585sub getModifiedFiles( ;$ )
    573586{
     
    757770    my @files = svn_ls(@_);
    758771
    759     print join( "\n", @files );
    760     print "\n";
     772    if( @files ) {
     773        print join( "\n", @files );
     774        print "\n";
     775    }
    761776}
    762777
     
    788803      = get_filenames( $_[0] );
    789804
    790     if ( $command eq "add" ) {
    791         mkpath($dirname_repo);
    792     }
     805    mkpath($dirname_repo);
    793806
    794807    # TODO: are permissions also copied?
     
    796809      or error "failed to copy $filename_prod to repository: $!";
    797810
    798     if ( $command eq "add" ) {
    799 
    800         # already checked in?
    801         chdir $DASSCM_REPO;
    802 
    803         # also add the path to filename.
    804         for my $dir ( split( '/', $dirname_prod ) ) {
    805             if ($dir) {
    806                 my ( $rc, @out ) =
    807                   run_command( "$SVN add --non-recursive \"" . $dir . "\"" );
    808                 if ( $rc > 0 ) {
    809                     print join( "\n", @out );
    810                 }
    811                 chdir $dir;
     811    # already checked in?
     812    chdir $DASSCM_REPO;
     813
     814    # also add the path to filename.
     815    for my $dir ( split( '/', $dirname_prod ) ) {
     816        if ($dir) {
     817            my ( $rc, @out ) =
     818                run_command( "$SVN add --non-recursive '$dir'" );
     819            if ( $rc > 0 ) {
     820                print join( "\n", @out );
    812821            }
    813         }
    814         my ( $rc, @out ) = run_command( "$SVN add \"" . $basename . "\"" );
    815         if ( $rc > 0 ) {
    816             print join( "\n", @out );
    817         }
    818         chdir $StartDirectory;
    819     }
    820 }
    821 
    822 
    823 
    824 #
    825 # add (is used for command add and commit)
     822            chdir $dir;
     823        }
     824    }
     825    my ( $rc, @out ) = run_command( "$SVN add '$basename'" );
     826    if ( $rc > 0 ) {
     827        print join( "\n", @out );
     828    }
     829    chdir $StartDirectory;
     830
     831}
     832
     833
     834
     835#
     836# adding new files (or directories)
    826837#
    827838sub add(@)
     
    884895        "$SVN commit $svnOptions --username '$DASSCM_USERNAME' $svnPasswordCredentials $DASSCM_REPO"
    885896      );
    886 }
    887 
    888 
    889 
    890 #
    891 # checks in all modified files
    892 #
    893 sub commitall(@)
    894 {
    895     check_parameter( @_, 1 );
    896     check_env();
    897 
    898     #
    899     # update local repository
    900     #
    901     svn_update();
    902 
    903     ( my $refChangedFiles, my $refRemovedFiles ) = getModifiedFiles( "/" );
    904     my %changedfiles = %{$refChangedFiles};
    905     my %removedfiles = %{$refRemovedFiles};
    906 
    907     if( %removedfiles ) {
    908         my $removedFilesString = '"' . join( '" "', values(%removedfiles) ) . '"';
    909         my ( $rc, @out ) = run_command( "$SVN rm $removedFilesString" );
    910         if ( $rc > 0 ) {
    911             print join( "\n", @out );
    912         }
    913     }
    914 
    915     # add will care about the rest, including permission file and commiting
    916     add( keys %changedfiles );
     897
     898    # svn commit does not deliever an error return code, if commit is canceld,
     899    # so a revert is performed in any case
     900    svn_revert();
    917901}
    918902
     
    975959        "$SVN commit $svnOptions --username '$DASSCM_USERNAME' $svnPasswordCredentials $DASSCM_REPO"
    976960      );
     961
     962    # svn commit does not deliever an error return code, if commit is canceld,
     963    # so a revert is performed in any case
     964    svn_revert();
    977965}
    978966
     
    11251113
    11261114
     1115#
     1116# remove all uncommited changes in the repository
     1117#
     1118sub cleanup()
     1119{
     1120    check_parameter( @_, 1 );
     1121    check_env();
     1122
     1123    svn_revert( $DASSCM_REPO );
     1124}
     1125
     1126
    11271127
    11281128#####################################################################
     
    11801180    #
    11811181    $_ = $command;
    1182     if (m/help/i) {
     1182    if (m/^help$/i) {
    11831183        help(@ARGV);
    1184     } elsif (m/login/i) {
     1184    } elsif (m/^login$/i) {
    11851185        $command = "login";
    11861186        login(@ARGV);
    1187     } elsif (m/init/i) {
     1187    } elsif (m/^init$/i) {
    11881188        $command = "init";
    11891189        init(@ARGV);
    1190     } elsif (m/ls/i) {
     1190    } elsif (m/^ls$/i) {
    11911191        $command = "ls";
    11921192        ls(@ARGV);
    1193     } elsif ( (m/update/i) || (m/up/i) ) {
     1193    } elsif ( (m/^update$/i) || (m/^up$/i) ) {
    11941194        $command = "update";
    11951195        update(@ARGV);
    1196     } elsif ( (m/commitall/i) || (m/cia/i) ) {
    1197         $command = "commitall";
    1198         commitall(@ARGV);
    1199     } elsif (m/add/i) {
     1196    } elsif (m/^add$/i) {
    12001197        $command = "add";
    12011198        add(@ARGV);
    1202     } elsif ( (m/commit/i) || (m/checkin/i) || (m/ci/i) ) {
     1199    } elsif ( (m/^commit$/i) || (m/^checkin$/i) || (m/^ci$/i) ) {
    12031200        $command = "commit";
    12041201        commit(@ARGV);
    1205     } elsif (m/blame/i) {
     1202    } elsif (m/^blame$/i) {
    12061203        $command = "blame";
    12071204        blame(@ARGV);
    1208     } elsif (m/diff/i) {
     1205    } elsif (m/^diff$/i) {
    12091206        $command = "diff";
    12101207        diff(@ARGV);
    1211     } elsif ( (m/status/i) || (m/st/i) ) {
     1208    } elsif ( (m/^status$/i) || (m/^st$/i) ) {
    12121209        $command     = "status";
    12131210        $return_code = status(@ARGV);
    1214     } elsif (m/permissions/i) {
     1211    } elsif (m/^permissions$/i) {
    12151212        $command = "permissions";
    12161213        permissions();
     1214    } elsif (m/^cleanup$/i) {
     1215        $command = "cleanup";
     1216        cleanup();
    12171217    } else {
    12181218        print "unknown command: $command\n\n";
     
    12221222    }
    12231223
    1224     # cleanup (svn-commit.tmp)
    12251224    # revert
    1226     # activate
    1227     # rm
    12281225
    12291226}
Note: See TracChangeset for help on using the changeset viewer.