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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 help_text = "Shows the pretty diff in the default browser" | 44 help_text = "Shows the pretty diff in the default browser" |
45 show_in_main_help = True | 45 show_in_main_help = True |
46 | 46 |
47 def __init__(self): | 47 def __init__(self): |
48 options = [ | 48 options = [ |
49 optparse.make_option("-g", "--git-commit", action="store", dest="git
_commit", | 49 optparse.make_option("-g", "--git-commit", action="store", dest="git
_commit", |
50 help=("Operate on a local commit. If a range, t
he commits are squashed into one. <ref>.... " | 50 help=("Operate on a local commit. If a range, t
he commits are squashed into one. <ref>.... " |
51 "includes the working copy changes. UPSTR
EAM can be used for the upstream/tracking branch.")) | 51 "includes the working copy changes. UPSTR
EAM can be used for the upstream/tracking branch.")) |
52 ] | 52 ] |
53 super(PrettyDiff, self).__init__(options) | 53 super(PrettyDiff, self).__init__(options) |
| 54 self._tool = None |
54 | 55 |
55 def execute(self, options, args, tool): | 56 def execute(self, options, args, tool): |
| 57 self._tool = tool |
56 pretty_diff_file = self._show_pretty_diff(options) | 58 pretty_diff_file = self._show_pretty_diff(options) |
57 if pretty_diff_file: | 59 if pretty_diff_file: |
58 diff_correct = tool.user.confirm("Was that diff correct?") | 60 diff_correct = tool.user.confirm("Was that diff correct?") |
59 pretty_diff_file.close() | 61 pretty_diff_file.close() |
60 if not diff_correct: | 62 if not diff_correct: |
61 sys.exit(1) | 63 sys.exit(1) |
62 | 64 |
63 def _show_pretty_diff(self, options): | 65 def _show_pretty_diff(self, options): |
64 if not self._tool.user.can_open_url(): | 66 if not self._tool.user.can_open_url(): |
65 return None | 67 return None |
(...skipping 17 matching lines...) Expand all Loading... |
83 return self._tool.scm().create_patch(options.git_commit, | 85 return self._tool.scm().create_patch(options.git_commit, |
84 changed_files=changed_files) | 86 changed_files=changed_files) |
85 | 87 |
86 def _open_pretty_diff(self, file_path): | 88 def _open_pretty_diff(self, file_path): |
87 if self._tool.platform.is_cygwin(): | 89 if self._tool.platform.is_cygwin(): |
88 assert file_path.endswith('.html') | 90 assert file_path.endswith('.html') |
89 self._tool.executive.run_command(['cygstart', file_path]) | 91 self._tool.executive.run_command(['cygstart', file_path]) |
90 return | 92 return |
91 url = "file://%s" % urllib.quote(file_path) | 93 url = "file://%s" % urllib.quote(file_path) |
92 self._tool.user.open_url(url) | 94 self._tool.user.open_url(url) |
OLD | NEW |