Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 79b2038

Browse files
committed
When checking for equality, open the slave file in text mode so it
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).
1 parent 19f4456 commit 79b2038

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

Tools/scripts/treesync.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def process(slave, master):
108108

109109
def compare(slave, master):
110110
try:
111-
sf = open(slave, 'rb')
111+
sf = open(slave, 'r')
112112
except IOError:
113113
sf = None
114114
try:
@@ -117,11 +117,14 @@ def compare(slave, master):
117117
mf = None
118118
if not sf:
119119
if not mf:
120-
print "Not updating missing master", master
120+
print "Neither master nor slave exists", master
121121
return
122122
print "Creating missing slave", slave
123123
copy(master, slave, answer=create_files)
124124
return
125+
if not mf:
126+
print "Not updating missing master", master
127+
return
125128
if sf and mf:
126129
if identical(sf, mf):
127130
return
@@ -136,6 +139,7 @@ def compare(slave, master):
136139
copy(master, slave, answer=write_slave)
137140
return
138141
# Slave is newer -- copy slave to master
142+
print "Slave is", sft-mft, "seconds newer than master"
139143
# But first check what to do about CRLF
140144
mf.seek(0)
141145
fun = funnychars(mf)

0 commit comments

Comments
 (0)