| OLD | NEW |
| 1 # Copyright (c) 2010 Google Inc. All rights reserved. | 1 # Copyright (c) 2010 Google Inc. All rights reserved. |
| 2 # | 2 # |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
| 5 # met: | 5 # met: |
| 6 # | 6 # |
| 7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
| 9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
| 10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 if not self._tool.user.can_open_url(): | 66 if not self._tool.user.can_open_url(): |
| 67 return None | 67 return None |
| 68 try: | 68 try: |
| 69 pretty_patch = PrettyPatch(self._tool.executive) | 69 pretty_patch = PrettyPatch(self._tool.executive) |
| 70 patch = self._diff(options) | 70 patch = self._diff(options) |
| 71 pretty_diff_file = pretty_patch.pretty_diff_file(patch) | 71 pretty_diff_file = pretty_patch.pretty_diff_file(patch) |
| 72 self._open_pretty_diff(pretty_diff_file.name) | 72 self._open_pretty_diff(pretty_diff_file.name) |
| 73 # We return the pretty_diff_file here because we need to keep the | 73 # We return the pretty_diff_file here because we need to keep the |
| 74 # file alive until the user has had a chance to confirm the diff. | 74 # file alive until the user has had a chance to confirm the diff. |
| 75 return pretty_diff_file | 75 return pretty_diff_file |
| 76 except ScriptError as e: | 76 except ScriptError as error: |
| 77 _log.warning("PrettyPatch failed. :(") | 77 _log.warning("PrettyPatch failed. :(") |
| 78 _log.error(e.message_with_output()) | 78 _log.error(error.message_with_output()) |
| 79 self._exit(e.exit_code or 2) | 79 self._exit(error.exit_code or 2) |
| 80 except OSError: | 80 except OSError: |
| 81 _log.warning("PrettyPatch unavailable.") | 81 _log.warning("PrettyPatch unavailable.") |
| 82 | 82 |
| 83 def _diff(self, options): | 83 def _diff(self, options): |
| 84 changed_files = self._tool.scm().changed_files(options.git_commit) | 84 changed_files = self._tool.scm().changed_files(options.git_commit) |
| 85 return self._tool.scm().create_patch(options.git_commit, | 85 return self._tool.scm().create_patch(options.git_commit, |
| 86 changed_files=changed_files) | 86 changed_files=changed_files) |
| 87 | 87 |
| 88 def _open_pretty_diff(self, file_path): | 88 def _open_pretty_diff(self, file_path): |
| 89 if self._tool.platform.is_cygwin(): | 89 if self._tool.platform.is_cygwin(): |
| 90 assert file_path.endswith('.html') | 90 assert file_path.endswith('.html') |
| 91 self._tool.executive.run_command(['cygstart', file_path]) | 91 self._tool.executive.run_command(['cygstart', file_path]) |
| 92 return | 92 return |
| 93 url = "file://%s" % urllib.quote(file_path) | 93 url = "file://%s" % urllib.quote(file_path) |
| 94 self._tool.user.open_url(url) | 94 self._tool.user.open_url(url) |
| OLD | NEW |