<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,6 +1,7 @@
 @echo off
-echo tree-sync.pl test script for Windows
-echo $Id: test-tree-sync.cmd,v 1.4 2007/04/21 05:28:21 paulg Exp $
+echo A very simple tree-sync.pl test script for Windows
+echo Tests most of the tree-sync functions assuming an ActivePerl environment
+echo This should probably be a Perl script itself ... but hey, so many hours in the day only!
 echo ----------------------------------------------------------------
 
 setlocal
@@ -18,11 +19,11 @@ set srcDir=%TEMP%
 set destDir=%TEMP%
 rem                     Also, set scriptDrive and srcDrive if the srcDir is on 
 rem                     different drive from where this script is executed
-set scriptDrive=c:
+set scriptDrive=d:
 set srcDrive=c:
 rem END CUSTOMISATION NOTE
 
-set scriptName=d:\mydocs\mydev\tree-sync\tree-sync.pl
+set scriptName=tree-sync.pl
 set srcFolder=ts-test-src
 set destFolder=ts-test-dest
 set srcRoot=%srcDir%\%srcFolder%
@@ -278,7 +279,7 @@ echo &quot;test9+10 modified on dest&quot; &gt;&gt; &quot;%destRoot%\dir 1\file 3.txt&quot;
 rem change drive/directory
 %srcDrive%
 cd %srcRoot%
-perl %scriptName% %opts% .\ ..\%destFolder%\ &gt;&gt; %log%
+perl %scriptDrive%%scriptName% %opts% .\ ..\%destFolder%\ &gt;&gt; %log%
 
 if %grepstatus% == 0 goto grepcheck10
 echo              (not checking file explicitly with grep)
@@ -322,7 +323,103 @@ echo              ... fail. Error in sync: Check results
 echo              ... fail. Error in sync: Check results &gt;&gt; %log%
 goto end
 
+
 :test12
+echo ============ Test 12: Test for sync of read-only files
+echo              Expected behaviour: read-only files should sync properly
+echo ============ Test 12: Test for sync of read-only files &gt;&gt; %log%
+echo              Expected behaviour: read-only files should sync properly &gt;&gt; %log%
+set f=&quot;%srcRoot%\file 5.txt&quot;
+set fd=&quot;%destRoot%\file 5.txt&quot;
+echo &quot;Test 12 attrib +R set on source&quot; &gt;&gt; %f%
+attrib +R %f%
+perl %scriptName% %opts% %srcRoot%\ %destRoot%\ &gt;&gt; %log% 
+attrib -R %f%
+sleep 3
+echo &quot;Test 12 OK changed after attrib +R set on source&quot; &gt;&gt; %f%
+attrib +R %f%
+perl %scriptName% %opts% %srcRoot%\ %destRoot%\ &gt;&gt; %log% 
+
+if %grepstatus% == 0 goto grepcheck12
+echo              (not checking file explicitly with grep)
+if not exist %fd% goto fail12
+echo              ... pass
+echo              ... pass &gt;&gt; %log%
+goto test13
+:grepcheck12
+echo              (checking file explicitly with grep)
+grep -c &quot;Test 12 OK&quot; %fd% &gt; nul
+if %errorlevel% == 1 goto fail12
+echo              ... pass
+goto test13
+:fail12
+echo              ... fail. Error in sync: Check results
+echo              ... fail. Error in sync: Check results &gt;&gt; %log%
+goto end
+
+:test13
+echo ============ Test 13: Test for sync of read-write file where dest has been made read-only
+echo              Expected behaviour: files should sync properly (-force by default)
+echo ============ Test 13: Test for sync of read-write file where dest has been made read-only &gt;&gt; %log%
+echo              Expected behaviour: files should sync properly (-force by default) &gt;&gt; %log%
+set f=&quot;%srcRoot%\file 6.txt&quot;
+set fd=&quot;%destRoot%\file 6.txt&quot;
+echo &quot;Test 13 created read-write on source&quot; &gt;&gt; %f%
+perl %scriptName% %opts% %srcRoot%\ %destRoot%\ &gt;&gt; %log% 
+attrib +R %fd%
+sleep 3
+echo &quot;Test 13 OK changed after attrib +R set on dest&quot; &gt;&gt; %f%
+perl %scriptName% %opts% %srcRoot%\ %destRoot%\ &gt;&gt; %log% 
+
+if %grepstatus% == 0 goto grepcheck13
+echo              (not checking file explicitly with grep)
+if not exist %fd% goto fail13
+echo              ... pass
+echo              ... pass &gt;&gt; %log%
+goto test14
+:grepcheck13
+echo              (checking file explicitly with grep)
+grep -c &quot;Test 13 OK&quot; %fd% &gt; nul
+if %errorlevel% == 1 goto fail13
+echo              ... pass
+goto test14
+:fail13
+echo              ... fail. Error in sync: Check results
+echo              ... fail. Error in sync: Check results &gt;&gt; %log%
+goto end
+
+:test14
+echo ============ Test 14: Test for non-sync of read-write file where dest has been made read-only and -noforce specified
+echo              Expected behaviour: files should not sync (-noforce)
+echo ============ Test 14: Test for non-sync of read-write file where dest has been made read-only and -noforce specified &gt;&gt; %log%
+echo              Expected behaviour: files should not sync (-noforce) &gt;&gt; %log%
+set f=&quot;%srcRoot%\file 6.txt&quot;
+set fd=&quot;%destRoot%\file 6.txt&quot;
+echo &quot;Test 14 created read-write on source&quot; &gt;&gt; %f%
+perl %scriptName% %opts% %srcRoot%\ %destRoot%\ &gt;&gt; %log% 
+attrib +R %fd%
+sleep 3
+echo &quot;Test 14 OK changed after attrib +R set on dest and -noforce&quot; &gt;&gt; %f%
+perl %scriptName% %opts% -noforce %srcRoot%\ %destRoot%\ &gt;&gt; %log% 
+
+if %grepstatus% == 0 goto grepcheck14
+echo              (not checking file explicitly with grep)
+if not exist %fd% goto fail14
+echo              ... pass
+echo              ... pass &gt;&gt; %log%
+goto test15
+:grepcheck14
+echo              (checking file explicitly with grep)
+grep -c &quot;Test 14 OK&quot; %fd% &gt; nul
+if not %errorlevel% == 1 goto fail13
+echo              ... pass
+goto test15
+:fail14
+echo              ... fail. Error in sync: Check results
+echo              ... fail. Error in sync: Check results &gt;&gt; %log%
+goto end
+
+:test15
 
 :cleanup
 goto end</diff>
      <filename>test-tree-sync.cmd</filename>
    </modified>
    <modified>
      <diff>@@ -5,7 +5,7 @@
 tree-sync.pl - sync two directories recursively. The goal is to bring two trees exactly the same. However, tree-sync.pl does not perform any copy operation by default (it generates a command file instead). The user has the opportunity to exam the command file before real copy operations happen.
 
 =head1 VERSION
-Version 2.2 Modified $Date: 2007/04/21 05:28:21 $ 
+Version 2.4 Modified $Date: 2008/10/26 20:58:00 $ 
 
 =head1 DESCRIPTION
 
@@ -25,16 +25,22 @@ Run &quot;tree-sync.pl -help&quot; to find out command-line options.
 To download, visit: 
   http://www.perl.com/CPAN 
   http://www.perl.com/CPAN/authors/id/P/PA/PAULPG/tree-sync/
-
+Sources are now managed on github.com. To download, or join the project, visit:
+  http://github.com/tardate/tree-sync/
+  
+  
 Release 1 by Chang Liu (liu@ics.uci.edu | changliu@acm.org)
 Copyright (c) 2000 Chang  Liu. All rights reserved.  
 License: GPL: GNU General Public License (http://www.gnu.org/copyleft/gpl.html). 
 
-Release 2 by Paul Gallagher (gallagher.paul@gmail.com)
+Release 2.0-2.2 by Paul Gallagher (gallagher.paul@gmail.com)
 Note: since attempts to contact the author of Release 1 have unfortunately failed
       to date, this version has been released without review from the original author.
 
-Release 3 by Dave Stafford (dave.stafford@globis.net)
+Release 2.3 by Dave Stafford (dave.stafford@globis.net)
+
+Release 2.4 by incorporates changes by Dave Stafford (dave.stafford@globis.net)
+      and Paul Gallagher (gallagher.paul@gmail.com)
 
 
 =head1 SYNCHRONISATION RULES
@@ -81,21 +87,32 @@ Sync Notes:
 
 =head1 CHANGES
 
+From Version 2.3 to Version 2.4:
+
+Refinements for 'ignore' operation.
+Moved to github hosting
+Introduced read-only file handling
+
+ 
 From Version 2.2 to Version 2.3:
+
 Added option 'diff' to view only changes 
 Added option 'ignore' to exclude certain extensions
 Added option 'brief' to remove src/dst directories in report view to make cleaner output
 
+
 From Version 2.1 to Version 2.2:
 
 1. fixed handling of filenames that contain special characters such as @, $ and quotes
 2. fixed handling of filenames that contain regex special characters
 
+
 From Version 2.0 to Version 2.1:
 
 1. changed copy routine to force a copy of access/modified times. This change was needed because I discovered modification
    times are not copied automatically on most	filesystems (other than windows).
 
+
 From Version 1.0 to Version 2.0:
 
 1. fixed report width calculations
@@ -169,7 +186,7 @@ name/  : it is a directory
 use strict;
 use warnings;
 
-my $VERSION = 2.3;
+my $VERSION = 2.4;
 
 ############# USAGE ##############################
 #
@@ -193,7 +210,8 @@ OPTIONS:
     [-brief]       make report cleaner by removing src/dst directories
     [-ignore EXT]  comma separated list of extensions to ignore
     [-verbose]     default is false
-    [-diff]        show only differences default is false
+    [-diff]        show only differences. Default is false
+    [-force | -noforce] forces overwrite of read-only files. Default is -force
     [-cmd SYNC-CMD-FILENAME] default is sync-now.pl. 
     [-run]         runs the sync routine immediately, overrides -cmd option. default is false
     [-width SCREEN-WIDTH] default is 80
@@ -205,13 +223,14 @@ PARAMETERS:
     DIR2 = target directory. Must be a directory. Will br created if it does not exist.
 
 EXAMPLE:
-    c:/&gt;perl tree-sync.pl -cmd mysync.pl /home/chang/work/prj /mnt/f/backup/prj
+    c:/&gt; perl tree-sync.pl -run -force &quot;c:\\My Documents&quot; d:\\backup\\mydocs
 or
-    %perl tree-sync.pl -width 200 -verbose /home/chang/work/prj /mnt/f/backup/prj
+    % perl tree-sync.pl -cmd mysync.pl -width 200 -verbose /home/chang/work/prj /mnt/f/backup/prj
 
 After that:
-    %cat sync-now.pl
-    %perl sync-now.pl
+    % cat sync-now.pl
+    % perl sync-now.pl
+    
 NOTE:
 It is recommended you DO NOT use the -run option until you have first tested using -cmd.
 Review the generated script file and report to verify that the sync is performing correctly.
@@ -219,7 +238,7 @@ Review the generated script file and report to verify that the sync is performin
 
 END_OF_USAGE
 
-	print &quot;Version: $VERSION   &quot;.'Last modified: $Date: 2007/04/21 05:28:21 $'.&quot;\n&quot;;
+	print &quot;Version: $VERSION   &quot;.'Last modified: $Date: 2008/10/26 20:58:00 $'.&quot;\n&quot;;
     exit;
 }
 
@@ -249,6 +268,7 @@ my $opt_run;
 my $opt_diff;
 my $opt_ignore;
 my $opt_brief;
+my $opt_force = 1;
 my $mtimeDiffTolerance = 2;
 
 GetOptions(&quot;verbose&quot; =&gt; \$opt_verbose,
@@ -261,7 +281,8 @@ GetOptions(&quot;verbose&quot; =&gt; \$opt_verbose,
            &quot;run&quot; =&gt; \$opt_run,
            &quot;brief&quot; =&gt; \$opt_brief,
            &quot;diff&quot; =&gt; \$opt_diff,
-           &quot;ignore=s&quot; =&gt; \$opt_ignore
+           &quot;ignore=s&quot; =&gt; \$opt_ignore,
+           &quot;force!&quot; =&gt; \$opt_force
 	   );
 
 print &quot;DEBUG:tree-sync.pl VERSION: $VERSION\n&quot; if $opt_debug;
@@ -274,6 +295,7 @@ if ($opt_ignore) {
 	  $opt_ignore.='$';
 }
 ## END ADDED DGS
+
 my $sourceDirectory = shift or usage(&quot;Source not specified&quot;);
 my $targetDirectory = shift or usage(&quot;Target not specified&quot;);
 
@@ -385,6 +407,7 @@ sub report
 	$right = shift;
 	my $type = shift;
 	my $diff = shift;
+  return if $type==1 &amp;&amp; $opt_brief;
 
   $left=~s/$sourceDirectory//  if $opt_brief;
   $right=~s/$targetDirectory// if $opt_brief;
@@ -579,11 +602,13 @@ sub create_sync_script
 #
 use File::stat;
 use File::Copy;
-# subroutine to copt access/modified times from source to dest file
+# subroutine to copy access/modified times from source to dest file
 sub copyWithTime {
 	my (\$srcFile, \$destFile) = \@_;
 	my \$srcAtime=stat(\$srcFile)-&gt;atime;
-	my \$srcMtime=stat(\$srcFile)-&gt;mtime;
+	my \$srcMtime=stat(\$srcFile)-&gt;mtime; 
+	# allow write on dest if file present
+	chmod stat(\$destFile)-&gt;mode | 0222, \$destFile if ((-e &quot;\$destFile&quot; ) &amp;&amp; !(-d &quot;\$destFile&quot; )); 
 	copy(\$srcFile, \$destFile);
 	utime \$srcAtime, \$srcMtime, \$destFile;
 	return;
@@ -685,6 +710,8 @@ sub copyWithTime {
 	my ($srcFile, $destFile) = @_;
 	my $srcAtime=stat($srcFile)-&gt;atime;
 	my $srcMtime=stat($srcFile)-&gt;mtime;
+	# allow write on dest if file present and &quot;force&quot; specified
+	chmod stat($destFile)-&gt;mode | 0222, $destFile if (($opt_force) &amp;&amp; (-e &quot;$destFile&quot; ) &amp;&amp; !(-d &quot;$destFile&quot; )); 
 	copy($srcFile, $destFile);
 	utime $srcAtime, $srcMtime, $destFile;
 	return;</diff>
      <filename>tree-sync.pl</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>b54456dd868b9b170cdd8d4bfc3b6a6f8918e8a1</id>
    </parent>
  </parents>
  <author>
    <name>tardate</name>
    <email>gallagher.paul@gmail.com</email>
  </author>
  <url>http://github.com/tardate/tree-sync/commit/f2867ecfbdabe1b88d9f16a7bf748d9f0b55e05f</url>
  <id>f2867ecfbdabe1b88d9f16a7bf748d9f0b55e05f</id>
  <committed-date>2008-10-26T18:23:08-07:00</committed-date>
  <authored-date>2008-10-26T18:23:08-07:00</authored-date>
  <message>version 2.4</message>
  <tree>ac8743de19c3efb673524d4e4d4deb89b204208c</tree>
  <committer>
    <name>tardate</name>
    <email>gallagher.paul@gmail.com</email>
  </committer>
</commit>
