Changeset 209


Ignore:
Timestamp:
Jul 2, 2007, 6:01:28 PM (17 years ago)
Author:
joergs
Message:

migrated from dasscm_chkconf to dasscm status

Location:
trunk/dasscm
Files:
1 deleted
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dasscm/dasscm

    r208 r209  
    88  qw($DASSCM_PROD $DASSCM_REPO $USER $DASSCM_USERNAME $DASSCM_USER $DASSCM_PASSWORD);
    99use Cwd;
     10use POSIX qw/getpgrp tcgetpgrp/;
    1011use Term::ReadKey;
    1112use File::Basename;
     13use File::Compare;
     14use File::Copy;
     15use File::Find;
    1216use File::stat;
    1317use File::Path;
    14 use File::Copy;
    1518use Getopt::Long;
    1619
     
    4649
    4750my $verbose = 0;
     51
     52# stores result from status (cvscheck)
     53my %status_removedfiles = ();
     54my %status_changedfiles = ();
    4855
    4956#####################################################################
     
    179186}
    180187
     188#
     189# used by status
     190# checks for differences between PROD and (local) REPO
     191#
     192sub cvscheck
     193{
     194    return unless -f;    # keine Directories
     195    return if $File::Find::dir =~ /\/CVS$/;    # ignoriere CVS-Verzeichnisse
     196    return
     197      if $File::Find::dir =~
     198      /\/\.svn/; # ignoriere Subversion Verzeichnisse (inkl. Unterverzeichnisse)
     199    my $cvsworkfile = "$File::Find::dir/$_";
     200
     201    # Ursprungspfad ermitteln
     202    # TODO: get_filename ?
     203    $cvsworkfile =~ /${DASSCM_REPO}\/(.+)/;
     204    my $realfile = "/" . $1;
     205
     206    # relativer Pfad zur CVS-Arbeitsdatei
     207    my $relcvsworkfile = $1;
     208
     209    if ( !-r $realfile ) {
     210        $status_removedfiles{"$realfile"} = $cvsworkfile;
     211    } else {
     212        ( -r "$cvsworkfile" ) || die("Fehler: $cvsworkfile ist nicht lesbar");
     213        if ( compare( $cvsworkfile, $realfile ) != 0 ) {
     214
     215            # Dateien unterscheiden sich
     216            #(-w $cvsworkfile) || die("failed: no Fehler: kein Schreibrecht auf $cvsworkfile");
     217            # Arbeitskopie durch Kopie ersetzen
     218            #copy($realfile,$cvsworkfile) || die("Fehler beim kopieren $realfile --> $cvsworkfile");
     219            $status_changedfiles{"$realfile"} = $cvsworkfile;
     220        }
     221    }
     222}
     223
    181224sub run_command
    182225{
     
    290333    $ENV{'DASSCM_PASSWORD'} = $input_password;
    291334
    292     # TODO: print environment
    293 
    294     exec("bash") or die "can't login";
     335    print "subversion access okay\n\n", "DASSCM_USERNAME:   $input_username\n",
     336      "DASSCM_PASSWORD:   (hidden)\n", "DASSCM_PROD:       $DASSCM_PROD\n",
     337      "DASSCM_REPO:       $DASSCM_REPO\n",
     338      "Server Repository: $DASSCM_SVN_REPOSITORY\n", "\n", "[dasscm shell]\n\n";
     339
     340    exec("bash") or die "failed to start new shell";
    295341}
    296342
     
    404450      run_command("diff $filename_repo $filename_prod");
    405451    print @diff;
     452}
     453
     454sub status(@)
     455{
     456    check_parameter( @_, 1 );
     457    check_env();
     458
     459    #
     460    # update local repository
     461    #
     462    svn_update();
     463
     464    # TODO: start at subdirectories ?
     465    my $cvsworkdir = $DASSCM_REPO;
     466
     467    File::Find::find( \&cvscheck, $cvsworkdir );
     468
     469    # Liste der geänderten Files ausgeben, falls nicht leer
     470    # Anzahl Elemente im Hash???
     471    my @changedfiles = keys %status_changedfiles;
     472
     473    if ( %status_changedfiles or %status_removedfiles ) {
     474        if (%status_removedfiles) {
     475            print "deleted files:\n";
     476            foreach my $key ( values %status_removedfiles ) {
     477                print "$key\n";
     478            }
     479            print "\n";
     480        }
     481
     482        if (%status_changedfiles) {
     483            print "modified files:\n";
     484            foreach my $key ( keys %status_changedfiles ) {
     485                print "$key\n";
     486            }
     487        }
     488    } else {
     489        print "no modified files found in $cvsworkdir\n";
     490    }
     491    print "\n";
     492
    406493}
    407494
     
    472559        $command = "diff";
    473560        diff(@ARGV);
     561    } elsif (m/status/i) {
     562        $command = "status";
     563        status(@ARGV);
    474564    } elsif (m/activate/i) {
    475565        ## TODO
     
    480570    }
    481571
    482     # login
    483572    # up
     573    # cleanup (svn-commit.tmp)
    484574    # commitall
    485575    # revert
Note: See TracChangeset for help on using the changeset viewer.