| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 | 50 |
| 51 | 51 |
| 52 _log = logging.getLogger(__name__) | 52 _log = logging.getLogger(__name__) |
| 53 | 53 |
| 54 | 54 |
| 55 # FIXME: Should TestResultWriter know how to compute this string? | 55 # FIXME: Should TestResultWriter know how to compute this string? |
| 56 def _baseline_name(fs, test_name, suffix): | 56 def _baseline_name(fs, test_name, suffix): |
| 57 return fs.splitext(test_name)[0] + TestResultWriter.FILENAME_SUFFIX_EXPECTED
+ "." + suffix | 57 return fs.splitext(test_name)[0] + TestResultWriter.FILENAME_SUFFIX_EXPECTED
+ "." + suffix |
| 58 | 58 |
| 59 | 59 |
| 60 def _get_branch_name_or_ref(tool): |
| 61 branch_name = tool.scm().current_branch() |
| 62 if not branch_name: |
| 63 # If HEAD is detached use commit SHA instead. |
| 64 return tool.executive.run_command(['git', 'rev-parse', 'HEAD']).strip() |
| 65 return branch_name |
| 66 |
| 67 |
| 60 class AbstractRebaseliningCommand(AbstractDeclarativeCommand): | 68 class AbstractRebaseliningCommand(AbstractDeclarativeCommand): |
| 61 # not overriding execute() - pylint: disable=W0223 | 69 # not overriding execute() - pylint: disable=W0223 |
| 62 | 70 |
| 63 no_optimize_option = optparse.make_option('--no-optimize', dest='optimize',
action='store_false', default=True, | 71 no_optimize_option = optparse.make_option('--no-optimize', dest='optimize',
action='store_false', default=True, |
| 64 help=('Do not optimize/de-dup the expectations after rebaselining (defau
lt is to de-dup automatically). ' | 72 help=('Do not optimize/de-dup the expectations after rebaselining (defau
lt is to de-dup automatically). ' |
| 65 'You can use "webkit-patch optimize-baselines" to optimize separat
ely.')) | 73 'You can use "webkit-patch optimize-baselines" to optimize separat
ely.')) |
| 66 | 74 |
| 67 platform_options = factory.platform_options(use_globs=True) | 75 platform_options = factory.platform_options(use_globs=True) |
| 68 | 76 |
| 69 results_directory_option = optparse.make_option("--results-directory", help=
"Local results directory to use") | 77 results_directory_option = optparse.make_option("--results-directory", help=
"Local results directory to use") |
| (...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 | 835 |
| 828 if self.tree_status() == 'closed': | 836 if self.tree_status() == 'closed': |
| 829 _log.info('Cannot proceed. Tree is closed.') | 837 _log.info('Cannot proceed. Tree is closed.') |
| 830 return | 838 return |
| 831 | 839 |
| 832 _log.info('Rebaselining %s for r%s by %s.' % (list(tests), revision, aut
hor)) | 840 _log.info('Rebaselining %s for r%s by %s.' % (list(tests), revision, aut
hor)) |
| 833 | 841 |
| 834 test_prefix_list, lines_to_remove = self.get_test_prefix_list(tests) | 842 test_prefix_list, lines_to_remove = self.get_test_prefix_list(tests) |
| 835 | 843 |
| 836 did_finish = False | 844 did_finish = False |
| 845 old_branch_name_or_ref = '' |
| 837 try: | 846 try: |
| 838 # Setup git-svn for dcommit if necessary. | 847 # Setup git-svn for dcommit if necessary. |
| 839 if tool.executive.run_command( | 848 if tool.executive.run_command( |
| 840 ['git', 'config', '--local', '--get-regexp', r'^svn-remote\.
'], | 849 ['git', 'config', '--local', '--get-regexp', r'^svn-remote\.
'], |
| 841 return_exit_code=True): | 850 return_exit_code=True): |
| 842 tool.executive.run_command(['git', 'auto-svn']) | 851 tool.executive.run_command(['git', 'auto-svn']) |
| 843 | 852 |
| 844 # Save the current branch name and checkout a clean branch for the p
atch. | 853 # Save the current branch name and checkout a clean branch for the p
atch. |
| 845 old_branch_name = tool.executive.run_command( | 854 old_branch_name_or_ref = _get_branch_name_or_ref(tool) |
| 846 ["git", "rev-parse", "--symbolic-full-name", "HEAD"]) | |
| 847 if old_branch_name == "HEAD": | |
| 848 # If HEAD is detached use commit SHA instead. | |
| 849 old_branch_name = tool.executive.run_command(["git", "rev-parse"
, "HEAD"]) | |
| 850 tool.scm().delete_branch(self.AUTO_REBASELINE_BRANCH_NAME) | 855 tool.scm().delete_branch(self.AUTO_REBASELINE_BRANCH_NAME) |
| 851 tool.scm().create_clean_branch(self.AUTO_REBASELINE_BRANCH_NAME) | 856 tool.scm().create_clean_branch(self.AUTO_REBASELINE_BRANCH_NAME) |
| 852 | 857 |
| 853 # If the tests are passing everywhere, then this list will be empty.
We don't need | 858 # If the tests are passing everywhere, then this list will be empty.
We don't need |
| 854 # to rebaseline, but we'll still need to update TestExpectations. | 859 # to rebaseline, but we'll still need to update TestExpectations. |
| 855 if test_prefix_list: | 860 if test_prefix_list: |
| 856 self._rebaseline(options, test_prefix_list) | 861 self._rebaseline(options, test_prefix_list) |
| 857 | 862 |
| 858 tool.scm().commit_locally_with_message(self.commit_message(author, r
evision, bugs)) | 863 tool.scm().commit_locally_with_message(self.commit_message(author, r
evision, bugs)) |
| 859 | 864 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 874 traceback.print_exc(file=sys.stderr) | 879 traceback.print_exc(file=sys.stderr) |
| 875 finally: | 880 finally: |
| 876 if did_finish: | 881 if did_finish: |
| 877 # Close the issue if dcommit failed. | 882 # Close the issue if dcommit failed. |
| 878 issue = tool.executive.run_command( | 883 issue = tool.executive.run_command( |
| 879 ['git', 'config', 'branch.%s.rietveldissue' % self.AUTO_REBA
SELINE_BRANCH_NAME]) | 884 ['git', 'config', 'branch.%s.rietveldissue' % self.AUTO_REBA
SELINE_BRANCH_NAME]) |
| 880 if issue.strip(): | 885 if issue.strip(): |
| 881 self._run_git_cl_command(options, ['set_close']) | 886 self._run_git_cl_command(options, ['set_close']) |
| 882 | 887 |
| 883 tool.scm().ensure_cleanly_tracking_remote_master() | 888 tool.scm().ensure_cleanly_tracking_remote_master() |
| 884 tool.scm().checkout_branch(old_branch_name) | 889 if old_branch_name_or_ref: |
| 890 tool.scm().checkout_branch(old_branch_name_or_ref) |
| 885 tool.scm().delete_branch(self.AUTO_REBASELINE_BRANCH_NAME) | 891 tool.scm().delete_branch(self.AUTO_REBASELINE_BRANCH_NAME) |
| 886 | 892 |
| 887 | 893 |
| 888 class RebaselineOMatic(AbstractDeclarativeCommand): | 894 class RebaselineOMatic(AbstractDeclarativeCommand): |
| 889 name = "rebaseline-o-matic" | 895 name = "rebaseline-o-matic" |
| 890 help_text = "Calls webkit-patch auto-rebaseline in a loop." | 896 help_text = "Calls webkit-patch auto-rebaseline in a loop." |
| 891 show_in_main_help = True | 897 show_in_main_help = True |
| 892 | 898 |
| 893 SLEEP_TIME_IN_SECONDS = 30 | 899 SLEEP_TIME_IN_SECONDS = 30 |
| 894 LOG_SERVER = 'blinkrebaseline.appspot.com' | 900 LOG_SERVER = 'blinkrebaseline.appspot.com' |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 935 | 941 |
| 936 out = self._log_line(process.stdout) | 942 out = self._log_line(process.stdout) |
| 937 while out: | 943 while out: |
| 938 # FIXME: This should probably batch up lines if they're available an
d log to the server once. | 944 # FIXME: This should probably batch up lines if they're available an
d log to the server once. |
| 939 out = self._log_line(process.stdout) | 945 out = self._log_line(process.stdout) |
| 940 | 946 |
| 941 def _do_one_rebaseline(self): | 947 def _do_one_rebaseline(self): |
| 942 self._log_queue = Queue.Queue(256) | 948 self._log_queue = Queue.Queue(256) |
| 943 log_thread = threading.Thread(name='LogToServer', target=self._log_to_se
rver_thread) | 949 log_thread = threading.Thread(name='LogToServer', target=self._log_to_se
rver_thread) |
| 944 log_thread.start() | 950 log_thread.start() |
| 951 old_branch_name_or_ref = '' |
| 945 try: | 952 try: |
| 946 old_branch_name = self._tool.scm().current_branch() | 953 old_branch_name_or_ref = _get_branch_name_or_ref(self._tool) |
| 947 self._run_logged_command(['git', 'pull']) | 954 self._run_logged_command(['git', 'pull']) |
| 948 rebaseline_command = [self._tool.filesystem.join(self._tool.scm().ch
eckout_root, 'Tools', 'Scripts', 'webkit-patch'), 'auto-rebaseline'] | 955 rebaseline_command = [self._tool.filesystem.join(self._tool.scm().ch
eckout_root, 'Tools', 'Scripts', 'webkit-patch'), 'auto-rebaseline'] |
| 949 if self._verbose: | 956 if self._verbose: |
| 950 rebaseline_command.append('--verbose') | 957 rebaseline_command.append('--verbose') |
| 951 self._run_logged_command(rebaseline_command) | 958 self._run_logged_command(rebaseline_command) |
| 952 except: | 959 except: |
| 953 self._log_queue.put(self.QUIT_LOG) | 960 self._log_queue.put(self.QUIT_LOG) |
| 954 traceback.print_exc(file=sys.stderr) | 961 traceback.print_exc(file=sys.stderr) |
| 955 # Sometimes git crashes and leaves us on a detached head. | 962 # Sometimes git crashes and leaves us on a detached head. |
| 956 self._tool.scm().checkout_branch(old_branch_name) | 963 if old_branch_name_or_ref: |
| 964 self._tool.scm().checkout_branch(old_branch_name_or_ref) |
| 957 else: | 965 else: |
| 958 self._log_queue.put(self.QUIT_LOG) | 966 self._log_queue.put(self.QUIT_LOG) |
| 959 log_thread.join() | 967 log_thread.join() |
| 960 | 968 |
| 961 def execute(self, options, args, tool): | 969 def execute(self, options, args, tool): |
| 962 self._verbose = options.verbose | 970 self._verbose = options.verbose |
| 963 while True: | 971 while True: |
| 964 self._do_one_rebaseline() | 972 self._do_one_rebaseline() |
| 965 time.sleep(self.SLEEP_TIME_IN_SECONDS) | 973 time.sleep(self.SLEEP_TIME_IN_SECONDS) |
| OLD | NEW |