Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/commands.py @ 4325:aa26759c6fb3
Merge with crew-stable.
author | Alexis S. L. Carvalho <alexis@cecm.usp.br> |
---|---|
date | Sat, 07 Apr 2007 04:45:27 -0300 |
parents | d4f0405fadac cd650cd61b06 |
children | de612b5f8d59 |
comparison
equal
deleted
inserted
replaced
4313:61ab822a9e88 | 4325:aa26759c6fb3 |
---|---|
1266 | 1266 |
1267 Given an extension name, print help for that extension, and the | 1267 Given an extension name, print help for that extension, and the |
1268 commands it provides.""" | 1268 commands it provides.""" |
1269 option_lists = [] | 1269 option_lists = [] |
1270 | 1270 |
1271 def addglobalopts(aliases): | |
1272 if ui.verbose: | |
1273 option_lists.append((_("global options:"), globalopts)) | |
1274 if name == 'shortlist': | |
1275 option_lists.append((_('use "hg help" for the full list ' | |
1276 'of commands'), ())) | |
1277 else: | |
1278 if name == 'shortlist': | |
1279 msg = _('use "hg help" for the full list of commands ' | |
1280 'or "hg -v" for details') | |
1281 elif aliases: | |
1282 msg = _('use "hg -v help%s" to show aliases and ' | |
1283 'global options') % (name and " " + name or "") | |
1284 else: | |
1285 msg = _('use "hg -v help %s" to show global options') % name | |
1286 option_lists.append((msg, ())) | |
1287 | |
1271 def helpcmd(name): | 1288 def helpcmd(name): |
1272 if with_version: | 1289 if with_version: |
1273 version_(ui) | 1290 version_(ui) |
1274 ui.write('\n') | 1291 ui.write('\n') |
1275 aliases, i = findcmd(ui, name) | 1292 aliases, i = findcmd(ui, name) |
1289 if len(aliases) > 1: | 1306 if len(aliases) > 1: |
1290 ui.write(_("\naliases: %s\n") % ', '.join(aliases[1:])) | 1307 ui.write(_("\naliases: %s\n") % ', '.join(aliases[1:])) |
1291 | 1308 |
1292 # options | 1309 # options |
1293 if i[1]: | 1310 if i[1]: |
1294 option_lists.append(("options", i[1])) | 1311 option_lists.append((_("options:\n"), i[1])) |
1312 | |
1313 addglobalopts(False) | |
1295 | 1314 |
1296 def helplist(select=None): | 1315 def helplist(select=None): |
1297 h = {} | 1316 h = {} |
1298 cmds = {} | 1317 cmds = {} |
1299 for c, e in table.items(): | 1318 for c, e in table.items(): |
1319 commands = cmds[f].replace("|",", ") | 1338 commands = cmds[f].replace("|",", ") |
1320 ui.write(" %s:\n %s\n"%(commands, h[f])) | 1339 ui.write(" %s:\n %s\n"%(commands, h[f])) |
1321 else: | 1340 else: |
1322 ui.write(' %-*s %s\n' % (m, f, h[f])) | 1341 ui.write(' %-*s %s\n' % (m, f, h[f])) |
1323 | 1342 |
1343 if not ui.quiet: | |
1344 addglobalopts(True) | |
1345 | |
1324 def helptopic(name): | 1346 def helptopic(name): |
1325 v = None | 1347 v = None |
1326 for i in help.helptable: | 1348 for i in help.helptable: |
1327 l = i.split('|') | 1349 l = i.split('|') |
1328 if name in l: | 1350 if name in l: |
1358 ct = mod.cmdtable | 1380 ct = mod.cmdtable |
1359 except AttributeError: | 1381 except AttributeError: |
1360 ui.status(_('no commands defined\n')) | 1382 ui.status(_('no commands defined\n')) |
1361 return | 1383 return |
1362 | 1384 |
1363 if ui.verbose: | 1385 ui.status(_('list of commands:\n\n')) |
1364 ui.status(_('list of commands:\n\n')) | |
1365 else: | |
1366 ui.status(_('list of commands (use "hg help -v %s" ' | |
1367 'to show aliases and global options):\n\n') % name) | |
1368 | |
1369 modcmds = dict.fromkeys([c.split('|', 1)[0] for c in ct]) | 1386 modcmds = dict.fromkeys([c.split('|', 1)[0] for c in ct]) |
1370 helplist(modcmds.has_key) | 1387 helplist(modcmds.has_key) |
1371 | 1388 |
1372 if name and name != 'shortlist': | 1389 if name and name != 'shortlist': |
1373 i = None | 1390 i = None |
1389 ui.status(_("Mercurial Distributed SCM\n")) | 1406 ui.status(_("Mercurial Distributed SCM\n")) |
1390 ui.status('\n') | 1407 ui.status('\n') |
1391 | 1408 |
1392 # list of commands | 1409 # list of commands |
1393 if name == "shortlist": | 1410 if name == "shortlist": |
1394 ui.status(_('basic commands (use "hg help" ' | 1411 ui.status(_('basic commands:\n\n')) |
1395 'for the full list or option "-v" for details):\n\n')) | 1412 else: |
1396 elif ui.verbose: | |
1397 ui.status(_('list of commands:\n\n')) | 1413 ui.status(_('list of commands:\n\n')) |
1398 else: | |
1399 ui.status(_('list of commands (use "hg help -v" ' | |
1400 'to show aliases and global options):\n\n')) | |
1401 | 1414 |
1402 helplist() | 1415 helplist() |
1403 | |
1404 # global options | |
1405 if ui.verbose: | |
1406 option_lists.append(("global options", globalopts)) | |
1407 | 1416 |
1408 # list all option lists | 1417 # list all option lists |
1409 opt_output = [] | 1418 opt_output = [] |
1410 for title, options in option_lists: | 1419 for title, options in option_lists: |
1411 opt_output.append(("\n%s:\n" % title, None)) | 1420 opt_output.append(("\n%s" % title, None)) |
1412 for shortopt, longopt, default, desc in options: | 1421 for shortopt, longopt, default, desc in options: |
1413 if "DEPRECATED" in desc and not ui.verbose: continue | 1422 if "DEPRECATED" in desc and not ui.verbose: continue |
1414 opt_output.append(("%2s%s" % (shortopt and "-%s" % shortopt, | 1423 opt_output.append(("%2s%s" % (shortopt and "-%s" % shortopt, |
1415 longopt and " --%s" % longopt), | 1424 longopt and " --%s" % longopt), |
1416 "%s%s" % (desc, | 1425 "%s%s" % (desc, |
1417 default | 1426 default |
1418 and _(" (default: %s)") % default | 1427 and _(" (default: %s)") % default |
1419 or ""))) | 1428 or ""))) |
1420 | 1429 |
1421 if opt_output: | 1430 if opt_output: |
1422 opts_len = max([len(line[0]) for line in opt_output if line[1]]) | 1431 opts_len = max([len(line[0]) for line in opt_output if line[1]] or [0]) |
1423 for first, second in opt_output: | 1432 for first, second in opt_output: |
1424 if second: | 1433 if second: |
1425 ui.write(" %-*s %s\n" % (opts_len, first, second)) | 1434 ui.write(" %-*s %s\n" % (opts_len, first, second)) |
1426 else: | 1435 else: |
1427 ui.write("%s\n" % first) | 1436 ui.write("%s\n" % first) |
1773 changes = get(rev) | 1782 changes = get(rev) |
1774 miss = 0 | 1783 miss = 0 |
1775 for k in [kw.lower() for kw in opts['keyword']]: | 1784 for k in [kw.lower() for kw in opts['keyword']]: |
1776 if not (k in changes[1].lower() or | 1785 if not (k in changes[1].lower() or |
1777 k in changes[4].lower() or | 1786 k in changes[4].lower() or |
1778 k in " ".join(changes[3][:20]).lower()): | 1787 k in " ".join(changes[3]).lower()): |
1779 miss = 1 | 1788 miss = 1 |
1780 break | 1789 break |
1781 if miss: | 1790 if miss: |
1782 continue | 1791 continue |
1783 | 1792 |
2843 _('follow changeset history, or file history across copies and renames')), | 2852 _('follow changeset history, or file history across copies and renames')), |
2844 ('', 'follow-first', None, | 2853 ('', 'follow-first', None, |
2845 _('only follow the first parent of merge changesets')), | 2854 _('only follow the first parent of merge changesets')), |
2846 ('d', 'date', '', _('show revs matching date spec')), | 2855 ('d', 'date', '', _('show revs matching date spec')), |
2847 ('C', 'copies', None, _('show copied files')), | 2856 ('C', 'copies', None, _('show copied files')), |
2848 ('k', 'keyword', [], _('search for a keyword')), | 2857 ('k', 'keyword', [], _('do case-insensitive search for a keyword')), |
2849 ('l', 'limit', '', _('limit number of changes displayed')), | 2858 ('l', 'limit', '', _('limit number of changes displayed')), |
2850 ('r', 'rev', [], _('show the specified revision or range')), | 2859 ('r', 'rev', [], _('show the specified revision or range')), |
2851 ('', 'removed', None, _('include revs where files were removed')), | 2860 ('', 'removed', None, _('include revs where files were removed')), |
2852 ('M', 'no-merges', None, _('do not show merges')), | 2861 ('M', 'no-merges', None, _('do not show merges')), |
2853 ('', 'style', '', _('display using template map file')), | 2862 ('', 'style', '', _('display using template map file')), |