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

Side by Side Diff: gclient.py

Issue 2384001: Add --deps for all commands beside config and help. Fix help. (Closed)
Patch Set: Use more generic wording; copy-paste fail Created 10 years, 7 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 # Copyright (c) 2010 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2010 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 """A wrapper script to manage a set of client modules in different SCM. 6 """A wrapper script to manage a set of client modules in different SCM.
7 7
8 This script is intended to be used to help basic management of client 8 This script is intended to be used to help basic management of client
9 program sources residing in one or more Subversion modules and Git 9 program sources residing in one or more Subversion modules and Git
10 repositories, along with other modules it depends on, also in Subversion or Git, 10 repositories, along with other modules it depends on, also in Subversion or Git,
(...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 795
796 796
797 #### gclient commands. 797 #### gclient commands.
798 798
799 799
800 def CMDcleanup(parser, args): 800 def CMDcleanup(parser, args):
801 """Cleans up all working copies. 801 """Cleans up all working copies.
802 802
803 Mostly svn-specific. Simply runs 'svn cleanup' for each module. 803 Mostly svn-specific. Simply runs 'svn cleanup' for each module.
804 """ 804 """
805 parser.add_option("--deps", dest="deps_os", metavar="OS_LIST",
806 help="override deps for the specified (comma-separated) "
807 "platform(s); 'all' will process all deps_os "
808 "references")
805 (options, args) = parser.parse_args(args) 809 (options, args) = parser.parse_args(args)
806 client = GClient.LoadCurrentConfig(options) 810 client = GClient.LoadCurrentConfig(options)
807 if not client: 811 if not client:
808 raise gclient_utils.Error("client not configured; see 'gclient config'") 812 raise gclient_utils.Error("client not configured; see 'gclient config'")
809 if options.verbose: 813 if options.verbose:
810 # Print out the .gclient file. This is longer than if we just printed the 814 # Print out the .gclient file. This is longer than if we just printed the
811 # client dict, but more legible, and it might contain helpful comments. 815 # client dict, but more legible, and it might contain helpful comments.
812 print(client.ConfigContent()) 816 print(client.ConfigContent())
813 return client.RunOnDeps('cleanup', args) 817 return client.RunOnDeps('cleanup', args)
814 818
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 safesync_url = "" 854 safesync_url = ""
851 if len(args) > 1: 855 if len(args) > 1:
852 safesync_url = args[1] 856 safesync_url = args[1]
853 client.SetDefaultConfig(name, base_url, safesync_url) 857 client.SetDefaultConfig(name, base_url, safesync_url)
854 client.SaveConfig() 858 client.SaveConfig()
855 return 0 859 return 0
856 860
857 861
858 def CMDexport(parser, args): 862 def CMDexport(parser, args):
859 """Wrapper for svn export for all managed directories.""" 863 """Wrapper for svn export for all managed directories."""
864 parser.add_option("--deps", dest="deps_os", metavar="OS_LIST",
865 help="override deps for the specified (comma-separated) "
866 "platform(s); 'all' will process all deps_os "
867 "references")
860 (options, args) = parser.parse_args(args) 868 (options, args) = parser.parse_args(args)
861 if len(args) != 1: 869 if len(args) != 1:
862 raise gclient_utils.Error("Need directory name") 870 raise gclient_utils.Error("Need directory name")
863 client = GClient.LoadCurrentConfig(options) 871 client = GClient.LoadCurrentConfig(options)
864 872
865 if not client: 873 if not client:
866 raise gclient_utils.Error("client not configured; see 'gclient config'") 874 raise gclient_utils.Error("client not configured; see 'gclient config'")
867 875
868 if options.verbose: 876 if options.verbose:
869 # Print out the .gclient file. This is longer than if we just printed the 877 # Print out the .gclient file. This is longer than if we just printed the
870 # client dict, but more legible, and it might contain helpful comments. 878 # client dict, but more legible, and it might contain helpful comments.
871 print(client.ConfigContent()) 879 print(client.ConfigContent())
872 return client.RunOnDeps('export', args) 880 return client.RunOnDeps('export', args)
873 881
874 882
875 @attr('epilog', """Example: 883 @attr('epilog', """Example:
876 gclient pack > patch.txt 884 gclient pack > patch.txt
877 generate simple patch for configured client and dependences 885 generate simple patch for configured client and dependences
878 """) 886 """)
879 def CMDpack(parser, args): 887 def CMDpack(parser, args):
880 """Generate a patch which can be applied at the root of the tree. 888 """Generate a patch which can be applied at the root of the tree.
881 889
882 Internally, runs 'svn diff'/'git diff' on each checked out module and 890 Internally, runs 'svn diff'/'git diff' on each checked out module and
883 dependencies, and performs minimal postprocessing of the output. The 891 dependencies, and performs minimal postprocessing of the output. The
884 resulting patch is printed to stdout and can be applied to a freshly 892 resulting patch is printed to stdout and can be applied to a freshly
885 checked out tree via 'patch -p0 < patchfile'. 893 checked out tree via 'patch -p0 < patchfile'.
886 """ 894 """
895 parser.add_option("--deps", dest="deps_os", metavar="OS_LIST",
896 help="override deps for the specified (comma-separated) "
897 "platform(s); 'all' will process all deps_os "
898 "references")
887 (options, args) = parser.parse_args(args) 899 (options, args) = parser.parse_args(args)
888 client = GClient.LoadCurrentConfig(options) 900 client = GClient.LoadCurrentConfig(options)
889 if not client: 901 if not client:
890 raise gclient_utils.Error("client not configured; see 'gclient config'") 902 raise gclient_utils.Error("client not configured; see 'gclient config'")
891 if options.verbose: 903 if options.verbose:
892 # Print out the .gclient file. This is longer than if we just printed the 904 # Print out the .gclient file. This is longer than if we just printed the
893 # client dict, but more legible, and it might contain helpful comments. 905 # client dict, but more legible, and it might contain helpful comments.
894 print(client.ConfigContent()) 906 print(client.ConfigContent())
895 return client.RunOnDeps('pack', args) 907 return client.RunOnDeps('pack', args)
896 908
897 909
898 def CMDstatus(parser, args): 910 def CMDstatus(parser, args):
899 """Show modification status for every dependencies.""" 911 """Show modification status for every dependencies."""
900 parser.add_option("--deps", dest="deps_os", metavar="OS_LIST", 912 parser.add_option("--deps", dest="deps_os", metavar="OS_LIST",
901 help="sync deps for the specified (comma-separated) " 913 help="override deps for the specified (comma-separated) "
902 "platform(s); 'all' will sync all platforms") 914 "platform(s); 'all' will process all deps_os "
915 "references")
903 (options, args) = parser.parse_args(args) 916 (options, args) = parser.parse_args(args)
904 client = GClient.LoadCurrentConfig(options) 917 client = GClient.LoadCurrentConfig(options)
905 if not client: 918 if not client:
906 raise gclient_utils.Error("client not configured; see 'gclient config'") 919 raise gclient_utils.Error("client not configured; see 'gclient config'")
907 if options.verbose: 920 if options.verbose:
908 # Print out the .gclient file. This is longer than if we just printed the 921 # Print out the .gclient file. This is longer than if we just printed the
909 # client dict, but more legible, and it might contain helpful comments. 922 # client dict, but more legible, and it might contain helpful comments.
910 print(client.ConfigContent()) 923 print(client.ConfigContent())
911 return client.RunOnDeps('status', args) 924 return client.RunOnDeps('status', args)
912 925
(...skipping 22 matching lines...) Expand all
935 "solution@rev/hash, e.g. -r src@123") 948 "solution@rev/hash, e.g. -r src@123")
936 parser.add_option("--head", action="store_true", 949 parser.add_option("--head", action="store_true",
937 help="skips any safesync_urls specified in " 950 help="skips any safesync_urls specified in "
938 "configured solutions and sync to head instead") 951 "configured solutions and sync to head instead")
939 parser.add_option("--delete_unversioned_trees", action="store_true", 952 parser.add_option("--delete_unversioned_trees", action="store_true",
940 help="delete any unexpected unversioned trees " 953 help="delete any unexpected unversioned trees "
941 "that are in the checkout") 954 "that are in the checkout")
942 parser.add_option("--reset", action="store_true", 955 parser.add_option("--reset", action="store_true",
943 help="resets any local changes before updating (git only)") 956 help="resets any local changes before updating (git only)")
944 parser.add_option("--deps", dest="deps_os", metavar="OS_LIST", 957 parser.add_option("--deps", dest="deps_os", metavar="OS_LIST",
945 help="sync deps for the specified (comma-separated) " 958 help="override deps for the specified (comma-separated) "
946 "platform(s); 'all' will sync all platforms") 959 "platform(s); 'all' will process all deps_os "
960 "references")
947 parser.add_option("--manually_grab_svn_rev", action="store_true", 961 parser.add_option("--manually_grab_svn_rev", action="store_true",
948 help="Skip svn up whenever possible by requesting " 962 help="Skip svn up whenever possible by requesting "
949 "actual HEAD revision from the repository") 963 "actual HEAD revision from the repository")
950 (options, args) = parser.parse_args(args) 964 (options, args) = parser.parse_args(args)
951 client = GClient.LoadCurrentConfig(options) 965 client = GClient.LoadCurrentConfig(options)
952 966
953 if not client: 967 if not client:
954 raise gclient_utils.Error("client not configured; see 'gclient config'") 968 raise gclient_utils.Error("client not configured; see 'gclient config'")
955 969
956 if not options.head: 970 if not options.head:
(...skipping 26 matching lines...) Expand all
983 print(client.ConfigContent()) 997 print(client.ConfigContent())
984 return client.RunOnDeps('update', args) 998 return client.RunOnDeps('update', args)
985 999
986 1000
987 def CMDupdate(parser, args): 1001 def CMDupdate(parser, args):
988 """Alias for the sync command. Deprecated.""" 1002 """Alias for the sync command. Deprecated."""
989 return CMDsync(parser, args) 1003 return CMDsync(parser, args)
990 1004
991 def CMDdiff(parser, args): 1005 def CMDdiff(parser, args):
992 """Displays local diff for every dependencies.""" 1006 """Displays local diff for every dependencies."""
1007 parser.add_option("--deps", dest="deps_os", metavar="OS_LIST",
1008 help="override deps for the specified (comma-separated) "
1009 "platform(s); 'all' will process all deps_os "
1010 "references")
993 (options, args) = parser.parse_args(args) 1011 (options, args) = parser.parse_args(args)
994 client = GClient.LoadCurrentConfig(options) 1012 client = GClient.LoadCurrentConfig(options)
995 if not client: 1013 if not client:
996 raise gclient_utils.Error("client not configured; see 'gclient config'") 1014 raise gclient_utils.Error("client not configured; see 'gclient config'")
997 if options.verbose: 1015 if options.verbose:
998 # Print out the .gclient file. This is longer than if we just printed the 1016 # Print out the .gclient file. This is longer than if we just printed the
999 # client dict, but more legible, and it might contain helpful comments. 1017 # client dict, but more legible, and it might contain helpful comments.
1000 print(client.ConfigContent()) 1018 print(client.ConfigContent())
1001 return client.RunOnDeps('diff', args) 1019 return client.RunOnDeps('diff', args)
1002 1020
1003 1021
1004 def CMDrevert(parser, args): 1022 def CMDrevert(parser, args):
1005 """Revert all modifications in every dependencies.""" 1023 """Revert all modifications in every dependencies."""
1006 parser.add_option("--deps", dest="deps_os", metavar="OS_LIST", 1024 parser.add_option("--deps", dest="deps_os", metavar="OS_LIST",
1007 help="sync deps for the specified (comma-separated) " 1025 help="override deps for the specified (comma-separated) "
1008 "platform(s); 'all' will sync all platforms") 1026 "platform(s); 'all' will process all deps_os "
1027 "references")
1009 parser.add_option("--nohooks", action="store_true", 1028 parser.add_option("--nohooks", action="store_true",
1010 help="don't run hooks after the revert is complete") 1029 help="don't run hooks after the revert is complete")
1011 (options, args) = parser.parse_args(args) 1030 (options, args) = parser.parse_args(args)
1012 # --force is implied. 1031 # --force is implied.
1013 options.force = True 1032 options.force = True
1014 client = GClient.LoadCurrentConfig(options) 1033 client = GClient.LoadCurrentConfig(options)
1015 if not client: 1034 if not client:
1016 raise gclient_utils.Error("client not configured; see 'gclient config'") 1035 raise gclient_utils.Error("client not configured; see 'gclient config'")
1017 return client.RunOnDeps('revert', args) 1036 return client.RunOnDeps('revert', args)
1018 1037
1019 1038
1020 def CMDrunhooks(parser, args): 1039 def CMDrunhooks(parser, args):
1021 """Runs hooks for files that have been modified in the local working copy.""" 1040 """Runs hooks for files that have been modified in the local working copy."""
1022 parser.add_option("--deps", dest="deps_os", metavar="OS_LIST", 1041 parser.add_option("--deps", dest="deps_os", metavar="OS_LIST",
1023 help="sync deps for the specified (comma-separated) " 1042 help="override deps for the specified (comma-separated) "
1024 "platform(s); 'all' will sync all platforms") 1043 "platform(s); 'all' will process all deps_os "
1044 "references")
1025 parser.add_option("--force", action="store_true", default=True, 1045 parser.add_option("--force", action="store_true", default=True,
1026 help="Deprecated. No effect.") 1046 help="Deprecated. No effect.")
1027 (options, args) = parser.parse_args(args) 1047 (options, args) = parser.parse_args(args)
1028 client = GClient.LoadCurrentConfig(options) 1048 client = GClient.LoadCurrentConfig(options)
1029 if not client: 1049 if not client:
1030 raise gclient_utils.Error("client not configured; see 'gclient config'") 1050 raise gclient_utils.Error("client not configured; see 'gclient config'")
1031 if options.verbose: 1051 if options.verbose:
1032 # Print out the .gclient file. This is longer than if we just printed the 1052 # Print out the .gclient file. This is longer than if we just printed the
1033 # client dict, but more legible, and it might contain helpful comments. 1053 # client dict, but more legible, and it might contain helpful comments.
1034 print(client.ConfigContent()) 1054 print(client.ConfigContent())
1035 options.force = True 1055 options.force = True
1036 options.nohooks = False 1056 options.nohooks = False
1037 return client.RunOnDeps('runhooks', args) 1057 return client.RunOnDeps('runhooks', args)
1038 1058
1039 1059
1040 def CMDrevinfo(parser, args): 1060 def CMDrevinfo(parser, args):
1041 """Outputs details for every dependencies.""" 1061 """Outputs details for every dependencies."""
1062 parser.add_option("--deps", dest="deps_os", metavar="OS_LIST",
1063 help="override deps for the specified (comma-separated) "
1064 "platform(s); 'all' will process all deps_os "
1065 "references")
1042 parser.add_option("--snapshot", action="store_true", 1066 parser.add_option("--snapshot", action="store_true",
1043 help="create a snapshot file of the current " 1067 help="create a snapshot file of the current "
1044 "version of all repositories") 1068 "version of all repositories")
1045 (options, args) = parser.parse_args(args) 1069 (options, args) = parser.parse_args(args)
1046 client = GClient.LoadCurrentConfig(options) 1070 client = GClient.LoadCurrentConfig(options)
1047 options.deps_os = None
1048 if not client: 1071 if not client:
1049 raise gclient_utils.Error("client not configured; see 'gclient config'") 1072 raise gclient_utils.Error("client not configured; see 'gclient config'")
1050 client.PrintRevInfo() 1073 client.PrintRevInfo()
1051 return 0 1074 return 0
1052 1075
1053 1076
1054 def Command(name): 1077 def Command(name):
1055 return getattr(sys.modules[__name__], 'CMD' + name, None) 1078 return getattr(sys.modules[__name__], 'CMD' + name, None)
1056 1079
1057 1080
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1118 1141
1119 1142
1120 if "__main__" == __name__: 1143 if "__main__" == __name__:
1121 try: 1144 try:
1122 sys.exit(Main(sys.argv[1:])) 1145 sys.exit(Main(sys.argv[1:]))
1123 except gclient_utils.Error, e: 1146 except gclient_utils.Error, e:
1124 print >> sys.stderr, "Error: %s" % str(e) 1147 print >> sys.stderr, "Error: %s" % str(e)
1125 sys.exit(1) 1148 sys.exit(1)
1126 1149
1127 # vim: ts=2:sw=2:tw=80:et: 1150 # 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