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

Side by Side Diff: gclient.py

Issue 173174: Enforce --force when running gclient runhooks (Closed)
Patch Set: Update doc Created 11 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # 2 #
3 # Copyright 2008 Google Inc. All Rights Reserved. 3 # Copyright 2008 Google Inc. All Rights Reserved.
4 # 4 #
5 # Licensed under the Apache License, Version 2.0 (the "License"); 5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License. 6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at 7 # You may obtain a copy of the License at
8 # 8 #
9 # http://www.apache.org/licenses/LICENSE-2.0 9 # http://www.apache.org/licenses/LICENSE-2.0
10 # 10 #
(...skipping 21 matching lines...) Expand all
32 Python script defining 'entries', a list of the names 32 Python script defining 'entries', a list of the names
33 of all modules in the client 33 of all modules in the client
34 <module>/DEPS : Python script defining var 'deps' as a map from each requisite 34 <module>/DEPS : Python script defining var 'deps' as a map from each requisite
35 submodule name to a URL where it can be found (via one SCM) 35 submodule name to a URL where it can be found (via one SCM)
36 36
37 Hooks 37 Hooks
38 .gclient and DEPS files may optionally contain a list named "hooks" to 38 .gclient and DEPS files may optionally contain a list named "hooks" to
39 allow custom actions to be performed based on files that have changed in the 39 allow custom actions to be performed based on files that have changed in the
40 working copy as a result of a "sync"/"update" or "revert" operation. This 40 working copy as a result of a "sync"/"update" or "revert" operation. This
41 could be prevented by using --nohooks (hooks run by default). Hooks can also 41 could be prevented by using --nohooks (hooks run by default). Hooks can also
42 be run based on what files have been modified in the working copy 42 be forced to run with the "runhooks" operation. If "sync" is run with
43 with the "runhooks" operation. If any of these operation are run with
44 --force, all known hooks will run regardless of the state of the working 43 --force, all known hooks will run regardless of the state of the working
45 copy. 44 copy.
46 45
47 Each item in a "hooks" list is a dict, containing these two keys: 46 Each item in a "hooks" list is a dict, containing these two keys:
48 "pattern" The associated value is a string containing a regular 47 "pattern" The associated value is a string containing a regular
49 expression. When a file whose pathname matches the expression 48 expression. When a file whose pathname matches the expression
50 is checked out, updated, or reverted, the hook's "action" will 49 is checked out, updated, or reverted, the hook's "action" will
51 run. 50 run.
52 "action" A list describing a command to run along with its arguments, if 51 "action" A list describing a command to run along with its arguments, if
53 any. An action command will run at most one time per gclient 52 any. An action command will run at most one time per gclient
54 invocation, regardless of how many files matched the pattern. 53 invocation, regardless of how many files matched the pattern.
55 The action is executed in the same directory as the .gclient 54 The action is executed in the same directory as the .gclient
56 file. If the first item in the list is the string "python", 55 file. If the first item in the list is the string "python",
57 the current Python interpreter (sys.executable) will be used 56 the current Python interpreter (sys.executable) will be used
58 to run the command. If the list contains string "$matching_files" 57 to run the command. If the list contains string "$matching_files"
59 it will be removed from the list and the list will be extended 58 it will be removed from the list and the list will be extended
60 by the list of matching files. 59 by the list of matching files.
61 60
62 Example: 61 Example:
63 hooks = [ 62 hooks = [
64 { "pattern": "\\.(gif|jpe?g|pr0n|png)$", 63 { "pattern": "\\.(gif|jpe?g|pr0n|png)$",
65 "action": ["python", "image_indexer.py", "--all"]}, 64 "action": ["python", "image_indexer.py", "--all"]},
66 ] 65 ]
67 """ 66 """
68 67
69 __author__ = "darinf@gmail.com (Darin Fisher)" 68 __author__ = "darinf@gmail.com (Darin Fisher)"
70 __version__ = "0.3.2" 69 __version__ = "0.3.3"
71 70
72 import errno 71 import errno
73 import optparse 72 import optparse
74 import os 73 import os
75 import re 74 import re
76 import stat 75 import stat
77 import subprocess 76 import subprocess
78 import sys 77 import sys
79 import time 78 import time
80 import urlparse 79 import urlparse
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 "update": GENERIC_UPDATE_USAGE_TEXT % {"cmd": "update", "alias": "sync"}, 215 "update": GENERIC_UPDATE_USAGE_TEXT % {"cmd": "update", "alias": "sync"},
217 "help": """Describe the usage of this program or its subcommands. 216 "help": """Describe the usage of this program or its subcommands.
218 217
219 usage: help [options] [subcommand] 218 usage: help [options] [subcommand]
220 219
221 Valid options: 220 Valid options:
222 --verbose : output additional diagnostics 221 --verbose : output additional diagnostics
223 """, 222 """,
224 "runhooks": 223 "runhooks":
225 """Runs hooks for files that have been modified in the local working copy, 224 """Runs hooks for files that have been modified in the local working copy,
226 according to 'svn status'. 225 according to 'svn status'. Implies --force.
227 226
228 usage: runhooks [options] 227 usage: runhooks [options]
229 228
230 Valid options: 229 Valid options:
231 --force : runs all known hooks, regardless of the working
232 copy status
233 --verbose : output additional diagnostics 230 --verbose : output additional diagnostics
234 """, 231 """,
235 "revinfo": 232 "revinfo":
236 """Outputs source path, server URL and revision information for every 233 """Outputs source path, server URL and revision information for every
237 dependency in all solutions (no local checkout required). 234 dependency in all solutions (no local checkout required).
238 235
239 usage: revinfo [options] 236 usage: revinfo [options]
240 """, 237 """,
241 } 238 }
242 239
(...skipping 1449 matching lines...) Expand 10 before | Expand all | Expand 10 after
1692 Raises: 1689 Raises:
1693 Error: if client isn't configured properly. 1690 Error: if client isn't configured properly.
1694 """ 1691 """
1695 client = GClient.LoadCurrentConfig(options) 1692 client = GClient.LoadCurrentConfig(options)
1696 if not client: 1693 if not client:
1697 raise Error("client not configured; see 'gclient config'") 1694 raise Error("client not configured; see 'gclient config'")
1698 if options.verbose: 1695 if options.verbose:
1699 # Print out the .gclient file. This is longer than if we just printed the 1696 # Print out the .gclient file. This is longer than if we just printed the
1700 # client dict, but more legible, and it might contain helpful comments. 1697 # client dict, but more legible, and it might contain helpful comments.
1701 print(client.ConfigContent()) 1698 print(client.ConfigContent())
1699 options.force = True
1702 return client.RunOnDeps('runhooks', args) 1700 return client.RunOnDeps('runhooks', args)
1703 1701
1704 1702
1705 def DoRevInfo(options, args): 1703 def DoRevInfo(options, args):
1706 """Handle the revinfo subcommand. 1704 """Handle the revinfo subcommand.
1707 1705
1708 Raises: 1706 Raises:
1709 Error: if client isn't configured properly. 1707 Error: if client isn't configured properly.
1710 """ 1708 """
1711 client = GClient.LoadCurrentConfig(options) 1709 client = GClient.LoadCurrentConfig(options)
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1811 1809
1812 if "__main__" == __name__: 1810 if "__main__" == __name__:
1813 try: 1811 try:
1814 result = Main(sys.argv) 1812 result = Main(sys.argv)
1815 except Error, e: 1813 except Error, e:
1816 print >> sys.stderr, "Error: %s" % str(e) 1814 print >> sys.stderr, "Error: %s" % str(e)
1817 result = 1 1815 result = 1
1818 sys.exit(result) 1816 sys.exit(result)
1819 1817
1820 # vim: ts=2:sw=2:tw=80:et: 1818 # vim: ts=2:sw=2:tw=80:et:
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698