12 import hg, util, revlog, bundlerepo, extensions, copies, context, error |
12 import hg, util, revlog, bundlerepo, extensions, copies, context, error |
13 import patch, help, mdiff, url, encoding |
13 import patch, help, mdiff, url, encoding |
14 import archival, changegroup, cmdutil, sshserver, hbisect |
14 import archival, changegroup, cmdutil, sshserver, hbisect |
15 from hgweb import server |
15 from hgweb import server |
16 import merge as merge_ |
16 import merge as merge_ |
|
17 import minirst |
17 |
18 |
18 # Commands start here, listed alphabetically |
19 # Commands start here, listed alphabetically |
19 |
20 |
20 def add(ui, repo, *pats, **opts): |
21 def add(ui, repo, *pats, **opts): |
21 """add the specified files on the next commit |
22 """add the specified files on the next commit |
131 '''create an unversioned archive of a repository revision |
132 '''create an unversioned archive of a repository revision |
132 |
133 |
133 By default, the revision used is the parent of the working directory; use |
134 By default, the revision used is the parent of the working directory; use |
134 -r/--rev to specify a different revision. |
135 -r/--rev to specify a different revision. |
135 |
136 |
136 To specify the type of archive to create, use -t/--type. Valid types are: |
137 To specify the type of archive to create, use -t/--type. Valid types are:: |
137 |
138 |
138 "files" (default): a directory full of files |
139 "files" (default): a directory full of files |
139 "tar": tar archive, uncompressed |
140 "tar": tar archive, uncompressed |
140 "tbz2": tar archive, compressed using bzip2 |
141 "tbz2": tar archive, compressed using bzip2 |
141 "tgz": tar archive, compressed using gzip |
142 "tgz": tar archive, compressed using gzip |
142 "uzip": zip archive, uncompressed |
143 "uzip": zip archive, uncompressed |
143 "zip": zip archive, compressed using deflate |
144 "zip": zip archive, compressed using deflate |
144 |
145 |
145 The exact name of the destination archive or directory is given using a |
146 The exact name of the destination archive or directory is given using a |
146 format string; see 'hg help export' for details. |
147 format string; see 'hg help export' for details. |
147 |
148 |
148 Each member added to an archive file has a directory prefix prepended. Use |
149 Each member added to an archive file has a directory prefix prepended. Use |
548 revision is given, the parent of the working directory is used, or tip if |
549 revision is given, the parent of the working directory is used, or tip if |
549 no revision is checked out. |
550 no revision is checked out. |
550 |
551 |
551 Output may be to a file, in which case the name of the file is given using |
552 Output may be to a file, in which case the name of the file is given using |
552 a format string. The formatting rules are the same as for the export |
553 a format string. The formatting rules are the same as for the export |
553 command, with the following additions: |
554 command, with the following additions:: |
554 |
555 |
555 %s basename of file being printed |
556 %s basename of file being printed |
556 %d dirname of file being printed, or '.' if in repository root |
557 %d dirname of file being printed, or '.' if in repository root |
557 %p root-relative path name of file being printed |
558 %p root-relative path name of file being printed |
558 """ |
559 """ |
559 ctx = repo[opts.get('rev')] |
560 ctx = repo[opts.get('rev')] |
560 err = 1 |
561 err = 1 |
561 m = cmdutil.match(repo, (file1,) + pats, opts) |
562 m = cmdutil.match(repo, (file1,) + pats, opts) |
562 for abs in ctx.walk(m): |
563 for abs in ctx.walk(m): |
598 repository data, not to the checked out files). Some filesystems, such as |
599 repository data, not to the checked out files). Some filesystems, such as |
599 AFS, implement hardlinking incorrectly, but do not report errors. In these |
600 AFS, implement hardlinking incorrectly, but do not report errors. In these |
600 cases, use the --pull option to avoid hardlinking. |
601 cases, use the --pull option to avoid hardlinking. |
601 |
602 |
602 In some cases, you can clone repositories and checked out files using full |
603 In some cases, you can clone repositories and checked out files using full |
603 hardlinks with |
604 hardlinks with :: |
604 |
605 |
605 $ cp -al REPO REPOCLONE |
606 $ cp -al REPO REPOCLONE |
606 |
607 |
607 This is the fastest way to clone, but it is not always safe. The operation |
608 This is the fastest way to clone, but it is not always safe. The operation |
608 is not atomic (making sure REPO is not modified during the operation is up |
609 is not atomic (making sure REPO is not modified during the operation is up |
1093 |
1094 |
1094 NOTE: export may generate unexpected diff output for merge changesets, as |
1095 NOTE: export may generate unexpected diff output for merge changesets, as |
1095 it will compare the merge changeset against its first parent only. |
1096 it will compare the merge changeset against its first parent only. |
1096 |
1097 |
1097 Output may be to a file, in which case the name of the file is given using |
1098 Output may be to a file, in which case the name of the file is given using |
1098 a format string. The formatting rules are as follows: |
1099 a format string. The formatting rules are as follows:: |
1099 |
1100 |
1100 %% literal "%" character |
1101 %% literal "%" character |
1101 %H changeset hash (40 bytes of hexadecimal) |
1102 %H changeset hash (40 bytes of hexadecimal) |
1102 %N number of patches being generated |
1103 %N number of patches being generated |
1103 %R changeset revision number |
1104 %R changeset revision number |
1104 %b basename of the exporting repository |
1105 %b basename of the exporting repository |
1105 %h short-form changeset hash (12 bytes of hexadecimal) |
1106 %h short-form changeset hash (12 bytes of hexadecimal) |
1106 %n zero-padded sequence number, starting at 1 |
1107 %n zero-padded sequence number, starting at 1 |
1107 %r zero-padded changeset revision number |
1108 %r zero-padded changeset revision number |
1108 |
1109 |
1109 Without the -a/--text option, export will avoid generating diffs of files |
1110 Without the -a/--text option, export will avoid generating diffs of files |
1110 it detects as binary. With -a, export will generate a diff anyway, |
1111 it detects as binary. With -a, export will generate a diff anyway, |
1111 probably with undesirable results. |
1112 probably with undesirable results. |
1112 |
1113 |
1395 With no arguments, print a list of commands with short help messages. |
1396 With no arguments, print a list of commands with short help messages. |
1396 |
1397 |
1397 Given a topic, extension, or command name, print help for that topic. |
1398 Given a topic, extension, or command name, print help for that topic. |
1398 """ |
1399 """ |
1399 option_lists = [] |
1400 option_lists = [] |
|
1401 textwidth = util.termwidth() - 2 |
1400 |
1402 |
1401 def addglobalopts(aliases): |
1403 def addglobalopts(aliases): |
1402 if ui.verbose: |
1404 if ui.verbose: |
1403 option_lists.append((_("global options:"), globalopts)) |
1405 option_lists.append((_("global options:"), globalopts)) |
1404 if name == 'shortlist': |
1406 if name == 'shortlist': |
1447 doc = gettext(i[0].__doc__) |
1449 doc = gettext(i[0].__doc__) |
1448 if not doc: |
1450 if not doc: |
1449 doc = _("(no help text available)") |
1451 doc = _("(no help text available)") |
1450 if ui.quiet: |
1452 if ui.quiet: |
1451 doc = doc.splitlines()[0] |
1453 doc = doc.splitlines()[0] |
1452 ui.write("\n%s\n" % doc.rstrip()) |
1454 ui.write("\n%s\n" % minirst.format(doc, textwidth)) |
1453 |
1455 |
1454 if not ui.quiet: |
1456 if not ui.quiet: |
1455 # options |
1457 # options |
1456 if i[1]: |
1458 if i[1]: |
1457 option_lists.append((_("options:\n"), i[1])) |
1459 option_lists.append((_("options:\n"), i[1])) |
1496 else: |
1498 else: |
1497 ui.write(' %-*s %s\n' % (m, f, util.wrap(h[f], m + 4))) |
1499 ui.write(' %-*s %s\n' % (m, f, util.wrap(h[f], m + 4))) |
1498 |
1500 |
1499 if name != 'shortlist': |
1501 if name != 'shortlist': |
1500 exts, maxlength = extensions.enabled() |
1502 exts, maxlength = extensions.enabled() |
1501 ui.write(help.listexts(_('enabled extensions:'), exts, maxlength)) |
1503 text = help.listexts(_('enabled extensions:'), exts, maxlength) |
|
1504 if text: |
|
1505 ui.write("\n%s\n" % minirst.format(text, textwidth)) |
1502 |
1506 |
1503 if not ui.quiet: |
1507 if not ui.quiet: |
1504 addglobalopts(True) |
1508 addglobalopts(True) |
1505 |
1509 |
1506 def helptopic(name): |
1510 def helptopic(name): |
1514 if not doc: |
1518 if not doc: |
1515 doc = _("(no help text available)") |
1519 doc = _("(no help text available)") |
1516 if hasattr(doc, '__call__'): |
1520 if hasattr(doc, '__call__'): |
1517 doc = doc() |
1521 doc = doc() |
1518 |
1522 |
1519 ui.write("%s\n" % header) |
1523 ui.write("%s\n\n" % header) |
1520 ui.write("%s\n" % doc.rstrip()) |
1524 ui.write("%s\n" % minirst.format(doc, textwidth)) |
1521 |
1525 |
1522 def helpext(name): |
1526 def helpext(name): |
1523 try: |
1527 try: |
1524 mod = extensions.find(name) |
1528 mod = extensions.find(name) |
1525 except KeyError: |
1529 except KeyError: |
1526 raise error.UnknownCommand(name) |
1530 raise error.UnknownCommand(name) |
1527 |
1531 |
1528 doc = gettext(mod.__doc__) or _('no help text available') |
1532 doc = gettext(mod.__doc__) or _('no help text available') |
1529 doc = doc.splitlines() |
1533 head, tail = doc.split('\n', 1) |
1530 ui.write(_('%s extension - %s\n') % (name.split('.')[-1], doc[0])) |
1534 ui.write(_('%s extension - %s\n\n') % (name.split('.')[-1], head)) |
1531 for d in doc[1:]: |
1535 if tail: |
1532 ui.write(d, '\n') |
1536 ui.write(minirst.format(tail, textwidth)) |
1533 |
1537 ui.status('\n\n') |
1534 ui.status('\n') |
|
1535 |
1538 |
1536 try: |
1539 try: |
1537 ct = mod.cmdtable |
1540 ct = mod.cmdtable |
1538 except AttributeError: |
1541 except AttributeError: |
1539 ct = {} |
1542 ct = {} |
2327 from the working directory. |
2330 from the working directory. |
2328 |
2331 |
2329 The following table details the behavior of remove for different file |
2332 The following table details the behavior of remove for different file |
2330 states (columns) and option combinations (rows). The file states are Added |
2333 states (columns) and option combinations (rows). The file states are Added |
2331 [A], Clean [C], Modified [M] and Missing [!] (as reported by hg status). |
2334 [A], Clean [C], Modified [M] and Missing [!] (as reported by hg status). |
2332 The actions are Warn, Remove (from branch) and Delete (from disk). |
2335 The actions are Warn, Remove (from branch) and Delete (from disk):: |
2333 |
2336 |
2334 A C M ! |
2337 A C M ! |
2335 none W RD W R |
2338 none W RD W R |
2336 -f R RD RD R |
2339 -f R RD RD R |
2337 -A W W W R |
2340 -A W W W R |
2338 -Af R R R R |
2341 -Af R R R R |
2339 |
2342 |
2340 This command schedules the files to be removed at the next commit. To undo |
2343 This command schedules the files to be removed at the next commit. To undo |
2341 a remove before that, see hg revert. |
2344 a remove before that, see hg revert. |
2342 """ |
2345 """ |
2343 |
2346 |
2408 |
2411 |
2409 This command also allows listing resolved files and manually indicating |
2412 This command also allows listing resolved files and manually indicating |
2410 whether or not files are resolved. All files must be marked as resolved |
2413 whether or not files are resolved. All files must be marked as resolved |
2411 before a commit is permitted. |
2414 before a commit is permitted. |
2412 |
2415 |
2413 The codes used to show the status of files are: |
2416 The codes used to show the status of files are:: |
2414 U = unresolved |
2417 |
2415 R = resolved |
2418 U = unresolved |
|
2419 R = resolved |
2416 """ |
2420 """ |
2417 |
2421 |
2418 all, mark, unmark, show = [opts.get(o) for o in 'all mark unmark list'.split()] |
2422 all, mark, unmark, show = [opts.get(o) for o in 'all mark unmark list'.split()] |
2419 |
2423 |
2420 if (show and (mark or unmark)) or (mark and unmark): |
2424 if (show and (mark or unmark)) or (mark and unmark): |
2673 since that time. This command does not alter the working directory. |
2677 since that time. This command does not alter the working directory. |
2674 |
2678 |
2675 Transactions are used to encapsulate the effects of all commands that |
2679 Transactions are used to encapsulate the effects of all commands that |
2676 create new changesets or propagate existing changesets into a repository. |
2680 create new changesets or propagate existing changesets into a repository. |
2677 For example, the following commands are transactional, and their effects |
2681 For example, the following commands are transactional, and their effects |
2678 can be rolled back: |
2682 can be rolled back:: |
2679 |
2683 |
2680 commit |
2684 commit |
2681 import |
2685 import |
2682 pull |
2686 pull |
2683 push (with this repository as destination) |
2687 push (with this repository as destination) |
2781 parent. |
2785 parent. |
2782 |
2786 |
2783 If one revision is given, it is used as the base revision. If two |
2787 If one revision is given, it is used as the base revision. If two |
2784 revisions are given, the differences between them are shown. |
2788 revisions are given, the differences between them are shown. |
2785 |
2789 |
2786 The codes used to show the status of files are: |
2790 The codes used to show the status of files are:: |
2787 M = modified |
2791 |
2788 A = added |
2792 M = modified |
2789 R = removed |
2793 A = added |
2790 C = clean |
2794 R = removed |
2791 ! = missing (deleted by non-hg command, but still tracked) |
2795 C = clean |
2792 ? = not tracked |
2796 ! = missing (deleted by non-hg command, but still tracked) |
2793 I = ignored |
2797 ? = not tracked |
2794 = origin of the previous file listed as A (added) |
2798 I = ignored |
|
2799 = origin of the previous file listed as A (added) |
2795 """ |
2800 """ |
2796 |
2801 |
2797 node1, node2 = cmdutil.revpair(repo, opts.get('rev')) |
2802 node1, node2 = cmdutil.revpair(repo, opts.get('rev')) |
2798 cwd = (pats and repo.getcwd()) or '' |
2803 cwd = (pats and repo.getcwd()) or '' |
2799 end = opts.get('print0') and '\0' or '\n' |
2804 end = opts.get('print0') and '\0' or '\n' |