vadvs (vadvs) wrote in changelog,
vadvs
vadvs
changelog

[vcv] r52: LJSUP-8088: Improve bin/vcv so it could ...

Committer: vad
LJSUP-8088: Improve bin/vcv so it could copy updated sources to multiple targets.
U   trunk/bin/vcv
Modified: trunk/bin/vcv
===================================================================
--- trunk/bin/vcv	2011-01-28 04:35:55 UTC (rev 51)
+++ trunk/bin/vcv	2011-03-05 08:20:35 UTC (rev 52)
@@ -391,16 +391,33 @@
     my $lfile = "$DIR_LIVE/$relfile";
     my $cfile = "$DIR_CVS/$cvspath{$relfile}";
 
+    ## Informational stage
     if ($opt_map) {
         print "$relfile\t$cvspath{$relfile}\n";
         next;
     }
-
+    
+    ## Informational stage
     if ($opt_livelist) {
         print "$relfile\n";
         next;
     }
 
+    ## Determine sources and targets for copying.
+    ##
+    ## Some of a source targets should be copied to more than just a one live place.
+    ## I.e. 
+    ##  cvs/ljcom/htdocs/create.bml -> 
+    ##          htdocs/create.bml and 
+    ##          ssldocs/create.bml
+    ##
+    ## (!) But do it only when copy from source to _live_ dir.
+    ## (we do not have file in source dirs that are mapped to several source dirs.
+    my $copy_copies = 0; ## by default do not update extra targets.
+    
+    ## Strictly speaking that's the list of extra targets.
+    my @extra_targets = extra_live_targets($root, $relfile);
+
     if ($init) {
         if ($require_size_change) {
             next if (-s $lfile) == (-s $cfile);
@@ -415,6 +432,8 @@
         if ($opt_force_cvs) {
             $status = "main <- $root";
             ($from, $to) = ($cfile, $lfile);
+
+            $copy_copies = 1;
         } else {
             if ($ltime > $ctime && ! $cvsonly) {
                 $status = "main -> $root";
@@ -423,6 +442,8 @@
             if ($ctime > $ltime && ! $liveonly) {
                 $status = "main <- $root";
                 ($from, $to) = ($cfile, $lfile);
+
+                $copy_copies = 1;
             }
         }
     }
@@ -452,12 +473,26 @@
     if ($sync) {
         make_dirs($relfile);
         copy($from, $to);
+
+        ## Handle extra targets
+        if ($copy_copies){
+            foreach my $target (@extra_targets){
+                make_dirs($target->{relfile});
+                copy($from => $target->{to});
+            }
+        }
     }
 
     if ($opt_justfiles) {
         print "$relfile\n";
     } else {
         printf "%-25s %s\n", $status, $relfile;
+        ## show info about extra targets
+        if ($copy_copies){
+            foreach my $target (@extra_targets){
+                printf "%-25s %s\n", $target->{status}, $target->{relfile};
+            }
+        }
         print $the_diff;
     }
 }
@@ -728,6 +763,25 @@
     return ($ret == 0);
 }
 
+sub extra_live_targets {
+    my $root    = shift;
+    my $relfile = shift;
+
+    return () unless $relfile =~ m|^htdocs/(.+)|;
+
+    my $sroot = "ssldocs/$1";
+    my @extra_targets = ();
+    if ($cvspath{$sroot}){
+        my $sfile = "$DIR_LIVE/$sroot"; 
+        push @extra_targets => { to => $sfile,
+                                 status => "ssl main <- $root",
+                                 relfile => $sroot,
+                                 };
+    }
+    return @extra_targets;
+}
+
+
 package VCV::SVK;
 use strict;
 
@@ -806,5 +860,4 @@
     }
 }
 
-
 __END__

Tags: vadvs, vcv
Subscribe

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments