mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 21:51:50 +00:00 
			
		
		
		
	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).
This commit is contained in:
		
							parent
							
								
									19f44560f2
								
							
						
					
					
						commit
						79b2038aa4
					
				
					 1 changed files with 6 additions and 2 deletions
				
			
		|  | @ -108,7 +108,7 @@ def process(slave, master): | ||||||
| 
 | 
 | ||||||
| def compare(slave, master): | def compare(slave, master): | ||||||
|     try: |     try: | ||||||
| 	sf = open(slave, 'rb') | 	sf = open(slave, 'r') | ||||||
|     except IOError: |     except IOError: | ||||||
| 	sf = None | 	sf = None | ||||||
|     try: |     try: | ||||||
|  | @ -117,11 +117,14 @@ def compare(slave, master): | ||||||
| 	mf = None | 	mf = None | ||||||
|     if not sf: |     if not sf: | ||||||
| 	if not mf: | 	if not mf: | ||||||
| 	    print "Not updating missing master", master | 	    print "Neither master nor slave exists", master | ||||||
| 	    return | 	    return | ||||||
| 	print "Creating missing slave", slave | 	print "Creating missing slave", slave | ||||||
| 	copy(master, slave, answer=create_files) | 	copy(master, slave, answer=create_files) | ||||||
| 	return | 	return | ||||||
|  |     if not mf: | ||||||
|  | 	print "Not updating missing master", master | ||||||
|  | 	return | ||||||
|     if sf and mf: |     if sf and mf: | ||||||
| 	if identical(sf, mf): | 	if identical(sf, mf): | ||||||
| 	    return | 	    return | ||||||
|  | @ -136,6 +139,7 @@ def compare(slave, master): | ||||||
| 	copy(master, slave, answer=write_slave) | 	copy(master, slave, answer=write_slave) | ||||||
| 	return | 	return | ||||||
|     # Slave is newer -- copy slave to master |     # Slave is newer -- copy slave to master | ||||||
|  |     print "Slave is", sft-mft, "seconds newer than master" | ||||||
|     # But first check what to do about CRLF |     # But first check what to do about CRLF | ||||||
|     mf.seek(0) |     mf.seek(0) | ||||||
|     fun = funnychars(mf) |     fun = funnychars(mf) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Guido van Rossum
						Guido van Rossum