Index: trunk/dasscm/dasscm
===================================================================
--- trunk/dasscm/dasscm	(revision 237)
+++ trunk/dasscm/dasscm	(revision 238)
@@ -26,4 +26,7 @@
 my $permissions_file = "/etc/permissions.d/dasscm.permission_backup";
 
+# documentation file (for usage)
+my $doc_file = "/usr/share/doc/packages/dasscm/dasscm_howto.txt";
+
 # configuration file
 my $config_file = "/etc/dasscm.conf";
@@ -33,9 +36,12 @@
 my $DASSCM_SVN_REPOSITORY;
 
+# current directory at program start
+my $StartDirectory = cwd();
+
 my $SVN                    = "svn ";
 my $svnOptions             = "";
 my $svnCheckoutCredentials = "";
 my $svnPasswordCredentials = "";
-my $DIFF                   = "diff --exclude .svn ";
+my $diff                   = "diff --exclude .svn ";
 
 # command line options get stored in options hash
@@ -69,5 +75,5 @@
     print "   permissions\n";
     print "\n";
-    print "preperation:\n", "  if dasscm is already configured,\n",
+    print "preparation:\n", "  if dasscm is already configured,\n",
       "  use 'dasscm login' and then eg. 'add'.\n",
       "  The environment variables\n", "    DASSCM_REPO\n", "    DASSCM_PROD\n",
@@ -75,5 +81,5 @@
       "  are evaluated, but set automatically by 'dasscm login'.\n", "\n",
       "  If dasscm is not yet configured, read",
-      "  /usr/share/doc/packages/dasscm/dasscm_howto.txt\n";
+      "  $doc_file\n";
 }
 
@@ -95,4 +101,8 @@
 }
 
+
+#
+# reading config file and return key/value pairs as hash
+#
 sub get_config
 {
@@ -115,5 +125,5 @@
             }
             if ( $_ =~ /=/g ) {
-                ## splitting in 2 fields at maximum
+                # splitting in 2 fields at maximum
                 my ( $option, $value ) = split( /=/, $_, 2 );
                 $option =~ s/^\s+//g;
@@ -212,16 +222,18 @@
 sub check_parameter(@)
 {
-    if( not @_ ) {
-        fatalerror( "no files specified. See 'dasscm --help'" );
-    }
-}
-
+}
+
+
+#
+# generate from (relative) filename 
+# all required file and directory names:
+# $basename,      $dirname_prod, $dirname_repo,
+# $filename_prod, $filename_repo
+#
 sub get_filenames(@)
 {
     my $filename_prod = $_[0];
 
-    # remove leading './' from relative directories
-    #$filename_prod =~ s/^\.\///;
-
+    # make filename absolut
     if ( !( $filename_prod =~ m/^\// ) ) {
         $filename_prod = cwd() . "/" . $filename_prod;
@@ -231,24 +243,14 @@
         fatalerror( $filename_prod  . " is not accessable" );
     }
-    #      elsif( -l $filename_prod ) {
-    #         my $dest = readlink($filename_prod);
-    #         # TODO:
-    #         #   default: disallow, but offer cmd switch to activate
-    #         #   (or check, if file is already checked in and has been a link before)
-    #         warning( "'$filename_prod' is a link to '$dest'.", "Please check, if '$dest' should be stored in repository instead" );
-    #         if( ! -f $dest ) {
-    #             fatalerror( "link target '$dest' is not a regular file. Giving up" );
-    #         }
-    #     } elsif( ! -f $filename_prod ) {
-    #         #fatalerror( $filename_prod . " is not a regular file" );
-    #     }
 
     # TODO: dirname buggy: eg. "/etc/" is reduced to "/",
     #	"/etc" is used as filename
     my $dirname_prod = dirname($filename_prod);
-    my $oldpath = cwd();
+
+    # uses chdir to determine real directory in a unique way
     chdir $dirname_prod or die $!;
     $dirname_prod = cwd();
-    chdir $oldpath;
+    chdir $StartDirectory;
+
     my $basename = basename($filename_prod);
 
@@ -362,4 +364,12 @@
     print "checking credentials ... ";
 
+    if( ! $username ) {
+        fatalerror( "no username given" );
+    }
+
+    if( ! $password ) {
+        fatalerror( "no password given" );
+    }
+
     # Options for "svn info" are not supported by subversion 1.0.0 (SLES9),
     # therefore switching to "svn status"
@@ -376,6 +386,6 @@
 
     if ( $rc_update != 0 ) {
-        print @result;
-        die;
+        print "\n", @result;
+        fatalerror();
     }
 
@@ -390,5 +400,5 @@
     print @result;
     if ( $rc_update != 0 ) {
-        die;
+        fatalerror();
     }
 }
@@ -410,5 +420,5 @@
     if ( $rc != 0 ) {
         print @result;
-        die;
+        fatalerror;
     }
     chomp(@result);
@@ -417,4 +427,9 @@
 
 
+#
+# from an array of files/dirs,
+# generates list of files
+# sorted by type
+#
 sub get_files( @ )
 {
@@ -496,5 +511,5 @@
     print "\n";
 
-    svn_check_credentials( $input_username, $input_password );
+    svn_check_credentials( $input_username || $DASSCM_USERNAME, $input_password );
 
     #
@@ -571,11 +586,11 @@
     }
 
+    # TODO: are permissions also copied?
     copy( $filename_prod, $filename_repo ) or error "failed to copy $filename_prod to repository: $!";
 
     if ( $command eq "add" ) {
 
-        my $oldpath = cwd();
         # already checked in?
-        chdir($DASSCM_REPO);
+        chdir $DASSCM_REPO;
 
         # also add the path to filename.
@@ -593,5 +608,5 @@
             print join( "\n", @out );
         } 
-        chdir($oldpath);
+        chdir $StartDirectory;
     }
 }
@@ -633,4 +648,6 @@
         print "\n";
     }
+
+    # TODO: confirm
 
     # copy files one by one to local repository
@@ -700,7 +717,8 @@
     }
 
-    ( my $rc_diff, my @diff ) =
-      run_command( $DIFF . " $filename_repo $filename_prod");
-    print @diff;
+    ( my $rc_diff, my @diff_result ) =
+      run_command( $diff . " $filename_repo $filename_prod");
+
+    print @diff_result;
 }
 
