]> granicus.if.org Git - python/commitdiff
When checking for equality, open the slave file in text mode so it
authorGuido van Rossum <guido@python.org>
Tue, 4 Nov 1997 17:35:43 +0000 (17:35 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 4 Nov 1997 17:35:43 +0000 (17:35 +0000)
will compare equal even if the master file uses only \n to terminate
lines (this is by far the most common situation).  Also, check for the
case where the master file is missing, and print the time difference
in seconds when the slave file appears newer than the master (for
debugging).

Tools/scripts/treesync.py

index f0393858df3f0599d78b0f8862603240fe823671..26c3cd5ea7e07ece19d5858c78901a1c2231ef01 100755 (executable)
@@ -108,7 +108,7 @@ def process(slave, master):
 
 def compare(slave, master):
     try:
-       sf = open(slave, 'rb')
+       sf = open(slave, 'r')
     except IOError:
        sf = None
     try:
@@ -117,11 +117,14 @@ def compare(slave, master):
        mf = None
     if not sf:
        if not mf:
-           print "Not updating missing master", master
+           print "Neither master nor slave exists", master
            return
        print "Creating missing slave", slave
        copy(master, slave, answer=create_files)
        return
+    if not mf:
+       print "Not updating missing master", master
+       return
     if sf and mf:
        if identical(sf, mf):
            return
@@ -136,6 +139,7 @@ def compare(slave, master):
        copy(master, slave, answer=write_slave)
        return
     # Slave is newer -- copy slave to master
+    print "Slave is", sft-mft, "seconds newer than master"
     # But first check what to do about CRLF
     mf.seek(0)
     fun = funnychars(mf)