| OLD | NEW |
| 1 #!/bin/env python | 1 #!/bin/env python |
| 2 # Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Wrapper around BeyondCompare or kdiff3 so it can be used as svn's diff3-cmd | 6 """Wrapper around BeyondCompare or kdiff3 so it can be used as svn's diff3-cmd |
| 7 tool. | 7 tool. |
| 8 | 8 |
| 9 The basic idea here is based heavily off of diffwrap.py at: | 9 The basic idea here is based heavily off of diffwrap.py at: |
| 10 http://svnbook.red-bean.com/en/1.5/svn.advanced.externaldifftools.html#svn.advan
ced.externaldifftools.diff3.ex-1 | 10 http://svnbook.red-bean.com/en/1.5/svn.advanced.externaldifftools.html#svn.advan
ced.externaldifftools.diff3.ex-1 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 shell=True) | 101 shell=True) |
| 102 except Exception,e: | 102 except Exception,e: |
| 103 print "Error running " + (" ".join(cmd)) | 103 print "Error running " + (" ".join(cmd)) |
| 104 traceback.print_exc(file=sys.stdout) | 104 traceback.print_exc(file=sys.stdout) |
| 105 | 105 |
| 106 # After performing the merge, this script needs to print the contents | 106 # After performing the merge, this script needs to print the contents |
| 107 # of the merged file to stdout. | 107 # of the merged file to stdout. |
| 108 # Return an errorcode of 0 on successful merge, 1 if unresolved conflicts | 108 # Return an errorcode of 0 on successful merge, 1 if unresolved conflicts |
| 109 # remain in the result. Any other errorcode will be treated as fatal. | 109 # remain in the result. Any other errorcode will be treated as fatal. |
| 110 merged_file_contents = open(mine).read() | 110 merged_file_contents = open(mine).read() |
| 111 # Ensure that the file doesn't use CRLF, in case the diff program converted | |
| 112 # line endings. | |
| 113 merged_file_contents.replace('\r\n', '\n') | |
| 114 | 111 |
| 115 # For reasons I don't understand, an extra line break gets added at the end | 112 # For reasons I don't understand, an extra line break gets added at the end |
| 116 # of the file. Strip it. | 113 # of the file. Strip it. |
| 117 merged_file_contents = merged_file_contents[:-1] | 114 merged_file_contents = merged_file_contents[:-1] |
| 118 print merged_file_contents | 115 print merged_file_contents |
| 119 return return_code | 116 return return_code |
| 120 | 117 |
| 121 if '__main__' == __name__: | 118 if '__main__' == __name__: |
| 122 try: | 119 try: |
| 123 return_code = main(sys.argv) | 120 return_code = main(sys.argv) |
| 124 except Exception,e: | 121 except Exception,e: |
| 125 traceback.print_exc(file=sys.stdout) | 122 traceback.print_exc(file=sys.stdout) |
| 126 # diff3 uses '1' to mean "conflict" and 2 to mean "I barfed". | 123 # diff3 uses '1' to mean "conflict" and 2 to mean "I barfed". |
| 127 sys.exit(2) # return "I barfed" | 124 sys.exit(2) # return "I barfed" |
| 128 sys.exit(return_code) | 125 sys.exit(return_code) |
| OLD | NEW |