Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: Tools/Scripts/webkitpy/tool/steps/commit.py

Issue 27055003: Remove a bunch of unused webkitpy code from tool/, common/checkout/ and common/config/ (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 # Copyright (C) 2010 Google Inc. All rights reserved.
2 #
3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are
5 # met:
6 #
7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer
11 # in the documentation and/or other materials provided with the
12 # distribution.
13 # * Neither the name of Google Inc. nor the names of its
14 # contributors may be used to endorse or promote products derived from
15 # this software without specific prior written permission.
16 #
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
29 import logging
30 import sys
31
32 from webkitpy.common.checkout.scm import AuthenticationError, AmbiguousCommitErr or
33 from webkitpy.common.config import urls
34 from webkitpy.common.system.executive import ScriptError
35 from webkitpy.common.system.user import User
36 from webkitpy.tool.steps.abstractstep import AbstractStep
37 from webkitpy.tool.steps.options import Options
38
39 _log = logging.getLogger(__name__)
40
41
42 class Commit(AbstractStep):
43 @classmethod
44 def options(cls):
45 return AbstractStep.options() + [
46 Options.non_interactive,
47 ]
48
49 def _commit_warning(self, error):
50 return ('There are %s local commits (and possibly changes in the working directory. '
51 'Everything will be committed as a single commit. '
52 'To avoid this prompt, set "git config webkit-patch.commit-shoul d-always-squash true".' % (
53 error.num_local_commits))
54
55 def _check_test_expectations(self, changed_files):
56 test_expectations_files = [filename for filename in changed_files if fil ename.endswith('TestExpectations')]
57 if not test_expectations_files:
58 return
59
60 args = ["--diff-files"]
61 args.extend(test_expectations_files)
62 try:
63 self._tool.executive.run_and_throw_if_fail(self._tool.deprecated_por t().check_webkit_style_command() + args, cwd=self._tool.scm().checkout_root)
64 except ScriptError, e:
65 if self._options.non_interactive:
66 raise
67 if not self._tool.user.confirm("Are you sure you want to continue?", default="n"):
68 self._exit(1)
69
70 def run(self, state):
71 self._commit_message = self._tool.checkout().commit_message_for_this_com mit(self._options.git_commit).message()
72 if len(self._commit_message) < 10:
73 raise Exception("Attempted to commit with a commit message shorter t han 10 characters. Either your patch is missing a ChangeLog or webkit-patch may have a bug.")
74
75 self._check_test_expectations(self._changed_files(state))
76 self._state = state
77
78 username = None
79 password = None
80 force_squash = self._options.non_interactive
81
82 num_tries = 0
83 while num_tries < 3:
84 num_tries += 1
85
86 try:
87 scm = self._tool.scm()
88 commit_text = scm.commit_with_message(self._commit_message, git_ commit=self._options.git_commit, username=username, password=password, force_squ ash=force_squash, changed_files=self._changed_files(state))
89 svn_revision = scm.svn_revision_from_commit_text(commit_text)
90 _log.info("Committed r%s: <%s>" % (svn_revision, urls.view_revis ion_url(svn_revision)))
91 self._state["commit_text"] = commit_text
92 break;
93 except AmbiguousCommitError, e:
94 if self._tool.user.confirm(self._commit_warning(e)):
95 force_squash = True
96 else:
97 # This will correctly interrupt the rest of the commit proce ss.
98 raise ScriptError(message="Did not commit")
99 except AuthenticationError, e:
100 if self._options.non_interactive:
101 raise ScriptError(message="Authentication required")
102 username = self._tool.user.prompt("%s login: " % e.server_host, repeat=5)
103 if not username:
104 raise ScriptError("You need to specify the username on %s to perform the commit as." % e.server_host)
105 if e.prompt_for_password:
106 password = self._tool.user.prompt_password("%s password for %s: " % (e.server_host, username), repeat=5)
107 if not password:
108 raise ScriptError("You need to specify the password for %s on %s to perform the commit." % (username, e.server_host))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698