##// END OF EJS Templates
graft: don't drop the second parent on unsuccessful merge (issue3498)...
graft: don't drop the second parent on unsuccessful merge (issue3498) This replicates the strategy of rebase, which postpones setparents and duplicatecopies after checking the merge stats. Without the second parent, resolve cannot redo merge.

File last commit:

r16942:87882c87 default
r17045:52ea9ce5 stable
Show More
help.py
116 lines | 4.3 KiB | text/x-python | PythonLexer
Matt Mackall
Add basic support for help topics and a dates topic
r3795 # help.py - help data for mercurial
#
# Copyright 2006 Matt Mackall <mpm@selenic.com>
#
Martin Geisler
updated license to be explicit about GPL version 2
r8225 # This software may be used and distributed according to the terms of the
Matt Mackall
Update license to GPLv2+
r10263 # GNU General Public License version 2 or any later version.
Matt Mackall
Add basic support for help topics and a dates topic
r3795
Martin Geisler
help: move help topics from mercurial/help.py to help/*.txt...
r9539 from i18n import gettext, _
import sys, os
FUJIWARA Katsunori
filemerge: create detail of internal merge tools from documentation string...
r16126 import extensions, revset, fileset, templatekw, templatefilters, filemerge
Dan Villiom Podlaski Christiansen
prevent transient leaks of file handle by using new helper functions...
r14168 import util
Cédric Duval
help: adding a new help topic about extensions...
r8863
Matt Mackall
extensions: drop maxlength from enabled and disabled...
r14316 def listexts(header, exts, indent=1):
Cédric Duval
help: more improvements for the extensions topic...
r8879 '''return a text listing of the given extensions'''
if not exts:
return ''
Matt Mackall
extensions: drop maxlength from enabled and disabled...
r14316 maxlength = max(len(e) for e in exts)
Cédric Duval
help: more improvements for the extensions topic...
r8879 result = '\n%s\n\n' % header
for name, desc in sorted(exts.iteritems()):
Brodie Rao
dispatch: provide help for disabled extensions and commands...
r10364 result += '%s%-*s %s\n' % (' ' * indent, maxlength + 2,
':%s:' % name, desc)
Cédric Duval
help: refactor extensions listing, and show enabled ones in the dedicated topic
r8864 return result
Cédric Duval
help: more improvements for the extensions topic...
r8879 def extshelp():
Martin Geisler
help: move help topics from mercurial/help.py to help/*.txt...
r9539 doc = loaddoc('extensions')()
Matt Mackall
extensions: drop maxlength from enabled and disabled...
r14316 doc += listexts(_('enabled extensions:'), extensions.enabled())
doc += listexts(_('disabled extensions:'), extensions.disabled())
Cédric Duval
help: adding a new help topic about extensions...
r8863 return doc
Martin Geisler
i18n: mark help strings for translation...
r7013
Martin Geisler
help: move help topics from mercurial/help.py to help/*.txt...
r9539 def loaddoc(topic):
"""Return a delayed loader for help/topic.txt."""
Matt Mackall
move environment topic
r3798
Martin Geisler
help: move help topics from mercurial/help.py to help/*.txt...
r9539 def loader():
Augie Fackler
windows: check util.mainfrozen() instead of ad-hoc checks everywhere
r14941 if util.mainfrozen():
Martin Geisler
help: move help topics from mercurial/help.py to help/*.txt...
r9539 module = sys.executable
else:
module = __file__
base = os.path.dirname(module)
Dirkjan Ochtman
help: add a topic on git diffs (issue1352)
r7293
Martin Geisler
help: move help topics from mercurial/help.py to help/*.txt...
r9539 for dir in ('.', '..'):
docdir = os.path.join(base, dir, 'help')
if os.path.isdir(docdir):
break
Alexander Solovyov
help: add a topic about some of the templating features
r7677
Martin Geisler
help: move help topics from mercurial/help.py to help/*.txt...
r9539 path = os.path.join(docdir, topic + ".txt")
Dan Villiom Podlaski Christiansen
prevent transient leaks of file handle by using new helper functions...
r14168 doc = gettext(util.readfile(path))
Patrick Mezard
help: add topic rewriting hooks...
r12820 for rewriter in helphooks.get(topic, []):
doc = rewriter(topic, doc)
return doc
Martin Geisler
help: move help topics from mercurial/help.py to help/*.txt...
r9539 return loader
Alexander Solovyov
help: add a topic about some of the templating features
r7677
Yun Lee
help: sort help topics to make the output more readable (issue2751)
r13888 helptable = sorted([
Martin Geisler
help: make "hg help hgrc" an alias for "hg help config"
r12145 (["config", "hgrc"], _("Configuration Files"), loaddoc('config')),
Martin Geisler
help: move help topics from mercurial/help.py to help/*.txt...
r9539 (["dates"], _("Date Formats"), loaddoc('dates')),
(["patterns"], _("File Name Patterns"), loaddoc('patterns')),
Matt Mackall
many, many trivial check-code fixups
r10282 (['environment', 'env'], _('Environment Variables'),
loaddoc('environment')),
(['revs', 'revisions'], _('Specifying Single Revisions'),
loaddoc('revisions')),
(['mrevs', 'multirevs'], _('Specifying Multiple Revisions'),
loaddoc('multirevs')),
Martin Geisler
help: add "revset" alias for "revsets" help topic
r12818 (['revset', 'revsets'], _("Specifying Revision Sets"), loaddoc('revsets')),
Matt Mackall
fileset: add a help topic...
r14686 (['fileset', 'filesets'], _("Specifying File Sets"), loaddoc('filesets')),
Martin Geisler
help: move help topics from mercurial/help.py to help/*.txt...
r9539 (['diffs'], _('Diff Formats'), loaddoc('diffs')),
Erik Zielke
help: help topic for merge tools...
r12771 (['merge-tools'], _('Merge Tools'), loaddoc('merge-tools')),
A. S. Budden
help: add reference to template help (issue3413)...
r16568 (['templating', 'templates', 'template', 'style'], _('Template Usage'),
Matt Mackall
many, many trivial check-code fixups
r10282 loaddoc('templates')),
Martin Geisler
help: move help topics from mercurial/help.py to help/*.txt...
r9539 (['urls'], _('URL Paths'), loaddoc('urls')),
Martin Geisler
help: consistently use title capitalization for help topics
r16547 (["extensions"], _("Using Additional Features"), extshelp),
Yun Lee
help: move hgignore man page into built-in help (issue2769)
r14044 (["subrepo", "subrepos"], _("Subrepositories"), loaddoc('subrepos')),
(["hgweb"], _("Configuring hgweb"), loaddoc('hgweb')),
(["glossary"], _("Glossary"), loaddoc('glossary')),
Martin Geisler
help: consistently use title capitalization for help topics
r16547 (["hgignore", "ignore"], _("Syntax for Mercurial Ignore Files"),
Yun Lee
help: move hgignore man page into built-in help (issue2769)
r14044 loaddoc('hgignore')),
Matt Mackall
help: add phases topic
r15996 (["phases"], _("Working with Phases"), loaddoc('phases')),
Yun Lee
help: sort help topics to make the output more readable (issue2751)
r13888 ])
Patrick Mezard
help: add topic rewriting hooks...
r12820
# Map topics to lists of callable taking the current topic help and
# returning the updated version
Matt Mackall
help: consolidate topic hooks in help.py...
r14318 helphooks = {}
Patrick Mezard
help: add topic rewriting hooks...
r12820
def addtopichook(topic, rewriter):
helphooks.setdefault(topic, []).append(rewriter)
Patrick Mezard
help: extract items doc generation function
r13593
def makeitemsdoc(topic, doc, marker, items):
"""Extract docstring from the items key to function mapping, build a
.single documentation block and use it to overwrite the marker in doc
"""
entries = []
for name in sorted(items):
text = (items[name].__doc__ or '').rstrip()
if not text:
continue
text = gettext(text)
lines = text.splitlines()
"Yann E. MORIN"
help: strip doctest from dochelp...
r16250 doclines = [(lines[0])]
for l in lines[1:]:
# Stop once we find some Python doctest
if l.strip().startswith('>>>'):
break
doclines.append(' ' + l.strip())
entries.append('\n'.join(doclines))
Patrick Mezard
help: extract items doc generation function
r13593 entries = '\n\n'.join(entries)
return doc.replace(marker, entries)
Matt Mackall
help: consolidate topic hooks in help.py...
r14318
def addtopicsymbols(topic, marker, symbols):
def add(topic, doc):
return makeitemsdoc(topic, doc, marker, symbols)
addtopichook(topic, add)
Matt Mackall
fileset: add a help topic...
r14686 addtopicsymbols('filesets', '.. predicatesmarker', fileset.symbols)
FUJIWARA Katsunori
filemerge: create detail of internal merge tools from documentation string...
r16126 addtopicsymbols('merge-tools', '.. internaltoolsmarker', filemerge.internals)
Matt Mackall
help: consolidate topic hooks in help.py...
r14318 addtopicsymbols('revsets', '.. predicatesmarker', revset.symbols)
addtopicsymbols('templates', '.. keywordsmarker', templatekw.keywords)
addtopicsymbols('templates', '.. filtersmarker', templatefilters.filters)