Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 19 matching lines...) Expand all Loading... | |
| 30 file below. | 30 file below. |
| 31 .gclient_entries : A cache constructed by 'update' command. Format is a | 31 .gclient_entries : A cache constructed by 'update' command. Format is a |
| 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. Hooks | 40 working copy as a result of a "sync"/"update" or "revert" operation. This |
| 41 can also be run based on what files have been modified in the working copy | 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 with the "runhooks" operation. If any of these operation are run with | 43 with the "runhooks" operation. If any of these operation are run with |
| 43 --force, all known hooks will run regardless of the state of the working | 44 --force, all known hooks will run regardless of the state of the working |
| 44 copy. | 45 copy. |
| 45 | 46 |
| 46 Each item in a "hooks" list is a dict, containing these two keys: | 47 Each item in a "hooks" list is a dict, containing these two keys: |
| 47 "pattern" The associated value is a string containing a regular | 48 "pattern" The associated value is a string containing a regular |
| 48 expression. When a file whose pathname matches the expression | 49 expression. When a file whose pathname matches the expression |
| 49 is checked out, updated, or reverted, the hook's "action" will | 50 is checked out, updated, or reverted, the hook's "action" will |
| 50 run. | 51 run. |
| 51 "action" A list describing a command to run along with its arguments, if | 52 "action" A list describing a command to run along with its arguments, if |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 112 | 113 |
| 113 GENERIC_UPDATE_USAGE_TEXT = ( | 114 GENERIC_UPDATE_USAGE_TEXT = ( |
| 114 """Perform a checkout/update of the modules specified by the gclient | 115 """Perform a checkout/update of the modules specified by the gclient |
| 115 configuration; see 'help config'. Unless --revision is specified, | 116 configuration; see 'help config'. Unless --revision is specified, |
| 116 then the latest revision of the root solutions is checked out, with | 117 then the latest revision of the root solutions is checked out, with |
| 117 dependent submodule versions updated according to DEPS files. | 118 dependent submodule versions updated according to DEPS files. |
| 118 If --revision is specified, then the given revision is used in place | 119 If --revision is specified, then the given revision is used in place |
| 119 of the latest, either for a single solution or for all solutions. | 120 of the latest, either for a single solution or for all solutions. |
| 120 Unless the --force option is provided, solutions and modules whose | 121 Unless the --force option is provided, solutions and modules whose |
| 121 local revision matches the one to update (i.e., they have not changed | 122 local revision matches the one to update (i.e., they have not changed |
| 122 in the repository) are *not* modified. | 123 in the repository) are *not* modified. Unless --nohooks is provided, |
| 124 the hooks are run. | |
| 123 This a synonym for 'gclient %(alias)s' | 125 This a synonym for 'gclient %(alias)s' |
| 124 | 126 |
| 125 usage: gclient %(cmd)s [options] [--] [svn update options/args] | 127 usage: gclient %(cmd)s [options] [--] [svn update options/args] |
| 126 | 128 |
| 127 Valid options: | 129 Valid options: |
| 128 --force : force update even for unchanged modules | 130 --force : force update even for unchanged modules |
| 131 --nohooks : don't run the hooks after the update is complete | |
| 129 --revision REV : update/checkout all solutions with specified revision | 132 --revision REV : update/checkout all solutions with specified revision |
| 130 --revision SOLUTION@REV : update given solution to specified revision | 133 --revision SOLUTION@REV : update given solution to specified revision |
| 131 --deps PLATFORM(S) : sync deps for the given platform(s), or 'all' | 134 --deps PLATFORM(S) : sync deps for the given platform(s), or 'all' |
| 132 --verbose : output additional diagnostics | 135 --verbose : output additional diagnostics |
| 133 --head : update to latest revision, instead of last good revision | 136 --head : update to latest revision, instead of last good revision |
| 134 | 137 |
| 135 Examples: | 138 Examples: |
| 136 gclient %(cmd)s | 139 gclient %(cmd)s |
| 137 update files from SVN according to current configuration, | 140 update files from SVN according to current configuration, |
| 138 *for modules which have changed since last update or sync* | 141 *for modules which have changed since last update or sync* |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 198 usage: revert | 201 usage: revert |
| 199 """, | 202 """, |
| 200 "status": | 203 "status": |
| 201 """Show the status of client and dependent modules, using 'svn diff' | 204 """Show the status of client and dependent modules, using 'svn diff' |
| 202 for each module. Additional options and args may be passed to 'svn diff'. | 205 for each module. Additional options and args may be passed to 'svn diff'. |
| 203 | 206 |
| 204 usage: status [options] [--] [svn diff args/options] | 207 usage: status [options] [--] [svn diff args/options] |
| 205 | 208 |
| 206 Valid options: | 209 Valid options: |
| 207 --verbose : output additional diagnostics | 210 --verbose : output additional diagnostics |
| 211 --nohooks : don't run the hooks after the update is complete | |
| 208 """, | 212 """, |
| 209 "sync": GENERIC_UPDATE_USAGE_TEXT % {"cmd": "sync", "alias": "update"}, | 213 "sync": GENERIC_UPDATE_USAGE_TEXT % {"cmd": "sync", "alias": "update"}, |
| 210 "update": GENERIC_UPDATE_USAGE_TEXT % {"cmd": "update", "alias": "sync"}, | 214 "update": GENERIC_UPDATE_USAGE_TEXT % {"cmd": "update", "alias": "sync"}, |
| 211 "help": """Describe the usage of this program or its subcommands. | 215 "help": """Describe the usage of this program or its subcommands. |
| 212 | 216 |
| 213 usage: help [options] [subcommand] | 217 usage: help [options] [subcommand] |
| 214 | 218 |
| 215 Valid options: | 219 Valid options: |
| 216 --verbose : output additional diagnostics | 220 --verbose : output additional diagnostics |
| 217 """, | 221 """, |
| (...skipping 1013 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1231 # differently from VC failures. | 1235 # differently from VC failures. |
| 1232 SubprocessCall(command, self._root_dir, fail_status=2) | 1236 SubprocessCall(command, self._root_dir, fail_status=2) |
| 1233 | 1237 |
| 1234 def _RunHooks(self, command, file_list, is_using_git): | 1238 def _RunHooks(self, command, file_list, is_using_git): |
| 1235 """Evaluates all hooks, running actions as needed. | 1239 """Evaluates all hooks, running actions as needed. |
| 1236 """ | 1240 """ |
| 1237 # Hooks only run for these command types. | 1241 # Hooks only run for these command types. |
| 1238 if not command in ('update', 'revert', 'runhooks'): | 1242 if not command in ('update', 'revert', 'runhooks'): |
| 1239 return | 1243 return |
| 1240 | 1244 |
| 1245 # Hooks only run when --nohooks is not specified | |
| 1246 if self._options.nohooks: | |
| 1247 return | |
| 1248 | |
| 1241 # Get any hooks from the .gclient file. | 1249 # Get any hooks from the .gclient file. |
| 1242 hooks = self.GetVar("hooks", []) | 1250 hooks = self.GetVar("hooks", []) |
| 1243 # Add any hooks found in DEPS files. | 1251 # Add any hooks found in DEPS files. |
| 1244 hooks.extend(self._deps_hooks) | 1252 hooks.extend(self._deps_hooks) |
| 1245 | 1253 |
| 1246 # If "--force" was specified, run all hooks regardless of what files have | 1254 # If "--force" was specified, run all hooks regardless of what files have |
| 1247 # changed. If the user is using git, then we don't know what files have | 1255 # changed. If the user is using git, then we don't know what files have |
| 1248 # changed so we always run all hooks. | 1256 # changed so we always run all hooks. |
| 1249 if self._options.force or is_using_git: | 1257 if self._options.force or is_using_git: |
| 1250 for hook_dict in hooks: | 1258 for hook_dict in hooks: |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1713 | 1721 |
| 1714 def Main(argv): | 1722 def Main(argv): |
| 1715 """Parse command line arguments and dispatch command.""" | 1723 """Parse command line arguments and dispatch command.""" |
| 1716 | 1724 |
| 1717 option_parser = optparse.OptionParser(usage=DEFAULT_USAGE_TEXT, | 1725 option_parser = optparse.OptionParser(usage=DEFAULT_USAGE_TEXT, |
| 1718 version=__version__) | 1726 version=__version__) |
| 1719 option_parser.disable_interspersed_args() | 1727 option_parser.disable_interspersed_args() |
| 1720 option_parser.add_option("", "--force", action="store_true", default=False, | 1728 option_parser.add_option("", "--force", action="store_true", default=False, |
| 1721 help=("(update/sync only) force update even " | 1729 help=("(update/sync only) force update even " |
| 1722 "for modules which haven't changed")) | 1730 "for modules which haven't changed")) |
| 1731 option_parser.add_option("", "--nohooks", action="store_true", default=False, | |
| 1732 help=("(update/sync/revert only) prevent the hooks fr om " | |
|
Nicolas Sylvain
2009/07/20 23:03:19
80chars
| |
| 1733 "running")) | |
| 1723 option_parser.add_option("", "--revision", action="append", dest="revisions", | 1734 option_parser.add_option("", "--revision", action="append", dest="revisions", |
| 1724 metavar="REV", default=[], | 1735 metavar="REV", default=[], |
| 1725 help=("(update/sync only) sync to a specific " | 1736 help=("(update/sync only) sync to a specific " |
| 1726 "revision, can be used multiple times for " | 1737 "revision, can be used multiple times for " |
| 1727 "each solution, e.g. --revision=src@123, " | 1738 "each solution, e.g. --revision=src@123, " |
| 1728 "--revision=internal@32")) | 1739 "--revision=internal@32")) |
| 1729 option_parser.add_option("", "--deps", default=None, dest="deps_os", | 1740 option_parser.add_option("", "--deps", default=None, dest="deps_os", |
| 1730 metavar="OS_LIST", | 1741 metavar="OS_LIST", |
| 1731 help=("(update/sync only) sync deps for the " | 1742 help=("(update/sync only) sync deps for the " |
| 1732 "specified (comma-separated) platform(s); " | 1743 "specified (comma-separated) platform(s); " |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1779 | 1790 |
| 1780 if "__main__" == __name__: | 1791 if "__main__" == __name__: |
| 1781 try: | 1792 try: |
| 1782 result = Main(sys.argv) | 1793 result = Main(sys.argv) |
| 1783 except Error, e: | 1794 except Error, e: |
| 1784 print >> sys.stderr, "Error: %s" % str(e) | 1795 print >> sys.stderr, "Error: %s" % str(e) |
| 1785 result = 1 | 1796 result = 1 |
| 1786 sys.exit(result) | 1797 sys.exit(result) |
| 1787 | 1798 |
| 1788 # vim: ts=2:sw=2:tw=80:et: | 1799 # vim: ts=2:sw=2:tw=80:et: |
| OLD | NEW |