99 "copy remote options to ui tree" |
99 "copy remote options to ui tree" |
100 if opts.get('ssh'): |
100 if opts.get('ssh'): |
101 ui.setconfig("ui", "ssh", opts['ssh']) |
101 ui.setconfig("ui", "ssh", opts['ssh']) |
102 if opts.get('remotecmd'): |
102 if opts.get('remotecmd'): |
103 ui.setconfig("ui", "remotecmd", opts['remotecmd']) |
103 ui.setconfig("ui", "remotecmd", opts['remotecmd']) |
104 |
|
105 def help_(ui, name=None, with_version=False): |
|
106 """show help for a command, extension, or list of commands |
|
107 |
|
108 With no arguments, print a list of commands and short help. |
|
109 |
|
110 Given a command name, print help for that command. |
|
111 |
|
112 Given an extension name, print help for that extension, and the |
|
113 commands it provides.""" |
|
114 option_lists = [] |
|
115 |
|
116 def helpcmd(name): |
|
117 if with_version: |
|
118 version_(ui) |
|
119 ui.write('\n') |
|
120 aliases, i = findcmd(ui, name) |
|
121 # synopsis |
|
122 ui.write("%s\n\n" % i[2]) |
|
123 |
|
124 # description |
|
125 doc = i[0].__doc__ |
|
126 if not doc: |
|
127 doc = _("(No help text available)") |
|
128 if ui.quiet: |
|
129 doc = doc.splitlines(0)[0] |
|
130 ui.write("%s\n" % doc.rstrip()) |
|
131 |
|
132 if not ui.quiet: |
|
133 # aliases |
|
134 if len(aliases) > 1: |
|
135 ui.write(_("\naliases: %s\n") % ', '.join(aliases[1:])) |
|
136 |
|
137 # options |
|
138 if i[1]: |
|
139 option_lists.append(("options", i[1])) |
|
140 |
|
141 def helplist(select=None): |
|
142 h = {} |
|
143 cmds = {} |
|
144 for c, e in table.items(): |
|
145 f = c.split("|", 1)[0] |
|
146 if select and not select(f): |
|
147 continue |
|
148 if name == "shortlist" and not f.startswith("^"): |
|
149 continue |
|
150 f = f.lstrip("^") |
|
151 if not ui.debugflag and f.startswith("debug"): |
|
152 continue |
|
153 doc = e[0].__doc__ |
|
154 if not doc: |
|
155 doc = _("(No help text available)") |
|
156 h[f] = doc.splitlines(0)[0].rstrip() |
|
157 cmds[f] = c.lstrip("^") |
|
158 |
|
159 fns = h.keys() |
|
160 fns.sort() |
|
161 m = max(map(len, fns)) |
|
162 for f in fns: |
|
163 if ui.verbose: |
|
164 commands = cmds[f].replace("|",", ") |
|
165 ui.write(" %s:\n %s\n"%(commands, h[f])) |
|
166 else: |
|
167 ui.write(' %-*s %s\n' % (m, f, h[f])) |
|
168 |
|
169 def helpext(name): |
|
170 try: |
|
171 mod = findext(name) |
|
172 except KeyError: |
|
173 raise UnknownCommand(name) |
|
174 |
|
175 doc = (mod.__doc__ or _('No help text available')).splitlines(0) |
|
176 ui.write(_('%s extension - %s\n') % (name.split('.')[-1], doc[0])) |
|
177 for d in doc[1:]: |
|
178 ui.write(d, '\n') |
|
179 |
|
180 ui.status('\n') |
|
181 if ui.verbose: |
|
182 ui.status(_('list of commands:\n\n')) |
|
183 else: |
|
184 ui.status(_('list of commands (use "hg help -v %s" ' |
|
185 'to show aliases and global options):\n\n') % name) |
|
186 |
|
187 modcmds = dict.fromkeys([c.split('|', 1)[0] for c in mod.cmdtable]) |
|
188 helplist(modcmds.has_key) |
|
189 |
|
190 if name and name != 'shortlist': |
|
191 try: |
|
192 helpcmd(name) |
|
193 except UnknownCommand: |
|
194 helpext(name) |
|
195 |
|
196 else: |
|
197 # program name |
|
198 if ui.verbose or with_version: |
|
199 version_(ui) |
|
200 else: |
|
201 ui.status(_("Mercurial Distributed SCM\n")) |
|
202 ui.status('\n') |
|
203 |
|
204 # list of commands |
|
205 if name == "shortlist": |
|
206 ui.status(_('basic commands (use "hg help" ' |
|
207 'for the full list or option "-v" for details):\n\n')) |
|
208 elif ui.verbose: |
|
209 ui.status(_('list of commands:\n\n')) |
|
210 else: |
|
211 ui.status(_('list of commands (use "hg help -v" ' |
|
212 'to show aliases and global options):\n\n')) |
|
213 |
|
214 helplist() |
|
215 |
|
216 # global options |
|
217 if ui.verbose: |
|
218 option_lists.append(("global options", globalopts)) |
|
219 |
|
220 # list all option lists |
|
221 opt_output = [] |
|
222 for title, options in option_lists: |
|
223 opt_output.append(("\n%s:\n" % title, None)) |
|
224 for shortopt, longopt, default, desc in options: |
|
225 if "DEPRECATED" in desc and not ui.verbose: continue |
|
226 opt_output.append(("%2s%s" % (shortopt and "-%s" % shortopt, |
|
227 longopt and " --%s" % longopt), |
|
228 "%s%s" % (desc, |
|
229 default |
|
230 and _(" (default: %s)") % default |
|
231 or ""))) |
|
232 |
|
233 if opt_output: |
|
234 opts_len = max([len(line[0]) for line in opt_output if line[1]]) |
|
235 for first, second in opt_output: |
|
236 if second: |
|
237 ui.write(" %-*s %s\n" % (opts_len, first, second)) |
|
238 else: |
|
239 ui.write("%s\n" % first) |
|
240 |
104 |
241 # Commands start here, listed alphabetically |
105 # Commands start here, listed alphabetically |
242 |
106 |
243 def add(ui, repo, *pats, **opts): |
107 def add(ui, repo, *pats, **opts): |
244 """add the specified files on the next commit |
108 """add the specified files on the next commit |
1216 else: |
1080 else: |
1217 heads = repo.heads() |
1081 heads = repo.heads() |
1218 displayer = cmdutil.show_changeset(ui, repo, opts) |
1082 displayer = cmdutil.show_changeset(ui, repo, opts) |
1219 for n in heads: |
1083 for n in heads: |
1220 displayer.show(changenode=n) |
1084 displayer.show(changenode=n) |
|
1085 |
|
1086 def help_(ui, name=None, with_version=False): |
|
1087 """show help for a command, extension, or list of commands |
|
1088 |
|
1089 With no arguments, print a list of commands and short help. |
|
1090 |
|
1091 Given a command name, print help for that command. |
|
1092 |
|
1093 Given an extension name, print help for that extension, and the |
|
1094 commands it provides.""" |
|
1095 option_lists = [] |
|
1096 |
|
1097 def helpcmd(name): |
|
1098 if with_version: |
|
1099 version_(ui) |
|
1100 ui.write('\n') |
|
1101 aliases, i = findcmd(ui, name) |
|
1102 # synopsis |
|
1103 ui.write("%s\n\n" % i[2]) |
|
1104 |
|
1105 # description |
|
1106 doc = i[0].__doc__ |
|
1107 if not doc: |
|
1108 doc = _("(No help text available)") |
|
1109 if ui.quiet: |
|
1110 doc = doc.splitlines(0)[0] |
|
1111 ui.write("%s\n" % doc.rstrip()) |
|
1112 |
|
1113 if not ui.quiet: |
|
1114 # aliases |
|
1115 if len(aliases) > 1: |
|
1116 ui.write(_("\naliases: %s\n") % ', '.join(aliases[1:])) |
|
1117 |
|
1118 # options |
|
1119 if i[1]: |
|
1120 option_lists.append(("options", i[1])) |
|
1121 |
|
1122 def helplist(select=None): |
|
1123 h = {} |
|
1124 cmds = {} |
|
1125 for c, e in table.items(): |
|
1126 f = c.split("|", 1)[0] |
|
1127 if select and not select(f): |
|
1128 continue |
|
1129 if name == "shortlist" and not f.startswith("^"): |
|
1130 continue |
|
1131 f = f.lstrip("^") |
|
1132 if not ui.debugflag and f.startswith("debug"): |
|
1133 continue |
|
1134 doc = e[0].__doc__ |
|
1135 if not doc: |
|
1136 doc = _("(No help text available)") |
|
1137 h[f] = doc.splitlines(0)[0].rstrip() |
|
1138 cmds[f] = c.lstrip("^") |
|
1139 |
|
1140 fns = h.keys() |
|
1141 fns.sort() |
|
1142 m = max(map(len, fns)) |
|
1143 for f in fns: |
|
1144 if ui.verbose: |
|
1145 commands = cmds[f].replace("|",", ") |
|
1146 ui.write(" %s:\n %s\n"%(commands, h[f])) |
|
1147 else: |
|
1148 ui.write(' %-*s %s\n' % (m, f, h[f])) |
|
1149 |
|
1150 def helpext(name): |
|
1151 try: |
|
1152 mod = findext(name) |
|
1153 except KeyError: |
|
1154 raise UnknownCommand(name) |
|
1155 |
|
1156 doc = (mod.__doc__ or _('No help text available')).splitlines(0) |
|
1157 ui.write(_('%s extension - %s\n') % (name.split('.')[-1], doc[0])) |
|
1158 for d in doc[1:]: |
|
1159 ui.write(d, '\n') |
|
1160 |
|
1161 ui.status('\n') |
|
1162 if ui.verbose: |
|
1163 ui.status(_('list of commands:\n\n')) |
|
1164 else: |
|
1165 ui.status(_('list of commands (use "hg help -v %s" ' |
|
1166 'to show aliases and global options):\n\n') % name) |
|
1167 |
|
1168 modcmds = dict.fromkeys([c.split('|', 1)[0] for c in mod.cmdtable]) |
|
1169 helplist(modcmds.has_key) |
|
1170 |
|
1171 if name and name != 'shortlist': |
|
1172 try: |
|
1173 helpcmd(name) |
|
1174 except UnknownCommand: |
|
1175 helpext(name) |
|
1176 |
|
1177 else: |
|
1178 # program name |
|
1179 if ui.verbose or with_version: |
|
1180 version_(ui) |
|
1181 else: |
|
1182 ui.status(_("Mercurial Distributed SCM\n")) |
|
1183 ui.status('\n') |
|
1184 |
|
1185 # list of commands |
|
1186 if name == "shortlist": |
|
1187 ui.status(_('basic commands (use "hg help" ' |
|
1188 'for the full list or option "-v" for details):\n\n')) |
|
1189 elif ui.verbose: |
|
1190 ui.status(_('list of commands:\n\n')) |
|
1191 else: |
|
1192 ui.status(_('list of commands (use "hg help -v" ' |
|
1193 'to show aliases and global options):\n\n')) |
|
1194 |
|
1195 helplist() |
|
1196 |
|
1197 # global options |
|
1198 if ui.verbose: |
|
1199 option_lists.append(("global options", globalopts)) |
|
1200 |
|
1201 # list all option lists |
|
1202 opt_output = [] |
|
1203 for title, options in option_lists: |
|
1204 opt_output.append(("\n%s:\n" % title, None)) |
|
1205 for shortopt, longopt, default, desc in options: |
|
1206 if "DEPRECATED" in desc and not ui.verbose: continue |
|
1207 opt_output.append(("%2s%s" % (shortopt and "-%s" % shortopt, |
|
1208 longopt and " --%s" % longopt), |
|
1209 "%s%s" % (desc, |
|
1210 default |
|
1211 and _(" (default: %s)") % default |
|
1212 or ""))) |
|
1213 |
|
1214 if opt_output: |
|
1215 opts_len = max([len(line[0]) for line in opt_output if line[1]]) |
|
1216 for first, second in opt_output: |
|
1217 if second: |
|
1218 ui.write(" %-*s %s\n" % (opts_len, first, second)) |
|
1219 else: |
|
1220 ui.write("%s\n" % first) |
1221 |
1221 |
1222 def identify(ui, repo): |
1222 def identify(ui, repo): |
1223 """print information about the working copy |
1223 """print information about the working copy |
1224 |
1224 |
1225 Print a short summary of the current state of the repo. |
1225 Print a short summary of the current state of the repo. |