Changeset 270 for trunk/dasscm


Ignore:
Timestamp:
Mar 4, 2009, 7:58:29 PM (16 years ago)
Author:
joergs
Message:

better handling of relative pathnames

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dasscm/dasscm

    r268 r270  
    161161}
    162162
     163
     164#
     165# check and evaluate environment variables
     166#
    163167sub check_env()
    164168{
     
    259263}
    260264
     265
     266
     267#
     268# has been intendend,
     269# to check addtitional parameters.
     270# Currently not used.
     271#
    261272sub check_parameter(@)
    262273{
     
    275286    # make filename absolut
    276287    if ( !( $filename_prod =~ m/^\// ) ) {
    277         $filename_prod = cwd() . "/" . $filename_prod;
     288        $filename_prod = cwd() . '/' . $filename_prod;
    278289    }
    279290
     
    284295    # TODO: dirname buggy: eg. "/etc/" is reduced to "/",
    285296    #   "/etc" is used as filename
    286     my $dirname_prod = dirname($filename_prod);
     297    #   therefore make sure, that if filename is a directory,
     298    #   it will end by "/"
     299    if( ( -d $filename_prod ) and ( !( $filename_prod =~ m/\/$/ ) ) ) {
     300        $filename_prod = $filename_prod . '/';
     301    }
     302
     303    ( my $basename, my $dirname_prod ) = fileparse($filename_prod);
    287304
    288305    # uses chdir to determine real directory in a unique way
    289306    chdir $dirname_prod or die $!;
    290     $dirname_prod = cwd();
     307    $dirname_prod = cwd() . '/';
    291308    chdir $StartDirectory;
    292 
    293     my $basename = basename($filename_prod);
    294309
    295310    if ($verbose) {
     
    460475sub svn_update( ;$ )
    461476{
     477    my $update_path = shift || "";
     478
     479    # use this flag to do only one update per run
    462480    if( ! $svnRepositoryIsUptodate ) {
    463         my $update_path = shift || $DASSCM_REPO;
    464481        ( my $rc_update, my @result ) =
    465482        run_command(
    466             "$SVN update --non-interactive $svnCheckoutCredentials $update_path");
     483            "$SVN update --non-interactive $svnCheckoutCredentials '$DASSCM_REPO/$update_path'");
    467484        print @result;
    468485        if ( $rc_update != 0 ) {
    469486            fatalerror();
    470         } else {
     487        } elsif ( not $update_path ) {
     488            # set this flag if a full update is done
    471489            $svnRepositoryIsUptodate = 1;
    472490        }
     
    476494
    477495
    478 sub svn_getStoredFiles( ;$ )
    479 {
    480 
    481     # TODO: get_filenames?
    482     #my $rel_path = shift || "";
    483     #my $path = "${DASSCM_REPO}/${rel_path}";
    484     my $path = ${DASSCM_REPO};
     496sub svn_getStoredFiles( ;@ )
     497{
     498    (
     499        my $basename,
     500        my $dirname_prod,
     501        my $dirname_repo,
     502        my $filename_prod,
     503        my $filename_repo
     504      )
     505      = get_filenames( $_[0] );
    485506
    486507    # svn ls -R is better, but much, much slower
    487508    # ( my $rc, my @result ) = run_command("$SVN ls --recursive $svnCheckoutCredentials $path");
     509
     510    # without the last true, run_command returns an error, if result is empty (?)
     511    # TODO: replace by perl find
    488512    ( my $rc, my @result ) =
    489513      run_command(
    490         "cd $path && find | grep -v '/.svn' | sed -e 's/\.\\///' | grep -v '^[\.]\$'"
     514        "cd $dirname_repo && find | grep -v '/.svn' | sed -e 's|\.\\/||' | grep -v '^[\.]\$'; true"
    491515      );
    492516    if ( $rc != 0 ) {
    493517        print @result;
    494         fatalerror;
     518        fatalerror('failed to get stored files');
    495519    }
    496520    chomp(@result);
     
    501525sub getModifiedFiles( ;$ )
    502526{
    503     # TODO: get_filenames?
    504     #my $rel_path = shift || "";
    505     #my $path = "${DASSCM_REPO}/${rel_path}";
    506     my $path = ${DASSCM_REPO};
    507     my @files = svn_getStoredFiles($path);
     527    (
     528        my $basename,
     529        my $dirname_prod,
     530        my $dirname_repo,
     531        my $filename_prod,
     532        my $filename_repo
     533      )
     534      = get_filenames( $_[0] );
     535
     536    my @files = svn_getStoredFiles( $dirname_prod );
    508537
    509538    # stores result from status (cvscheck)
     
    818847    check_env();
    819848
    820     # TODO: get_filenames?
    821     #my $rel_path = shift || "";
    822     #my $path = "${DASSCM_REPO}/${rel_path}";
    823     my $dir = ${DASSCM_REPO};
    824 
    825849    #
    826850    # update local repository
     
    828852    svn_update();
    829853
    830     ( my $refChangedFiles, my $refRemovedFiles ) = getModifiedFiles( $dir );
     854    ( my $refChangedFiles, my $refRemovedFiles ) = getModifiedFiles( "/" );
    831855    my %changedfiles = %{$refChangedFiles};
    832856    my %removedfiles = %{$refRemovedFiles};
     
    896920    check_env();
    897921
     922    (
     923        my $basename,
     924        my $dirname_prod,
     925        my $dirname_repo,
     926        my $filename_prod,
     927        my $filename_repo
     928      )
     929      = get_filenames( $_[0] || "/" );
     930
     931
    898932    # return code for the shell
    899933    # default: error
     
    905939    svn_update();
    906940
    907     # TODO: start at subdirectories ?
    908     my $dir   = $DASSCM_REPO;
    909     ( my $refChangedFiles, my $refRemovedFiles ) = getModifiedFiles( $dir );
     941    ( my $refChangedFiles, my $refRemovedFiles ) = getModifiedFiles( $dirname_prod );
    910942    my %changedfiles = %{$refChangedFiles};
    911943    my %removedfiles = %{$refRemovedFiles};
     
    927959        }
    928960    } else {
    929         print "no modified files found in $dir\n";
     961        print "no modified files found in $dirname_repo\n";
    930962        $return_code = $RETURN_OK;
    931963    }
     
    936968
    937969
    938 sub permissions(@)
     970sub permissions()
    939971{
    940972    check_parameter( @_, 1 );
     
    946978    #svn_update();
    947979
    948     # TODO: start at subdirectories ?
    949980    my $dir   = $DASSCM_REPO;
    950     my @files = svn_getStoredFiles($dir);
     981    my @files = svn_getStoredFiles( "/" );
    951982
    952983    if (@files) {
     
    10741105    } elsif (m/permissions/i) {
    10751106        $command = "permissions";
    1076         permissions(@ARGV);
     1107        permissions();
    10771108    } else {
    10781109        print "unknown command: $command\n\n";
Note: See TracChangeset for help on using the changeset viewer.