Changeset 275 for trunk


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

perltidy

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dasscm/dasscm

    r274 r275  
    5555my $svnCheckoutCredentials = "";
    5656my $svnPasswordCredentials = "";
     57
    5758# flag. Set to true by svn_update
    5859# This prevents, that svn_update is called multiple times
     
    6465# subcommand, that gets executed (add, commit, ...)
    6566my $command;
    66 
    6767
    6868my $verbose = 0;
     
    161161}
    162162
    163 
    164163#
    165164# check and evaluate environment variables
     
    263262}
    264263
    265 
    266 
    267264#
    268265# has been intendend,
     
    297294    # herefore make sure, that if filename is a directory,
    298295    # it will end by "/"
    299     if( ( -d $filename_prod ) and ( !( $filename_prod =~ m/\/$/ ) ) ) {
     296    if ( ( -d $filename_prod ) and ( !( $filename_prod =~ m/\/$/ ) ) ) {
    300297        $filename_prod = $filename_prod . '/';
    301298    }
     
    321318    );
    322319}
    323 
    324320
    325321sub copy_file_to_repository( $ )
     
    333329        my $filename_prod,
    334330        my $filename_repo
    335     )
    336     = get_filenames( $filename );
     331      )
     332      = get_filenames($filename);
    337333
    338334    # TODO: are permissions also copied?
    339335    copy( $filename_prod, $filename_repo )
    340         or error "failed to copy $filename_prod to repository: $!";
    341 }
    342 
     336      or error "failed to copy $filename_prod to repository: $!";
     337}
    343338
    344339#
     
    496491
    497492    # use this flag to do only one update per run
    498     if( ! $svnRepositoryIsUptodate ) {
     493    if ( !$svnRepositoryIsUptodate ) {
    499494        ( my $rc_update, my @result ) =
    500         run_command(
    501             "$SVN update --non-interactive $svnCheckoutCredentials '$DASSCM_REPO/$update_path'");
     495          run_command(
     496            "$SVN update --non-interactive $svnCheckoutCredentials '$DASSCM_REPO/$update_path'"
     497          );
    502498        print @result;
    503499        if ( $rc_update != 0 ) {
    504500            fatalerror();
    505501        } elsif ( not $update_path ) {
     502
    506503            # set this flag if a full update is done
    507504            $svnRepositoryIsUptodate = 1;
     
    509506    }
    510507}
    511 
    512 
    513508
    514509sub svn_ls( ;@ )
     
    531526    my @others = ();
    532527
    533     if( -f $filename_prod ) {
    534         @files = ( $filename_prod );
     528    if ( -f $filename_prod ) {
     529        @files = ($filename_prod);
    535530    } elsif ( -d $dirname_repo ) {
    536531        find(
     
    540535                    $name =~ s|^$dirname_repo||;
    541536                    if ( $name =~ m/\.svn/ ) {
     537
    542538                        # skip svn meta data
    543539                    } elsif ( -l $_ ) {
    544    
     540
    545541                        # soft link
    546542                        # important: check for links first
     
    548544                        push( @links, $name );
    549545                    } elsif ( -d $_ ) {
    550    
     546
    551547                        # directories
    552548                        push( @dirs, $name );
    553549                    } elsif ( -f $_ ) {
    554    
     550
    555551                        # regular file
    556552                        push( @files, $name );
     
    558554                        push( @others, $name );
    559555                    }
    560                     }
     556                  }
    561557            },
    562             ( $dirname_repo )
     558            ($dirname_repo)
    563559        );
    564560    }
     
    567563}
    568564
    569 
    570 
    571565sub svn_revert( ;$ )
    572566{
    573567    my $path = shift || $DASSCM_REPO;
    574568
    575     ( my $rc_update, my @result ) =
    576         run_command( "$SVN revert -R '$path'" );
     569    ( my $rc_update, my @result ) = run_command("$SVN revert -R '$path'");
    577570
    578571    if ( $rc_update != 0 ) {
    579572        print "\n", @result;
    580         error( "failed to revert subversion repository changes" );
    581     }
    582 }
    583 
     573        error("failed to revert subversion repository changes");
     574    }
     575}
    584576
    585577sub getModifiedFiles( ;$ )
     
    594586      = get_filenames( $_[0] );
    595587
    596     my @files = svn_ls( $filename_prod );
     588    my @files = svn_ls($filename_prod);
    597589
    598590    # stores result from status (cvscheck)
     
    625617}
    626618
    627 
    628619#
    629620# from an array of files/dirs,
     
    741732}
    742733
    743 
    744734#
    745735# initialize local checkout directory (initial checkout)
     
    761751}
    762752
    763 
    764 
    765753sub ls(@)
    766754{
     
    770758    my @files = svn_ls(@_);
    771759
    772     if( @files ) {
     760    if (@files) {
    773761        print join( "\n", @files );
    774762        print "\n";
    775763    }
    776764}
    777 
    778 
    779765
    780766sub update(@)
     
    815801    for my $dir ( split( '/', $dirname_prod ) ) {
    816802        if ($dir) {
    817             my ( $rc, @out ) =
    818                 run_command( "$SVN add --non-recursive '$dir'" );
     803            my ( $rc, @out ) = run_command("$SVN add --non-recursive '$dir'");
    819804            if ( $rc > 0 ) {
    820805                print join( "\n", @out );
     
    823808        }
    824809    }
    825     my ( $rc, @out ) = run_command( "$SVN add '$basename'" );
     810    my ( $rc, @out ) = run_command("$SVN add '$basename'");
    826811    if ( $rc > 0 ) {
    827812        print join( "\n", @out );
     
    830815
    831816}
    832 
    833 
    834817
    835818#
     
    901884}
    902885
    903 
    904 
    905886#
    906887# checks in all modified files
    907888#
    908889sub commit(@)
    909 {
    910     check_parameter( @_, 1 );
    911     check_env();
    912 
    913     (
    914         my $basename,
    915         my $dirname_prod,
    916         my $dirname_repo,
    917         my $filename_prod,
    918         my $filename_repo
    919     )
    920     = get_filenames( $_[0] );
    921 
    922 
    923     #
    924     # update local repository
    925     #
    926     svn_update();
    927 
    928     ( my $refChangedFiles, my $refRemovedFiles ) = getModifiedFiles( $filename_prod );
    929     my %changedfiles = %{$refChangedFiles};
    930     my %removedfiles = %{$refRemovedFiles};
    931 
    932     if( %removedfiles ) {
    933         my $removedFilesString = '"' . join( '" "', values(%removedfiles) ) . '"';
    934         my ( $rc, @out ) = run_command( "$SVN rm $removedFilesString" );
    935         if ( $rc > 0 ) {
    936             print join( "\n", @out );
    937         }
    938     }
    939 
    940     # copy files one by one to local repository
    941     for my $file ( keys(%changedfiles) ) {
    942         copy_file_to_repository( $file );
    943     }
    944 
    945     # create new permissions file
    946     permissions();
    947 
    948     # add permissions file
    949     add_helper($permissions_file);
    950 
    951     if ( $options{'message'} ) {
    952         $svnOptions .= " --message \"$options{'message'}\" ";
    953     }
    954 
    955     # commit calls $EDITOR.
    956     # use "interactive" here, to display output
    957     my $retcode =
    958       run_interactive(
    959         "$SVN commit $svnOptions --username '$DASSCM_USERNAME' $svnPasswordCredentials $DASSCM_REPO"
    960       );
    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();
    965 }
    966 
    967 
    968 
    969 sub blame(@)
    970890{
    971891    check_parameter( @_, 1 );
     
    981901      = get_filenames( $_[0] );
    982902
    983     my $retcode = run_interactive("$SVN blame $svnOptions $filename_repo");
    984 }
    985 
    986 sub diff(@)
     903    #
     904    # update local repository
     905    #
     906    svn_update();
     907
     908    ( my $refChangedFiles, my $refRemovedFiles ) =
     909      getModifiedFiles($filename_prod);
     910    my %changedfiles = %{$refChangedFiles};
     911    my %removedfiles = %{$refRemovedFiles};
     912
     913    if (%removedfiles) {
     914        my $removedFilesString =
     915          '"' . join( '" "', values(%removedfiles) ) . '"';
     916        my ( $rc, @out ) = run_command("$SVN rm $removedFilesString");
     917        if ( $rc > 0 ) {
     918            print join( "\n", @out );
     919        }
     920    }
     921
     922    # copy files one by one to local repository
     923    for my $file ( keys(%changedfiles) ) {
     924        copy_file_to_repository($file);
     925    }
     926
     927    # create new permissions file
     928    permissions();
     929
     930    # add permissions file
     931    add_helper($permissions_file);
     932
     933    if ( $options{'message'} ) {
     934        $svnOptions .= " --message \"$options{'message'}\" ";
     935    }
     936
     937    # commit calls $EDITOR.
     938    # use "interactive" here, to display output
     939    my $retcode =
     940      run_interactive(
     941        "$SVN commit $svnOptions --username '$DASSCM_USERNAME' $svnPasswordCredentials $DASSCM_REPO"
     942      );
     943
     944    # svn commit does not deliever an error return code, if commit is canceld,
     945    # so a revert is performed in any case
     946    svn_revert();
     947}
     948
     949sub blame(@)
    987950{
    988951    check_parameter( @_, 1 );
     
    998961      = get_filenames( $_[0] );
    999962
     963    my $retcode = run_interactive("$SVN blame $svnOptions $filename_repo");
     964}
     965
     966sub diff(@)
     967{
     968    check_parameter( @_, 1 );
     969    check_env();
     970
     971    (
     972        my $basename,
     973        my $dirname_prod,
     974        my $dirname_repo,
     975        my $filename_prod,
     976        my $filename_repo
     977      )
     978      = get_filenames( $_[0] );
     979
    1000980    #print "$basename,$dirname_prod,$dirname_repo\n";
    1001981
     
    10261006      = get_filenames( $_[0] || "/" );
    10271007
    1028 
    10291008    # return code for the shell
    10301009    # default: error
     
    10361015    svn_update();
    10371016
    1038     ( my $refChangedFiles, my $refRemovedFiles ) = getModifiedFiles( $dirname_prod );
     1017    ( my $refChangedFiles, my $refRemovedFiles ) =
     1018      getModifiedFiles($dirname_prod);
    10391019    my %changedfiles = %{$refChangedFiles};
    10401020    my %removedfiles = %{$refRemovedFiles};
    10411021
    1042     if( %removedfiles or %changedfiles ) {
     1022    if ( %removedfiles or %changedfiles ) {
    10431023        if (%removedfiles) {
    10441024            print "deleted files (found in repository, but not in system):\n";
     
    10631043}
    10641044
    1065 
    1066 
    10671045sub permissions()
    10681046{
     
    10761054
    10771055    my $dir   = $DASSCM_REPO;
    1078     my @files = svn_ls( "/" );
     1056    my @files = svn_ls("/");
    10791057
    10801058    if (@files) {
     
    11121090}
    11131091
    1114 
    11151092#
    11161093# remove all uncommited changes in the repository
     
    11211098    check_env();
    11221099
    1123     svn_revert( $DASSCM_REPO );
    1124 }
    1125 
    1126 
     1100    svn_revert($DASSCM_REPO);
     1101}
    11271102
    11281103#####################################################################
Note: See TracChangeset for help on using the changeset viewer.