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

Side by Side Diff: scripts/slave/gclient_safe_revert.py

Issue 157073002: Bot update! (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@master
Patch Set: Remove environ Created 6 years, 10 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
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2013 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 """Do a revert if a checkout exists.""" 6 """Do a revert if a checkout exists."""
7 7
8 import os 8 import os
9 import sys 9 import sys
10 10
11 from common import chromium_utils 11 from common import chromium_utils
12 12
13 13
14 def main(): 14 def main():
15 if len(sys.argv) != 3: 15 if len(sys.argv) != 3:
16 print 'usage: gclient_safe_revert.py build_directory gclient_command' 16 print 'usage: gclient_safe_revert.py build_directory gclient_command'
17 return 2 17 return 2
18 18
19 build_directory = sys.argv[1] 19 build_directory = sys.argv[1]
20 gclient_command = sys.argv[2] 20 gclient_command = sys.argv[2]
21 21
22 if not os.path.exists(build_directory): 22 if not os.path.exists(build_directory):
23 print 'Path %s doesn\'t exist, not running gclient.' % build_directory 23 print 'Path %s doesn\'t exist, not running gclient.' % build_directory
24 return 0 24 return 0
25 25
26 if not os.path.isdir(build_directory): 26 if not os.path.isdir(build_directory):
27 print 'Path %s isn\'t a directory, not running gclient.' % build_directory 27 print 'Path %s isn\'t a directory, not running gclient.' % build_directory
28 return 0 28 return 0
29 29
30 if os.path.isfile(os.path.join(build_directory, 'update.flag')):
31 print 'update.flag file found: bot_update has run and checkout is already '
32 print 'in a consistent state. No actions will be performed in this step.'
33 return 0
34
30 gclient_config = os.path.join(build_directory, '.gclient') 35 gclient_config = os.path.join(build_directory, '.gclient')
31 if not os.path.exists(gclient_config): 36 if not os.path.exists(gclient_config):
32 print ('%s doesn\'t exist, not a gclient-controlled checkout.' % 37 print ('%s doesn\'t exist, not a gclient-controlled checkout.' %
33 gclient_config) 38 gclient_config)
34 return 0 39 return 0
35 40
36 # Work around http://crbug.com/280158 41 # Work around http://crbug.com/280158
37 cmd = [gclient_command, 'recurse', '-i', 'sh', '-c', 42 cmd = [gclient_command, 'recurse', '-i', 'sh', '-c',
38 'if [ -e .git ]; then git remote update; fi'] 43 'if [ -e .git ]; then git remote update; fi']
39 chromium_utils.RunCommand(cmd, cwd=build_directory) 44 chromium_utils.RunCommand(cmd, cwd=build_directory)
40 45
41 cmd = [gclient_command, 'revert', '--nohooks', '--upstream'] 46 cmd = [gclient_command, 'revert', '--nohooks', '--upstream']
42 return chromium_utils.RunCommand(cmd, cwd=build_directory) 47 return chromium_utils.RunCommand(cmd, cwd=build_directory)
43 48
44 49
45 if '__main__' == __name__: 50 if '__main__' == __name__:
46 sys.exit(main()) 51 sys.exit(main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698