1190 |
1198 |
1191 NOTE: This command should be treated as experimental. While it |
1199 NOTE: This command should be treated as experimental. While it |
1192 should properly record copied files, this information is not yet |
1200 should properly record copied files, this information is not yet |
1193 fully used by merge, nor fully reported by log. |
1201 fully used by merge, nor fully reported by log. |
1194 """ |
1202 """ |
1195 errs, copied = docopy(ui, repo, pats, opts) |
1203 try: |
|
1204 wlock = repo.wlock(0) |
|
1205 errs, copied = docopy(ui, repo, pats, opts, wlock) |
|
1206 except lock.LockHeld, inst: |
|
1207 ui.warn(_("repository lock held by %s\n") % inst.args[0]) |
|
1208 errs = 1 |
1196 return errs |
1209 return errs |
1197 |
1210 |
1198 def debugancestor(ui, index, rev1, rev2): |
1211 def debugancestor(ui, index, rev1, rev2): |
1199 """find the ancestor revision of two revisions in a given index""" |
1212 """find the ancestor revision of two revisions in a given index""" |
1200 r = revlog.revlog(util.opener(os.getcwd()), index, "") |
1213 r = revlog.revlog(util.opener(os.getcwd(), audit=False), index, "") |
1201 a = r.ancestor(r.lookup(rev1), r.lookup(rev2)) |
1214 a = r.ancestor(r.lookup(rev1), r.lookup(rev2)) |
1202 ui.write("%d:%s\n" % (r.rev(a), hex(a))) |
1215 ui.write("%d:%s\n" % (r.rev(a), hex(a))) |
|
1216 |
|
1217 def debugcomplete(ui, cmd): |
|
1218 """returns the completion list associated with the given command""" |
|
1219 clist = findpossible(cmd).keys() |
|
1220 clist.sort() |
|
1221 ui.write("%s\n" % " ".join(clist)) |
1203 |
1222 |
1204 def debugrebuildstate(ui, repo, rev=None): |
1223 def debugrebuildstate(ui, repo, rev=None): |
1205 """rebuild the dirstate as it would look like for the given revision""" |
1224 """rebuild the dirstate as it would look like for the given revision""" |
1206 if not rev: |
1225 if not rev: |
1207 rev = repo.changelog.tip() |
1226 rev = repo.changelog.tip() |
1281 for f in repo.dirstate.copies: |
1296 for f in repo.dirstate.copies: |
1282 ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copies[f], f)) |
1297 ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copies[f], f)) |
1283 |
1298 |
1284 def debugdata(ui, file_, rev): |
1299 def debugdata(ui, file_, rev): |
1285 """dump the contents of an data file revision""" |
1300 """dump the contents of an data file revision""" |
1286 r = revlog.revlog(util.opener(os.getcwd()), file_[:-2] + ".i", file_) |
1301 r = revlog.revlog(util.opener(os.getcwd(), audit=False), |
|
1302 file_[:-2] + ".i", file_) |
1287 try: |
1303 try: |
1288 ui.write(r.revision(r.lookup(rev))) |
1304 ui.write(r.revision(r.lookup(rev))) |
1289 except KeyError: |
1305 except KeyError: |
1290 raise util.Abort(_('invalid revision identifier %s'), rev) |
1306 raise util.Abort(_('invalid revision identifier %s'), rev) |
1291 |
1307 |
1292 def debugindex(ui, file_): |
1308 def debugindex(ui, file_): |
1293 """dump the contents of an index file""" |
1309 """dump the contents of an index file""" |
1294 r = revlog.revlog(util.opener(os.getcwd()), file_, "") |
1310 r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_, "") |
1295 ui.write(" rev offset length base linkrev" + |
1311 ui.write(" rev offset length base linkrev" + |
1296 " nodeid p1 p2\n") |
1312 " nodeid p1 p2\n") |
1297 for i in range(r.count()): |
1313 for i in range(r.count()): |
1298 e = r.index[i] |
1314 e = r.index[i] |
1299 ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % ( |
1315 ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % ( |
1300 i, e[0], e[1], e[2], e[3], |
1316 i, e[0], e[1], e[2], e[3], |
1301 short(e[6]), short(e[4]), short(e[5]))) |
1317 short(e[6]), short(e[4]), short(e[5]))) |
1302 |
1318 |
1303 def debugindexdot(ui, file_): |
1319 def debugindexdot(ui, file_): |
1304 """dump an index DAG as a .dot file""" |
1320 """dump an index DAG as a .dot file""" |
1305 r = revlog.revlog(util.opener(os.getcwd()), file_, "") |
1321 r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_, "") |
1306 ui.write("digraph G {\n") |
1322 ui.write("digraph G {\n") |
1307 for i in range(r.count()): |
1323 for i in range(r.count()): |
1308 e = r.index[i] |
1324 e = r.index[i] |
1309 ui.write("\t%d -> %d\n" % (r.rev(e[4]), i)) |
1325 ui.write("\t%d -> %d\n" % (r.rev(e[4]), i)) |
1310 if e[5] != nullid: |
1326 if e[5] != nullid: |
2152 |
2166 |
2153 NOTE: This command should be treated as experimental. While it |
2167 NOTE: This command should be treated as experimental. While it |
2154 should properly record rename files, this information is not yet |
2168 should properly record rename files, this information is not yet |
2155 fully used by merge, nor fully reported by log. |
2169 fully used by merge, nor fully reported by log. |
2156 """ |
2170 """ |
2157 errs, copied = docopy(ui, repo, pats, opts) |
2171 try: |
2158 names = [] |
2172 wlock = repo.wlock(0) |
2159 for abs, rel, exact in copied: |
2173 errs, copied = docopy(ui, repo, pats, opts, wlock) |
2160 if ui.verbose or not exact: |
2174 names = [] |
2161 ui.status(_('removing %s\n') % rel) |
2175 for abs, rel, exact in copied: |
2162 names.append(abs) |
2176 if ui.verbose or not exact: |
2163 repo.remove(names, unlink=True) |
2177 ui.status(_('removing %s\n') % rel) |
|
2178 names.append(abs) |
|
2179 repo.remove(names, True, wlock) |
|
2180 except lock.LockHeld, inst: |
|
2181 ui.warn(_("repository lock held by %s\n") % inst.args[0]) |
|
2182 errs = 1 |
2164 return errs |
2183 return errs |
2165 |
2184 |
2166 def revert(ui, repo, *pats, **opts): |
2185 def revert(ui, repo, *pats, **opts): |
2167 """revert modified files or dirs back to their unmodified states |
2186 """revert modified files or dirs back to their unmodified states |
2168 |
2187 |
2169 Revert any uncommitted modifications made to the named files or |
2188 In its default mode, it reverts any uncommitted modifications made |
2170 directories. This restores the contents of the affected files to |
2189 to the named files or directories. This restores the contents of |
2171 an unmodified state. |
2190 the affected files to an unmodified state. |
|
2191 |
|
2192 Using the -r option, it reverts the given files or directories to |
|
2193 their state as of an earlier revision. This can be helpful to "roll |
|
2194 back" some or all of a change that should not have been committed. |
|
2195 |
|
2196 Revert modifies the working directory. It does not commit any |
|
2197 changes, or change the parent of the current working directory. |
2172 |
2198 |
2173 If a file has been deleted, it is recreated. If the executable |
2199 If a file has been deleted, it is recreated. If the executable |
2174 mode of a file was changed, it is reset. |
2200 mode of a file was changed, it is reset. |
2175 |
2201 |
2176 If names are given, all files matching the names are reverted. |
2202 If names are given, all files matching the names are reverted. |
2571 ('d', 'date', None, _('list the date')), |
2597 ('d', 'date', None, _('list the date')), |
2572 ('n', 'number', None, _('list the revision number (default)')), |
2598 ('n', 'number', None, _('list the revision number (default)')), |
2573 ('c', 'changeset', None, _('list the changeset')), |
2599 ('c', 'changeset', None, _('list the changeset')), |
2574 ('I', 'include', [], _('include names matching the given patterns')), |
2600 ('I', 'include', [], _('include names matching the given patterns')), |
2575 ('X', 'exclude', [], _('exclude names matching the given patterns'))], |
2601 ('X', 'exclude', [], _('exclude names matching the given patterns'))], |
2576 _('hg annotate [OPTION]... FILE...')), |
2602 _('hg annotate [-r REV] [-a] [-u] [-d] [-n] [-c] FILE...')), |
2577 "bundle": |
2603 "bundle": |
2578 (bundle, |
2604 (bundle, |
2579 [], |
2605 [], |
2580 _('hg bundle FILE DEST')), |
2606 _('hg bundle FILE DEST')), |
2581 "cat": |
2607 "cat": |
2582 (cat, |
2608 (cat, |
2583 [('I', 'include', [], _('include names matching the given patterns')), |
2609 [('o', 'output', '', _('print output to file with formatted name')), |
2584 ('X', 'exclude', [], _('exclude names matching the given patterns')), |
2610 ('r', 'rev', '', _('print the given revision')), |
2585 ('o', 'output', '', _('print output to file with formatted name')), |
2611 ('I', 'include', [], _('include names matching the given patterns')), |
2586 ('r', 'rev', '', _('print the given revision'))], |
2612 ('X', 'exclude', [], _('exclude names matching the given patterns'))], |
2587 _('hg cat [OPTION]... FILE...')), |
2613 _('hg cat [OPTION]... FILE...')), |
2588 "^clone": |
2614 "^clone": |
2589 (clone, |
2615 (clone, |
2590 [('U', 'noupdate', None, _('do not update the new working directory')), |
2616 [('U', 'noupdate', None, _('do not update the new working directory')), |
2591 ('e', 'ssh', '', _('specify ssh command to use')), |
|
2592 ('', 'pull', None, _('use pull protocol to copy metadata')), |
|
2593 ('r', 'rev', [], |
2617 ('r', 'rev', [], |
2594 _('a changeset you would like to have after cloning')), |
2618 _('a changeset you would like to have after cloning')), |
|
2619 ('', 'pull', None, _('use pull protocol to copy metadata')), |
|
2620 ('e', 'ssh', '', _('specify ssh command to use')), |
2595 ('', 'remotecmd', '', |
2621 ('', 'remotecmd', '', |
2596 _('specify hg command to run on the remote side'))], |
2622 _('specify hg command to run on the remote side'))], |
2597 _('hg clone [OPTION]... SOURCE [DEST]')), |
2623 _('hg clone [OPTION]... SOURCE [DEST]')), |
2598 "^commit|ci": |
2624 "^commit|ci": |
2599 (commit, |
2625 (commit, |
2600 [('A', 'addremove', None, _('run addremove during commit')), |
2626 [('A', 'addremove', None, _('run addremove during commit')), |
2601 ('I', 'include', [], _('include names matching the given patterns')), |
|
2602 ('X', 'exclude', [], _('exclude names matching the given patterns')), |
|
2603 ('m', 'message', '', _('use <text> as commit message')), |
2627 ('m', 'message', '', _('use <text> as commit message')), |
2604 ('l', 'logfile', '', _('read the commit message from <file>')), |
2628 ('l', 'logfile', '', _('read the commit message from <file>')), |
2605 ('d', 'date', '', _('record datecode as commit date')), |
2629 ('d', 'date', '', _('record datecode as commit date')), |
2606 ('u', 'user', '', _('record user as commiter'))], |
2630 ('u', 'user', '', _('record user as commiter')), |
|
2631 ('I', 'include', [], _('include names matching the given patterns')), |
|
2632 ('X', 'exclude', [], _('exclude names matching the given patterns'))], |
2607 _('hg commit [OPTION]... [FILE]...')), |
2633 _('hg commit [OPTION]... [FILE]...')), |
2608 "copy|cp": |
2634 "copy|cp": |
2609 (copy, |
2635 (copy, |
2610 [('I', 'include', [], _('include names matching the given patterns')), |
2636 [('A', 'after', None, _('record a copy that has already occurred')), |
2611 ('X', 'exclude', [], _('exclude names matching the given patterns')), |
|
2612 ('A', 'after', None, _('record a copy that has already occurred')), |
|
2613 ('f', 'force', None, |
2637 ('f', 'force', None, |
2614 _('forcibly copy over an existing managed file'))], |
2638 _('forcibly copy over an existing managed file')), |
|
2639 ('I', 'include', [], _('include names matching the given patterns')), |
|
2640 ('X', 'exclude', [], _('exclude names matching the given patterns'))], |
2615 _('hg copy [OPTION]... [SOURCE]... DEST')), |
2641 _('hg copy [OPTION]... [SOURCE]... DEST')), |
2616 "debugancestor": (debugancestor, [], _('debugancestor INDEX REV1 REV2')), |
2642 "debugancestor": (debugancestor, [], _('debugancestor INDEX REV1 REV2')), |
|
2643 "debugcomplete": (debugcomplete, [], _('debugcomplete CMD')), |
2617 "debugrebuildstate": |
2644 "debugrebuildstate": |
2618 (debugrebuildstate, |
2645 (debugrebuildstate, |
2619 [('r', 'rev', "", _("revision to rebuild to"))], |
2646 [('r', 'rev', '', _('revision to rebuild to'))], |
2620 _('debugrebuildstate [-r REV] [REV]')), |
2647 _('debugrebuildstate [-r REV] [REV]')), |
2621 "debugcheckstate": (debugcheckstate, [], _('debugcheckstate')), |
2648 "debugcheckstate": (debugcheckstate, [], _('debugcheckstate')), |
2622 "debugconfig": (debugconfig, [], _('debugconfig')), |
2649 "debugconfig": (debugconfig, [], _('debugconfig')), |
2623 "debugsetparents": (debugsetparents, [], _('debugsetparents REV1 [REV2]')), |
2650 "debugsetparents": (debugsetparents, [], _('debugsetparents REV1 [REV2]')), |
2624 "debugstate": (debugstate, [], _('debugstate')), |
2651 "debugstate": (debugstate, [], _('debugstate')), |
2633 _('debugwalk [OPTION]... [FILE]...')), |
2660 _('debugwalk [OPTION]... [FILE]...')), |
2634 "^diff": |
2661 "^diff": |
2635 (diff, |
2662 (diff, |
2636 [('r', 'rev', [], _('revision')), |
2663 [('r', 'rev', [], _('revision')), |
2637 ('a', 'text', None, _('treat all files as text')), |
2664 ('a', 'text', None, _('treat all files as text')), |
2638 ('I', 'include', [], _('include names matching the given patterns')), |
|
2639 ('p', 'show-function', None, |
2665 ('p', 'show-function', None, |
2640 _('show which function each change is in')), |
2666 _('show which function each change is in')), |
2641 ('w', 'ignore-all-space', None, |
2667 ('w', 'ignore-all-space', None, |
2642 _('ignore white space when comparing lines')), |
2668 _('ignore white space when comparing lines')), |
2643 ('X', 'exclude', [], |
2669 ('I', 'include', [], _('include names matching the given patterns')), |
2644 _('exclude names matching the given patterns'))], |
2670 ('X', 'exclude', [], _('exclude names matching the given patterns'))], |
2645 _('hg diff [-a] [-I] [-X] [-r REV1 [-r REV2]] [FILE]...')), |
2671 _('hg diff [-a] [-I] [-X] [-r REV1 [-r REV2]] [FILE]...')), |
2646 "^export": |
2672 "^export": |
2647 (export, |
2673 (export, |
2648 [('o', 'output', '', _('print output to file with formatted name')), |
2674 [('o', 'output', '', _('print output to file with formatted name')), |
2649 ('a', 'text', None, _('treat all files as text')), |
2675 ('a', 'text', None, _('treat all files as text')), |
2650 ('', 'switch-parent', None, _('diff against the second parent'))], |
2676 ('', 'switch-parent', None, _('diff against the second parent'))], |
2651 _('hg export [-a] [-o OUTFILE] REV...')), |
2677 _('hg export [-a] [-o OUTFILESPEC] REV...')), |
2652 "forget": |
2678 "forget": |
2653 (forget, |
2679 (forget, |
2654 [('I', 'include', [], _('include names matching the given patterns')), |
2680 [('I', 'include', [], _('include names matching the given patterns')), |
2655 ('X', 'exclude', [], _('exclude names matching the given patterns'))], |
2681 ('X', 'exclude', [], _('exclude names matching the given patterns'))], |
2656 _('hg forget [OPTION]... FILE...')), |
2682 _('hg forget [OPTION]... FILE...')), |
2657 "grep": |
2683 "grep": |
2658 (grep, |
2684 (grep, |
2659 [('0', 'print0', None, _('end fields with NUL')), |
2685 [('0', 'print0', None, _('end fields with NUL')), |
2660 ('I', 'include', [], _('include names matching the given patterns')), |
|
2661 ('X', 'exclude', [], _('exclude names matching the given patterns')), |
|
2662 ('', 'all', None, _('print all revisions that match')), |
2686 ('', 'all', None, _('print all revisions that match')), |
2663 ('i', 'ignore-case', None, _('ignore case when matching')), |
2687 ('i', 'ignore-case', None, _('ignore case when matching')), |
2664 ('l', 'files-with-matches', None, |
2688 ('l', 'files-with-matches', None, |
2665 _('print only filenames and revs that match')), |
2689 _('print only filenames and revs that match')), |
2666 ('n', 'line-number', None, _('print matching line numbers')), |
2690 ('n', 'line-number', None, _('print matching line numbers')), |
2667 ('r', 'rev', [], _('search in given revision range')), |
2691 ('r', 'rev', [], _('search in given revision range')), |
2668 ('u', 'user', None, _('print user who committed change'))], |
2692 ('u', 'user', None, _('print user who committed change')), |
|
2693 ('I', 'include', [], _('include names matching the given patterns')), |
|
2694 ('X', 'exclude', [], _('exclude names matching the given patterns'))], |
2669 _('hg grep [OPTION]... PATTERN [FILE]...')), |
2695 _('hg grep [OPTION]... PATTERN [FILE]...')), |
2670 "heads": |
2696 "heads": |
2671 (heads, |
2697 (heads, |
2672 [('b', 'branches', None, _('show branches')), |
2698 [('b', 'branches', None, _('show branches')), |
2673 ('', 'style', '', _('display using template map file')), |
2699 ('', 'style', '', _('display using template map file')), |
2679 "import|patch": |
2705 "import|patch": |
2680 (import_, |
2706 (import_, |
2681 [('p', 'strip', 1, |
2707 [('p', 'strip', 1, |
2682 _('directory strip option for patch. This has the same\n') + |
2708 _('directory strip option for patch. This has the same\n') + |
2683 _('meaning as the corresponding patch option')), |
2709 _('meaning as the corresponding patch option')), |
|
2710 ('b', 'base', '', _('base path')), |
2684 ('f', 'force', None, |
2711 ('f', 'force', None, |
2685 _('skip check for outstanding uncommitted changes')), |
2712 _('skip check for outstanding uncommitted changes'))], |
2686 ('b', 'base', '', _('base path'))], |
2713 _('hg import [-p NUM] [-b BASE] [-f] PATCH...')), |
2687 _('hg import [-f] [-p NUM] [-b BASE] PATCH...')), |
|
2688 "incoming|in": (incoming, |
2714 "incoming|in": (incoming, |
2689 [('M', 'no-merges', None, _('do not show merges')), |
2715 [('M', 'no-merges', None, _('do not show merges')), |
2690 ('', 'style', '', _('display using template map file')), |
2716 ('', 'style', '', _('display using template map file')), |
2691 ('n', 'newest-first', None, _('show newest record first')), |
2717 ('n', 'newest-first', None, _('show newest record first')), |
2692 ('p', 'patch', None, _('show patch')), |
2718 ('p', 'patch', None, _('show patch')), |
2703 ('I', 'include', [], _('include names matching the given patterns')), |
2729 ('I', 'include', [], _('include names matching the given patterns')), |
2704 ('X', 'exclude', [], _('exclude names matching the given patterns'))], |
2730 ('X', 'exclude', [], _('exclude names matching the given patterns'))], |
2705 _('hg locate [OPTION]... [PATTERN]...')), |
2731 _('hg locate [OPTION]... [PATTERN]...')), |
2706 "^log|history": |
2732 "^log|history": |
2707 (log, |
2733 (log, |
2708 [('I', 'include', [], _('include names matching the given patterns')), |
2734 [('b', 'branches', None, _('show branches')), |
2709 ('X', 'exclude', [], _('exclude names matching the given patterns')), |
|
2710 ('b', 'branches', None, _('show branches')), |
|
2711 ('k', 'keyword', [], _('search for a keyword')), |
2735 ('k', 'keyword', [], _('search for a keyword')), |
2712 ('l', 'limit', '', _('limit number of changes displayed')), |
2736 ('l', 'limit', '', _('limit number of changes displayed')), |
2713 ('r', 'rev', [], _('show the specified revision or range')), |
2737 ('r', 'rev', [], _('show the specified revision or range')), |
2714 ('M', 'no-merges', None, _('do not show merges')), |
2738 ('M', 'no-merges', None, _('do not show merges')), |
2715 ('', 'style', '', _('display using template map file')), |
2739 ('', 'style', '', _('display using template map file')), |
2716 ('m', 'only-merges', None, _('show only merges')), |
2740 ('m', 'only-merges', None, _('show only merges')), |
2717 ('p', 'patch', None, _('show patch')), |
2741 ('p', 'patch', None, _('show patch')), |
2718 ('', 'template', '', _('display with template'))], |
2742 ('', 'template', '', _('display with template')), |
2719 _('hg log [-I] [-X] [-r REV]... [-p] [FILE]')), |
2743 ('I', 'include', [], _('include names matching the given patterns')), |
|
2744 ('X', 'exclude', [], _('exclude names matching the given patterns'))], |
|
2745 _('hg log [OPTION]... [FILE]')), |
2720 "manifest": (manifest, [], _('hg manifest [REV]')), |
2746 "manifest": (manifest, [], _('hg manifest [REV]')), |
2721 "outgoing|out": (outgoing, |
2747 "outgoing|out": (outgoing, |
2722 [('M', 'no-merges', None, _('do not show merges')), |
2748 [('M', 'no-merges', None, _('do not show merges')), |
2723 ('p', 'patch', None, _('show patch')), |
2749 ('p', 'patch', None, _('show patch')), |
2724 ('', 'style', '', _('display using template map file')), |
2750 ('', 'style', '', _('display using template map file')), |
2725 ('n', 'newest-first', None, _('show newest record first')), |
2751 ('n', 'newest-first', None, _('show newest record first')), |
2726 ('', 'template', '', _('display with template'))], |
2752 ('', 'template', '', _('display with template'))], |
2727 _('hg outgoing [-p] [-n] [-M] [DEST]')), |
2753 _('hg outgoing [-M] [-p] [-n] [DEST]')), |
2728 "^parents": |
2754 "^parents": |
2729 (parents, |
2755 (parents, |
2730 [('b', 'branches', None, _('show branches')), |
2756 [('b', 'branches', None, _('show branches')), |
2731 ('', 'style', '', _('display using template map file')), |
2757 ('', 'style', '', _('display using template map file')), |
2732 ('', 'template', '', _('display with template'))], |
2758 ('', 'template', '', _('display with template'))], |
2738 _('update the working directory to tip after pull')), |
2764 _('update the working directory to tip after pull')), |
2739 ('e', 'ssh', '', _('specify ssh command to use')), |
2765 ('e', 'ssh', '', _('specify ssh command to use')), |
2740 ('r', 'rev', [], _('a specific revision you would like to pull')), |
2766 ('r', 'rev', [], _('a specific revision you would like to pull')), |
2741 ('', 'remotecmd', '', |
2767 ('', 'remotecmd', '', |
2742 _('specify hg command to run on the remote side'))], |
2768 _('specify hg command to run on the remote side'))], |
2743 _('hg pull [-u] [-e FILE] [-r rev]... [--remotecmd FILE] [SOURCE]')), |
2769 _('hg pull [-u] [-e FILE] [-r REV]... [--remotecmd FILE] [SOURCE]')), |
2744 "^push": |
2770 "^push": |
2745 (push, |
2771 (push, |
2746 [('f', 'force', None, _('force push')), |
2772 [('f', 'force', None, _('force push')), |
2747 ('e', 'ssh', '', _('specify ssh command to use')), |
2773 ('e', 'ssh', '', _('specify ssh command to use')), |
2748 ('r', 'rev', [], _('a specific revision you would like to push')), |
2774 ('r', 'rev', [], _('a specific revision you would like to push')), |
2749 ('', 'remotecmd', '', |
2775 ('', 'remotecmd', '', |
2750 _('specify hg command to run on the remote side'))], |
2776 _('specify hg command to run on the remote side'))], |
2751 _('hg push [-f] [-e FILE] [-r rev]... [--remotecmd FILE] [DEST]')), |
2777 _('hg push [-f] [-e FILE] [-r REV]... [--remotecmd FILE] [DEST]')), |
2752 "rawcommit": |
2778 "debugrawcommit|rawcommit": |
2753 (rawcommit, |
2779 (rawcommit, |
2754 [('p', 'parent', [], _('parent')), |
2780 [('p', 'parent', [], _('parent')), |
2755 ('d', 'date', '', _('date code')), |
2781 ('d', 'date', '', _('date code')), |
2756 ('u', 'user', '', _('user')), |
2782 ('u', 'user', '', _('user')), |
2757 ('F', 'files', '', _('file list')), |
2783 ('F', 'files', '', _('file list')), |
2758 ('m', 'message', '', _('commit message')), |
2784 ('m', 'message', '', _('commit message')), |
2759 ('l', 'logfile', '', _('commit message file'))], |
2785 ('l', 'logfile', '', _('commit message file'))], |
2760 _('hg rawcommit [OPTION]... [FILE]...')), |
2786 _('hg debugrawcommit [OPTION]... [FILE]...')), |
2761 "recover": (recover, [], _('hg recover')), |
2787 "recover": (recover, [], _('hg recover')), |
2762 "^remove|rm": |
2788 "^remove|rm": |
2763 (remove, |
2789 (remove, |
2764 [('I', 'include', [], _('include names matching the given patterns')), |
2790 [('f', 'force', None, _('remove file even if modified')), |
|
2791 ('I', 'include', [], _('include names matching the given patterns')), |
2765 ('X', 'exclude', [], _('exclude names matching the given patterns'))], |
2792 ('X', 'exclude', [], _('exclude names matching the given patterns'))], |
2766 _('hg remove [OPTION]... FILE...')), |
2793 _('hg remove [OPTION]... FILE...')), |
2767 "rename|mv": |
2794 "rename|mv": |
2768 (rename, |
2795 (rename, |
2769 [('I', 'include', [], _('include names matching the given patterns')), |
2796 [('A', 'after', None, _('record a rename that has already occurred')), |
2770 ('X', 'exclude', [], _('exclude names matching the given patterns')), |
|
2771 ('A', 'after', None, _('record a rename that has already occurred')), |
|
2772 ('f', 'force', None, |
2797 ('f', 'force', None, |
2773 _('forcibly copy over an existing managed file'))], |
2798 _('forcibly copy over an existing managed file')), |
2774 _('hg rename [OPTION]... [SOURCE]... DEST')), |
2799 ('I', 'include', [], _('include names matching the given patterns')), |
|
2800 ('X', 'exclude', [], _('exclude names matching the given patterns'))], |
|
2801 _('hg rename [OPTION]... SOURCE... DEST')), |
2775 "^revert": |
2802 "^revert": |
2776 (revert, |
2803 (revert, |
2777 [('I', 'include', [], _('include names matching the given patterns')), |
2804 [('r', 'rev', '', _('revision to revert to')), |
2778 ('X', 'exclude', [], _('exclude names matching the given patterns')), |
2805 ('I', 'include', [], _('include names matching the given patterns')), |
2779 ('r', 'rev', '', _('revision to revert to'))], |
2806 ('X', 'exclude', [], _('exclude names matching the given patterns'))], |
2780 _('hg revert [-n] [-r REV] [NAME]...')), |
2807 _('hg revert [-r REV] [NAME]...')), |
2781 "root": (root, [], _('hg root')), |
2808 "root": (root, [], _('hg root')), |
2782 "^serve": |
2809 "^serve": |
2783 (serve, |
2810 (serve, |
2784 [('A', 'accesslog', '', _('name of access log file to write to')), |
2811 [('A', 'accesslog', '', _('name of access log file to write to')), |
2785 ('d', 'daemon', None, _('run server in background')), |
2812 ('d', 'daemon', None, _('run server in background')), |
2813 [('l', 'local', None, _('make the tag local')), |
2840 [('l', 'local', None, _('make the tag local')), |
2814 ('m', 'message', '', _('message for tag commit log entry')), |
2841 ('m', 'message', '', _('message for tag commit log entry')), |
2815 ('d', 'date', '', _('record datecode as commit date')), |
2842 ('d', 'date', '', _('record datecode as commit date')), |
2816 ('u', 'user', '', _('record user as commiter')), |
2843 ('u', 'user', '', _('record user as commiter')), |
2817 ('r', 'rev', '', _('revision to tag'))], |
2844 ('r', 'rev', '', _('revision to tag'))], |
2818 _('hg tag [-r REV] [OPTION]... NAME')), |
2845 _('hg tag [-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME')), |
2819 "tags": (tags, [], _('hg tags')), |
2846 "tags": (tags, [], _('hg tags')), |
2820 "tip": |
2847 "tip": |
2821 (tip, |
2848 (tip, |
2822 [('b', 'branches', None, _('show branches')), |
2849 [('b', 'branches', None, _('show branches')), |
2823 ('', 'style', '', _('display using template map file')), |
2850 ('', 'style', '', _('display using template map file')), |
2824 ('p', 'patch', None, _('show patch')), |
2851 ('p', 'patch', None, _('show patch')), |
2825 ('', 'template', '', _('display with template'))], |
2852 ('', 'template', '', _('display with template'))], |
2826 _('hg [-b] [-p] tip')), |
2853 _('hg tip [-b] [-p]')), |
2827 "unbundle": |
2854 "unbundle": |
2828 (unbundle, |
2855 (unbundle, |
2829 [('u', 'update', None, |
2856 [('u', 'update', None, |
2830 _('update the working directory to tip after unbundle'))], |
2857 _('update the working directory to tip after unbundle'))], |
2831 _('hg unbundle [-u] FILE')), |
2858 _('hg unbundle [-u] FILE')), |
2842 "verify": (verify, [], _('hg verify')), |
2869 "verify": (verify, [], _('hg verify')), |
2843 "version": (show_version, [], _('hg version')), |
2870 "version": (show_version, [], _('hg version')), |
2844 } |
2871 } |
2845 |
2872 |
2846 globalopts = [ |
2873 globalopts = [ |
2847 ('R', 'repository', '', _('repository root directory')), |
2874 ('R', 'repository', '', |
|
2875 _('repository root directory or symbolic path name')), |
2848 ('', 'cwd', '', _('change working directory')), |
2876 ('', 'cwd', '', _('change working directory')), |
2849 ('y', 'noninteractive', None, |
2877 ('y', 'noninteractive', None, |
2850 _('do not prompt, assume \'yes\' for any required answers')), |
2878 _('do not prompt, assume \'yes\' for any required answers')), |
2851 ('q', 'quiet', None, _('suppress output')), |
2879 ('q', 'quiet', None, _('suppress output')), |
2852 ('v', 'verbose', None, _('enable additional output')), |
2880 ('v', 'verbose', None, _('enable additional output')), |
2857 ('', 'profile', None, _('print command execution profile')), |
2885 ('', 'profile', None, _('print command execution profile')), |
2858 ('', 'version', None, _('output version information and exit')), |
2886 ('', 'version', None, _('output version information and exit')), |
2859 ('h', 'help', None, _('display help and exit')), |
2887 ('h', 'help', None, _('display help and exit')), |
2860 ] |
2888 ] |
2861 |
2889 |
2862 norepo = ("clone init version help debugancestor debugconfig debugdata" |
2890 norepo = ("clone init version help debugancestor debugcomplete debugdata" |
2863 " debugindex debugindexdot paths") |
2891 " debugindex debugindexdot") |
2864 |
2892 optionalrepo = ("paths debugconfig") |
2865 def find(cmd): |
2893 |
2866 """Return (aliases, command table entry) for command string.""" |
2894 def findpossible(cmd): |
2867 choice = None |
2895 """ |
2868 count = 0 |
2896 Return cmd -> (aliases, command table entry) |
|
2897 for each matching command |
|
2898 """ |
|
2899 choice = {} |
|
2900 debugchoice = {} |
2869 for e in table.keys(): |
2901 for e in table.keys(): |
2870 aliases = e.lstrip("^").split("|") |
2902 aliases = e.lstrip("^").split("|") |
2871 if cmd in aliases: |
2903 if cmd in aliases: |
2872 return aliases, table[e] |
2904 choice[cmd] = (aliases, table[e]) |
|
2905 continue |
2873 for a in aliases: |
2906 for a in aliases: |
2874 if a.startswith(cmd): |
2907 if a.startswith(cmd): |
2875 count += 1 |
2908 if aliases[0].startswith("debug"): |
2876 choice = aliases, table[e] |
2909 debugchoice[a] = (aliases, table[e]) |
|
2910 else: |
|
2911 choice[a] = (aliases, table[e]) |
2877 break |
2912 break |
2878 |
2913 |
2879 if count > 1: |
2914 if not choice and debugchoice: |
2880 raise AmbiguousCommand(cmd) |
2915 choice = debugchoice |
|
2916 |
|
2917 return choice |
|
2918 |
|
2919 def find(cmd): |
|
2920 """Return (aliases, command table entry) for command string.""" |
|
2921 choice = findpossible(cmd) |
|
2922 |
|
2923 if choice.has_key(cmd): |
|
2924 return choice[cmd] |
|
2925 |
|
2926 if len(choice) > 1: |
|
2927 clist = choice.keys() |
|
2928 clist.sort() |
|
2929 raise AmbiguousCommand(cmd, clist) |
2881 |
2930 |
2882 if choice: |
2931 if choice: |
2883 return choice |
2932 return choice.values()[0] |
2884 |
2933 |
2885 raise UnknownCommand(cmd) |
2934 raise UnknownCommand(cmd) |
2886 |
2935 |
2887 class SignalInterrupt(Exception): |
2936 class SignalInterrupt(Exception): |
2888 """Exception raised on SIGTERM and SIGHUP.""" |
2937 """Exception raised on SIGTERM and SIGHUP.""" |
2981 u.warn(_("module %s overrides %s\n") % (x.__name__, t)) |
3033 u.warn(_("module %s overrides %s\n") % (x.__name__, t)) |
2982 table.update(cmdtable) |
3034 table.update(cmdtable) |
2983 |
3035 |
2984 try: |
3036 try: |
2985 cmd, func, args, options, cmdoptions = parse(u, args) |
3037 cmd, func, args, options, cmdoptions = parse(u, args) |
|
3038 if options["time"]: |
|
3039 def get_times(): |
|
3040 t = os.times() |
|
3041 if t[4] == 0.0: # Windows leaves this as zero, so use time.clock() |
|
3042 t = (t[0], t[1], t[2], t[3], time.clock()) |
|
3043 return t |
|
3044 s = get_times() |
|
3045 def print_time(): |
|
3046 t = get_times() |
|
3047 u.warn(_("Time: real %.3f secs (user %.3f+%.3f sys %.3f+%.3f)\n") % |
|
3048 (t[4]-s[4], t[0]-s[0], t[2]-s[2], t[1]-s[1], t[3]-s[3])) |
|
3049 atexit.register(print_time) |
|
3050 |
|
3051 u.updateopts(options["verbose"], options["debug"], options["quiet"], |
|
3052 not options["noninteractive"]) |
|
3053 |
|
3054 # enter the debugger before command execution |
|
3055 if options['debugger']: |
|
3056 pdb.set_trace() |
|
3057 |
|
3058 try: |
|
3059 if options['cwd']: |
|
3060 try: |
|
3061 os.chdir(options['cwd']) |
|
3062 except OSError, inst: |
|
3063 raise util.Abort('%s: %s' % |
|
3064 (options['cwd'], inst.strerror)) |
|
3065 |
|
3066 path = u.expandpath(options["repository"]) or "" |
|
3067 repo = path and hg.repository(u, path=path) or None |
|
3068 |
|
3069 if options['help']: |
|
3070 help_(u, cmd, options['version']) |
|
3071 sys.exit(0) |
|
3072 elif options['version']: |
|
3073 show_version(u) |
|
3074 sys.exit(0) |
|
3075 elif not cmd: |
|
3076 help_(u, 'shortlist') |
|
3077 sys.exit(0) |
|
3078 |
|
3079 if cmd not in norepo.split(): |
|
3080 try: |
|
3081 if not repo: |
|
3082 repo = hg.repository(u, path=path) |
|
3083 u = repo.ui |
|
3084 for x in external: |
|
3085 if hasattr(x, 'reposetup'): |
|
3086 x.reposetup(u, repo) |
|
3087 except hg.RepoError: |
|
3088 if cmd not in optionalrepo.split(): |
|
3089 raise |
|
3090 d = lambda: func(u, repo, *args, **cmdoptions) |
|
3091 else: |
|
3092 d = lambda: func(u, *args, **cmdoptions) |
|
3093 |
|
3094 try: |
|
3095 if options['profile']: |
|
3096 import hotshot, hotshot.stats |
|
3097 prof = hotshot.Profile("hg.prof") |
|
3098 try: |
|
3099 try: |
|
3100 return prof.runcall(d) |
|
3101 except: |
|
3102 try: |
|
3103 u.warn(_('exception raised - generating ' |
|
3104 'profile anyway\n')) |
|
3105 except: |
|
3106 pass |
|
3107 raise |
|
3108 finally: |
|
3109 prof.close() |
|
3110 stats = hotshot.stats.load("hg.prof") |
|
3111 stats.strip_dirs() |
|
3112 stats.sort_stats('time', 'calls') |
|
3113 stats.print_stats(40) |
|
3114 else: |
|
3115 return d() |
|
3116 finally: |
|
3117 u.flush() |
|
3118 except: |
|
3119 # enter the debugger when we hit an exception |
|
3120 if options['debugger']: |
|
3121 pdb.post_mortem(sys.exc_info()[2]) |
|
3122 if options['traceback']: |
|
3123 traceback.print_exc() |
|
3124 raise |
2986 except ParseError, inst: |
3125 except ParseError, inst: |
2987 if inst.args[0]: |
3126 if inst.args[0]: |
2988 u.warn(_("hg %s: %s\n") % (inst.args[0], inst.args[1])) |
3127 u.warn(_("hg %s: %s\n") % (inst.args[0], inst.args[1])) |
2989 help_(u, inst.args[0]) |
3128 help_(u, inst.args[0]) |
2990 else: |
3129 else: |
2991 u.warn(_("hg: %s\n") % inst.args[1]) |
3130 u.warn(_("hg: %s\n") % inst.args[1]) |
2992 help_(u, 'shortlist') |
3131 help_(u, 'shortlist') |
2993 sys.exit(-1) |
3132 sys.exit(-1) |
2994 except AmbiguousCommand, inst: |
3133 except AmbiguousCommand, inst: |
2995 u.warn(_("hg: command '%s' is ambiguous.\n") % inst.args[0]) |
3134 u.warn(_("hg: command '%s' is ambiguous:\n %s\n") % |
|
3135 (inst.args[0], " ".join(inst.args[1]))) |
2996 sys.exit(1) |
3136 sys.exit(1) |
2997 except UnknownCommand, inst: |
3137 except UnknownCommand, inst: |
2998 u.warn(_("hg: unknown command '%s'\n") % inst.args[0]) |
3138 u.warn(_("hg: unknown command '%s'\n") % inst.args[0]) |
2999 help_(u, 'shortlist') |
3139 help_(u, 'shortlist') |
3000 sys.exit(1) |
3140 sys.exit(1) |
3001 |
|
3002 if options["time"]: |
|
3003 def get_times(): |
|
3004 t = os.times() |
|
3005 if t[4] == 0.0: # Windows leaves this as zero, so use time.clock() |
|
3006 t = (t[0], t[1], t[2], t[3], time.clock()) |
|
3007 return t |
|
3008 s = get_times() |
|
3009 def print_time(): |
|
3010 t = get_times() |
|
3011 u.warn(_("Time: real %.3f secs (user %.3f+%.3f sys %.3f+%.3f)\n") % |
|
3012 (t[4]-s[4], t[0]-s[0], t[2]-s[2], t[1]-s[1], t[3]-s[3])) |
|
3013 atexit.register(print_time) |
|
3014 |
|
3015 u.updateopts(options["verbose"], options["debug"], options["quiet"], |
|
3016 not options["noninteractive"]) |
|
3017 |
|
3018 # enter the debugger before command execution |
|
3019 if options['debugger']: |
|
3020 pdb.set_trace() |
|
3021 |
|
3022 try: |
|
3023 try: |
|
3024 if options['help']: |
|
3025 help_(u, cmd, options['version']) |
|
3026 sys.exit(0) |
|
3027 elif options['version']: |
|
3028 show_version(u) |
|
3029 sys.exit(0) |
|
3030 elif not cmd: |
|
3031 help_(u, 'shortlist') |
|
3032 sys.exit(0) |
|
3033 |
|
3034 if options['cwd']: |
|
3035 try: |
|
3036 os.chdir(options['cwd']) |
|
3037 except OSError, inst: |
|
3038 raise util.Abort('%s: %s' % |
|
3039 (options['cwd'], inst.strerror)) |
|
3040 |
|
3041 if cmd not in norepo.split(): |
|
3042 path = options["repository"] or "" |
|
3043 repo = hg.repository(ui=u, path=path) |
|
3044 for x in external: |
|
3045 if hasattr(x, 'reposetup'): |
|
3046 x.reposetup(u, repo) |
|
3047 d = lambda: func(u, repo, *args, **cmdoptions) |
|
3048 else: |
|
3049 d = lambda: func(u, *args, **cmdoptions) |
|
3050 |
|
3051 if options['profile']: |
|
3052 import hotshot, hotshot.stats |
|
3053 prof = hotshot.Profile("hg.prof") |
|
3054 r = prof.runcall(d) |
|
3055 prof.close() |
|
3056 stats = hotshot.stats.load("hg.prof") |
|
3057 stats.strip_dirs() |
|
3058 stats.sort_stats('time', 'calls') |
|
3059 stats.print_stats(40) |
|
3060 return r |
|
3061 else: |
|
3062 return d() |
|
3063 except: |
|
3064 # enter the debugger when we hit an exception |
|
3065 if options['debugger']: |
|
3066 pdb.post_mortem(sys.exc_info()[2]) |
|
3067 if options['traceback']: |
|
3068 traceback.print_exc() |
|
3069 raise |
|
3070 except hg.RepoError, inst: |
3141 except hg.RepoError, inst: |
3071 u.warn(_("abort: "), inst, "!\n") |
3142 u.warn(_("abort: "), inst, "!\n") |
3072 except revlog.RevlogError, inst: |
3143 except revlog.RevlogError, inst: |
3073 u.warn(_("abort: "), inst, "!\n") |
3144 u.warn(_("abort: "), inst, "!\n") |
3074 except SignalInterrupt: |
3145 except SignalInterrupt: |