# HG changeset patch # User Matt Mackall # Date 1165356373 21600 # Node ID 17a11f4ff26037a4aaf3e4c529a3e8c3ebf0a570 # Parent 630caaf2981584d01eda969d97d8431f44545f4f Add basic support for help topics and a dates topic diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -10,7 +10,7 @@ from node import * from i18n import gettext as _ demandload(globals(), "bisect os re sys signal imp urllib pdb shlex stat") demandload(globals(), "fancyopts ui hg util lock revlog bundlerepo") -demandload(globals(), "difflib patch time") +demandload(globals(), "difflib patch time help") demandload(globals(), "traceback errno version atexit") demandload(globals(), "archival changegroup cmdutil hgweb.server sshserver") @@ -1141,6 +1141,24 @@ def help_(ui, name=None, with_version=Fa else: ui.write(' %-*s %s\n' % (m, f, h[f])) + def helptopic(name): + v = None + for i in help.helptable: + l = i.split('|') + if name in l: + v = i + header = l[-1] + if not v: + raise UnknownCommand(name) + + # description + doc = help.helptable[v] + if not doc: + doc = _("(No help text available)") + + ui.write("%s\n" % header) + ui.write("%s\n" % doc.rstrip()) + def helpext(name): try: mod = findext(name) @@ -1163,10 +1181,16 @@ def help_(ui, name=None, with_version=Fa helplist(modcmds.has_key) if name and name != 'shortlist': - try: - helpcmd(name) - except UnknownCommand: - helpext(name) + i = None + for f in (helpcmd, helptopic, helpext): + try: + f(name) + i = None + break + except UnknownCommand, inst: + i = inst + if i: + raise i else: # program name diff --git a/mercurial/help.py b/mercurial/help.py new file mode 100644 --- /dev/null +++ b/mercurial/help.py @@ -0,0 +1,45 @@ +# help.py - help data for mercurial +# +# Copyright 2006 Matt Mackall +# +# This software may be used and distributed according to the terms +# of the GNU General Public License, incorporated herein by reference. + +helptable = { + "dates|Date Formats": + r''' + Some commands (backout, commit, tag) allow the user to specify a date. + Possible formats for dates are: + +YYYY-mm-dd \HH:MM[:SS] [(+|-)NNNN]:: + This is a subset of ISO 8601, allowing just the recommended notations + for date and time. The last part represents the timezone; if omitted, + local time is assumed. Examples: + + "2005-08-22 03:27 -0700" + + "2006-04-19 21:39:51" + +aaa bbb dd HH:MM:SS YYYY [(+|-)NNNN]:: + This is the date format used by the C library. Here, aaa stands for + abbreviated weekday name and bbb for abbreviated month name. The last + part represents the timezone; if omitted, local time is assumed. + Examples: + + "Mon Aug 22 03:27:00 2005 -0700" + + "Wed Apr 19 21:39:51 2006" + +unixtime offset:: + This is the internal representation format for dates. unixtime is + the number of seconds since the epoch (1970-01-01 00:00 UTC). offset + is the offset of the local timezone, in seconds west of UTC (negative + if the timezone is east of UTC). + Examples: + + "1124706420 25200" (2005-08-22 03:27:00 -0700) + + "1145475591 -7200" (2006-04-19 21:39:51 +0200) + ''', +} +