Show More
@@ -221,7 +221,7 b' def help(ui, cmd=None):' | |||
|
221 | 221 | if ui.verbose: |
|
222 | 222 | ui.write('hg commands:\n\n') |
|
223 | 223 | else: |
|
224 |
ui.write('basic hg commands (use |
|
|
224 | ui.write('basic hg commands (use "hg help -v" for more):\n\n') | |
|
225 | 225 | |
|
226 | 226 | h = {} |
|
227 | 227 | for c, e in table.items(): |
@@ -392,7 +392,8 b' def copy(ui, repo, source, dest):' | |||
|
392 | 392 | """mark a file as copied or renamed for the next commit""" |
|
393 | 393 | return repo.copy(*relpath(repo, (source, dest))) |
|
394 | 394 | |
|
395 |
def debugcheck |
|
|
395 | def debugcheckstate(ui, repo): | |
|
396 | """validate the correctness of the current dirstate""" | |
|
396 | 397 | parent1, parent2 = repo.dirstate.parents() |
|
397 | 398 | repo.dirstate.read() |
|
398 | 399 | dc = repo.dirstate.map |
@@ -424,7 +425,8 b' def debugcheckdirstate(ui, repo):' | |||
|
424 | 425 | ui.warn(".hg/dirstate inconsistent with current parent's manifest\n") |
|
425 | 426 | sys.exit(1) |
|
426 | 427 | |
|
427 |
def debug |
|
|
428 | def debugstate(ui, repo): | |
|
429 | """show the contents of the current dirstate""" | |
|
428 | 430 | repo.dirstate.read() |
|
429 | 431 | dc = repo.dirstate.map |
|
430 | 432 | keys = dc.keys() |
@@ -433,6 +435,7 b' def debugdumpdirstate(ui, repo):' | |||
|
433 | 435 | ui.write("%c %s\n" % (dc[file][0], file)) |
|
434 | 436 | |
|
435 | 437 | def debugindex(ui, file): |
|
438 | """dump the contents of an index file""" | |
|
436 | 439 | r = hg.revlog(hg.opener(""), file, "") |
|
437 | 440 | ui.write(" rev offset length base linkrev" + |
|
438 | 441 | " p1 p2 nodeid\n") |
@@ -443,6 +446,7 b' def debugindex(ui, file):' | |||
|
443 | 446 | hg.hex(e[4][:5]), hg.hex(e[5][:5]), hg.hex(e[6][:5]))) |
|
444 | 447 | |
|
445 | 448 | def debugindexdot(ui, file): |
|
449 | """dump an index DAG as a .dot file""" | |
|
446 | 450 | r = hg.revlog(hg.opener(""), file, "") |
|
447 | 451 | ui.write("digraph G {\n") |
|
448 | 452 | for i in range(r.count()): |
@@ -858,7 +862,18 b' def tip(ui, repo):' | |||
|
858 | 862 | show_changeset(ui, repo, changenode=n) |
|
859 | 863 | |
|
860 | 864 | def undo(ui, repo): |
|
861 |
"""undo the last |
|
|
865 | """undo the last commit or pull | |
|
866 | ||
|
867 | Roll back the last pull or commit transaction on the | |
|
868 | repository, restoring the project to its earlier state. | |
|
869 | ||
|
870 | This command should be used with care. There is only one level of | |
|
871 | undo and there is no redo. | |
|
872 | ||
|
873 | This command is not intended for use on public repositories. Once | |
|
874 | a change is visible for pull by other users, undoing it locally is | |
|
875 | ineffective. | |
|
876 | """ | |
|
862 | 877 | repo.undo() |
|
863 | 878 | |
|
864 | 879 | def update(ui, repo, node=None, merge=False, clean=False): |
@@ -886,7 +901,7 b' def verify(ui, repo):' | |||
|
886 | 901 | table = { |
|
887 | 902 | "^add": (add, [], "hg add [files]"), |
|
888 | 903 | "addremove": (addremove, [], "hg addremove [files]"), |
|
889 | "annotate": (annotate, | |
|
904 | "^annotate": (annotate, | |
|
890 | 905 | [('r', 'revision', '', 'revision'), |
|
891 | 906 | ('u', 'user', None, 'show user'), |
|
892 | 907 | ('n', 'number', None, 'show revision number'), |
@@ -903,13 +918,13 b' table = {' | |||
|
903 | 918 | ('u', 'user', "", 'user')], |
|
904 | 919 | 'hg commit [files]'), |
|
905 | 920 | "copy": (copy, [], 'hg copy <source> <dest>'), |
|
906 |
"debugcheck |
|
|
907 |
"debug |
|
|
921 | "debugcheckstate": (debugcheckstate, [], 'debugcheckstate'), | |
|
922 | "debugstate": (debugstate, [], 'debugstate'), | |
|
908 | 923 | "debugindex": (debugindex, [], 'debugindex <file>'), |
|
909 | 924 | "debugindexdot": (debugindexdot, [], 'debugindexdot <file>'), |
|
910 | 925 | "^diff": (diff, [('r', 'rev', [], 'revision')], |
|
911 | 926 | 'hg diff [-r A] [-r B] [files]'), |
|
912 | "export": (export, [('o', 'output', "", 'output to file')], | |
|
927 | "^export": (export, [('o', 'output', "", 'output to file')], | |
|
913 | 928 | "hg export [-o file] <changeset> ..."), |
|
914 | 929 | "forget": (forget, [], "hg forget [files]"), |
|
915 | 930 | "heads": (heads, [], 'hg heads'), |
@@ -939,7 +954,7 b' table = {' | |||
|
939 | 954 | 'hg rawcommit [options] [files]'), |
|
940 | 955 | "recover": (recover, [], "hg recover"), |
|
941 | 956 | "^remove|rm": (remove, [], "hg remove [files]"), |
|
942 | "revert": (revert, | |
|
957 | "^revert": (revert, | |
|
943 | 958 | [("n", "nonrecursive", None, "don't recurse into subdirs"), |
|
944 | 959 | ("r", "rev", "", "revision")], |
|
945 | 960 | "hg revert [files|dirs]"), |
@@ -966,6 +981,16 b' table = {' | |||
|
966 | 981 | "version": (show_version, [], 'hg version'), |
|
967 | 982 | } |
|
968 | 983 | |
|
984 | globalopts = [('v', 'verbose', None, 'verbose'), | |
|
985 | ('', 'debug', None, 'debug'), | |
|
986 | ('q', 'quiet', None, 'quiet'), | |
|
987 | ('', 'profile', None, 'profile'), | |
|
988 | ('R', 'repository', "", 'repository root directory'), | |
|
989 | ('', 'traceback', None, 'print traceback on exception'), | |
|
990 | ('y', 'noninteractive', None, 'run non-interactively'), | |
|
991 | ('', 'version', None, 'output version information and exit'), | |
|
992 | ] | |
|
993 | ||
|
969 | 994 | norepo = "clone init version help debugindex debugindexdot" |
|
970 | 995 | |
|
971 | 996 | def find(cmd): |
@@ -983,80 +1008,76 b' def catchterm(*args):' | |||
|
983 | 1008 | def run(): |
|
984 | 1009 | sys.exit(dispatch(sys.argv[1:])) |
|
985 | 1010 | |
|
986 | def dispatch(args): | |
|
987 | signal.signal(signal.SIGTERM, catchterm) | |
|
1011 | class ParseError(Exception): pass | |
|
988 | 1012 | |
|
989 | def get_ui(): | |
|
990 | return ui.ui(options["verbose"], options["debug"], options["quiet"], | |
|
991 | not options["noninteractive"]) | |
|
992 | ||
|
1013 | def parse(args): | |
|
993 | 1014 | options = {} |
|
994 | opts = [('v', 'verbose', None, 'verbose'), | |
|
995 | ('', 'debug', None, 'debug'), | |
|
996 | ('q', 'quiet', None, 'quiet'), | |
|
997 | ('', 'profile', None, 'profile'), | |
|
998 | ('R', 'repository', "", 'repository root directory'), | |
|
999 | ('', 'traceback', None, 'print traceback on exception'), | |
|
1000 | ('y', 'noninteractive', None, 'run non-interactively'), | |
|
1001 | ('', 'version', None, 'output version information and exit'), | |
|
1002 | ] | |
|
1015 | cmdoptions = {} | |
|
1003 | 1016 | |
|
1004 | 1017 | try: |
|
1005 |
args = fancyopts.fancyopts(args, opts, options |
|
|
1006 | 'hg [options] <command> [options] [files]') | |
|
1018 | args = fancyopts.fancyopts(args, globalopts, options) | |
|
1007 | 1019 | except fancyopts.getopt.GetoptError, inst: |
|
1008 | u = ui.ui() | |
|
1009 | u.warn("hg: %s\n" % (inst)) | |
|
1010 | sys.exit(-1) | |
|
1020 | raise ParseError(cmd, inst) | |
|
1011 | 1021 | |
|
1012 | if not args: | |
|
1013 | cmd = "help" | |
|
1022 | if options["version"]: | |
|
1023 | return ("version", show_version, [], options, cmdoptions) | |
|
1024 | elif not args: | |
|
1025 | return ("help", help, [], options, cmdoptions) | |
|
1014 | 1026 | else: |
|
1015 | 1027 | cmd, args = args[0], args[1:] |
|
1016 | 1028 | |
|
1017 | if options["version"]: | |
|
1018 | show_version(get_ui()) | |
|
1019 | sys.exit(0) | |
|
1020 | ||
|
1021 | try: | |
|
1022 | 1029 |
|
|
1023 | except UnknownCommand: | |
|
1024 | u = get_ui() | |
|
1025 | u.warn("hg: unknown command '%s'\n" % cmd) | |
|
1026 | help(u) | |
|
1027 | sys.exit(1) | |
|
1028 | 1030 | |
|
1029 | 1031 | # combine global options into local |
|
1030 | 1032 | c = list(i[1]) |
|
1031 | 1033 | l = len(c) |
|
1032 | for o in opts: | |
|
1034 | for o in globalopts: | |
|
1033 | 1035 | c.append((o[0], o[1], options[o[1]], o[3])) |
|
1034 | 1036 | |
|
1035 | cmdoptions = {} | |
|
1036 | 1037 | try: |
|
1037 |
args = fancyopts.fancyopts(args, c, cmdoptions |
|
|
1038 | args = fancyopts.fancyopts(args, c, cmdoptions) | |
|
1038 | 1039 | except fancyopts.getopt.GetoptError, inst: |
|
1039 | u = get_ui() | |
|
1040 | u.warn("hg %s: %s\n" % (cmd, inst)) | |
|
1041 | help(u, cmd) | |
|
1042 | sys.exit(-1) | |
|
1040 | raise ParseError(cmd, inst) | |
|
1043 | 1041 | |
|
1044 | 1042 | # separate global options back out |
|
1045 | for o in opts: | |
|
1043 | for o in globalopts: | |
|
1046 | 1044 | n = o[1] |
|
1047 | 1045 | options[n] = cmdoptions[n] |
|
1048 | 1046 | del cmdoptions[n] |
|
1049 | 1047 | |
|
1050 | u = get_ui() | |
|
1048 | return (cmd, i[0], args, options, cmdoptions) | |
|
1049 | ||
|
1050 | def dispatch(args): | |
|
1051 | signal.signal(signal.SIGTERM, catchterm) | |
|
1052 | ||
|
1053 | try: | |
|
1054 | cmd, func, args, options, cmdoptions = parse(args) | |
|
1055 | except ParseError, inst: | |
|
1056 | u = ui.ui() | |
|
1057 | if inst.args[0]: | |
|
1058 | u.warn("hg %s: %s\n" % (inst.args[0], inst.args[1])) | |
|
1059 | help(u, inst.args[0]) | |
|
1060 | else: | |
|
1061 | u.warn("hg: %s\n" % inst.args[1]) | |
|
1062 | help(u) | |
|
1063 | sys.exit(-1) | |
|
1064 | except UnknownCommand, inst: | |
|
1065 | u = ui.ui() | |
|
1066 | u.warn("hg: unknown command '%s'\n" % inst.args[0]) | |
|
1067 | help(u) | |
|
1068 | sys.exit(1) | |
|
1069 | ||
|
1070 | u = ui.ui(options["verbose"], options["debug"], options["quiet"], | |
|
1071 | not options["noninteractive"]) | |
|
1051 | 1072 | |
|
1052 | 1073 | try: |
|
1053 | 1074 | try: |
|
1054 | 1075 | if cmd not in norepo.split(): |
|
1055 | 1076 | path = options["repository"] or "" |
|
1056 | 1077 | repo = hg.repository(ui=u, path=path) |
|
1057 |
d = lambda: |
|
|
1078 | d = lambda: func(u, repo, *args, **cmdoptions) | |
|
1058 | 1079 | else: |
|
1059 |
d = lambda: |
|
|
1080 | d = lambda: func(u, *args, **cmdoptions) | |
|
1060 | 1081 | |
|
1061 | 1082 | if options['profile']: |
|
1062 | 1083 | import hotshot, hotshot.stats |
@@ -1102,7 +1123,7 b' def dispatch(args):' | |||
|
1102 | 1123 | if len(tb) > 2: # no |
|
1103 | 1124 | raise |
|
1104 | 1125 | u.debug(inst, "\n") |
|
1105 |
u.warn("%s: invalid arguments\n" % |
|
|
1126 | u.warn("%s: invalid arguments\n" % cmd) | |
|
1106 | 1127 | help(u, cmd) |
|
1107 | 1128 | |
|
1108 | 1129 | sys.exit(-1) |
@@ -1,6 +1,6 b'' | |||
|
1 | 1 | import os, getopt |
|
2 | 2 | |
|
3 |
def fancyopts(args, options, state |
|
|
3 | def fancyopts(args, options, state): | |
|
4 | 4 | long=[] |
|
5 | 5 | short='' |
|
6 | 6 | map={} |
@@ -1,9 +1,9 b'' | |||
|
1 | 1 | #!/bin/sh |
|
2 | 2 | |
|
3 | set -x | |
|
4 | ||
|
3 | hg help | |
|
5 | 4 | hg -q help |
|
6 | 5 | hg add -h |
|
6 | hg add --skjdfks | |
|
7 | 7 | hg help diff |
|
8 | 8 | hg help foo |
|
9 | 9 | hg -q commands |
@@ -1,46 +1,67 b'' | |||
|
1 | + hg -q help | |
|
2 | basic hg commands (use -v for long list): | |
|
1 | basic hg commands (use "hg help -v" for more): | |
|
3 | 2 | |
|
4 | 3 | add add the specified files on the next commit |
|
4 | annotate show changeset information per file line | |
|
5 | 5 | clone make a copy of an existing repository |
|
6 | 6 | commit commit the specified files or all outstanding changes |
|
7 | 7 | diff diff working directory (or selected files) |
|
8 | export dump the header and diffs for one or more changesets | |
|
8 | 9 | init create a new repository in the current directory |
|
9 | 10 | log show the revision history of the repository or a single file |
|
10 | 11 | pull pull changes from the specified source |
|
11 | 12 | push push changes to the specified destination |
|
12 | 13 | remove remove the specified files on the next commit |
|
14 | revert revert modified files or dirs back to their unmodified states | |
|
13 | 15 | serve export the repository via HTTP |
|
14 | 16 | status show changed files in the working directory |
|
15 | 17 | update update or merge working directory |
|
16 | + hg add -h | |
|
18 | basic hg commands (use "hg help -v" for more): | |
|
19 | ||
|
20 | add add the specified files on the next commit | |
|
21 | annotate show changeset information per file line | |
|
22 | clone make a copy of an existing repository | |
|
23 | commit commit the specified files or all outstanding changes | |
|
24 | diff diff working directory (or selected files) | |
|
25 | export dump the header and diffs for one or more changesets | |
|
26 | init create a new repository in the current directory | |
|
27 | log show the revision history of the repository or a single file | |
|
28 | pull pull changes from the specified source | |
|
29 | push push changes to the specified destination | |
|
30 | remove remove the specified files on the next commit | |
|
31 | revert revert modified files or dirs back to their unmodified states | |
|
32 | serve export the repository via HTTP | |
|
33 | status show changed files in the working directory | |
|
34 | update update or merge working directory | |
|
17 | 35 | hg add: option -h not recognized |
|
18 | 36 | hg add [files] |
|
19 | 37 | |
|
20 | 38 | add the specified files on the next commit |
|
21 | + hg help diff | |
|
39 | hg add: option --skjdfks not recognized | |
|
40 | hg add [files] | |
|
41 | ||
|
42 | add the specified files on the next commit | |
|
22 | 43 | hg diff [-r A] [-r B] [files] |
|
23 | 44 | |
|
24 | 45 | -r --rev |
|
25 | 46 | revision |
|
26 | 47 | |
|
27 | 48 | diff working directory (or selected files) |
|
28 | + hg help foo | |
|
29 | 49 | hg: unknown command foo |
|
30 | + hg -q commands | |
|
31 | 50 | hg: unknown command 'commands' |
|
32 |
basic hg commands (use |
|
|
51 | basic hg commands (use "hg help -v" for more): | |
|
33 | 52 | |
|
34 | 53 | add add the specified files on the next commit |
|
54 | annotate show changeset information per file line | |
|
35 | 55 | clone make a copy of an existing repository |
|
36 | 56 | commit commit the specified files or all outstanding changes |
|
37 | 57 | diff diff working directory (or selected files) |
|
58 | export dump the header and diffs for one or more changesets | |
|
38 | 59 | init create a new repository in the current directory |
|
39 | 60 | log show the revision history of the repository or a single file |
|
40 | 61 | pull pull changes from the specified source |
|
41 | 62 | push push changes to the specified destination |
|
42 | 63 | remove remove the specified files on the next commit |
|
64 | revert revert modified files or dirs back to their unmodified states | |
|
43 | 65 | serve export the repository via HTTP |
|
44 | 66 | status show changed files in the working directory |
|
45 | 67 | update update or merge working directory |
|
46 | + exit 0 |
General Comments 0
You need to be logged in to leave comments.
Login now