mercurial: stop shipping mercurial-26 obsolete pkg
[unleashed-userland.git] / components / developer / mercurial / patches / hgmanpage.patch
blobc9abcc2b63a62eed78d1c5c8cf8e151dd3107140
1 rst2man does a poor job of creating man pages that can be read on Solaris.
2 Some of the changes in this patch make the Solaris *roff tools do the right
3 thing:
5 - Getting rid of the rst2man header before the SYNOPSIS
7 - Changing "\(aq" to "'", and making sure that single quotes don't start
8 a line (at least in a couple of places where it's not safe)
10 - Changing ".ft C" and ".ft P" to simply ".ft"
12 - Removing "\%" and "\:"
14 Groff also seems to have as much trouble with the .INDENT/.UNINDENT macros
15 as Solaris *roff, de-indenting paragraphs that shouldn't be, so we use
16 .RS/.RE instead. It's not as fancy, but seems to do the job.
18 Applying this patch has no effect in the normal userland build (it can't
19 run automatically until docutils is delivered), but it enables a "gmake
20 patches/manpage.patch" to regenerate the manpages with the updated text
21 (found in rst.patch) with the patched hgmanpage.py, and updates the
22 manpage.patch file.
24 --- mercurial.hg/doc/hgmanpage.py 2016-10-09 20:00:17.207404849 -0700
25 +++ mercurial.hg/doc/hgmanpage.py 2016-10-10 10:04:03.695820057 -0700
26 @@ -202,6 +202,7 @@
27 self._in_docinfo = None
28 self._active_table = None
29 self._in_literal = False
30 + self._in_literal_inline = False
31 self.header_written = 0
32 self._line_block = 0
33 self.authors = []
34 @@ -217,15 +218,15 @@
35 # ``B`` bold, ``I`` italic, ``R`` roman should be available.
36 # Hopefully ``C`` courier too.
37 self.defs = {
38 - 'indent' : ('.INDENT %.1f\n', '.UNINDENT\n'),
39 + 'indent' : ('.RS %d\n', '.RE\n'),
40 'definition_list_item' : ('.TP', ''),
41 'field_name' : ('.TP\n.B ', '\n'),
42 'literal' : ('\\fB', '\\fP'),
43 - 'literal_block' : ('.sp\n.nf\n.ft C\n', '\n.ft P\n.fi\n'),
44 + 'literal_block' : ('.sp\n.nf\n.ft\n', '\n.ft\n.fi\n'),
46 'option_list_item' : ('.TP\n', ''),
48 - 'reference' : (r'\%', r'\:'),
49 + 'reference' : (r'', r''),
50 'emphasis': ('\\fI', '\\fP'),
51 'strong' : ('\\fB', '\\fP'),
52 'term' : ('\n.B ', '\n'),
53 @@ -272,6 +273,7 @@
54 self.body[i - 2][:4] == '.TP\n'):
55 self.body[i] = '.\n'
56 elif (self.body[i - 1] == '\n' and
57 + self.body[i - 2] and
58 self.body[i - 2][0] != '.' and
59 (self.body[i - 3][:7] == '.TP\n.B '
60 or self.body[i - 3][:4] == '\n.B ')
61 @@ -289,7 +291,6 @@
62 text = text.replace('\\','\\e')
63 replace_pairs = [
64 (u'-', u'\\-'),
65 - (u"'", u'\\(aq'),
66 (u'ยด', u"\\'"),
67 (u'`', u'\\(ga'),
69 @@ -302,6 +303,15 @@
70 if text[0] == '.':
71 text = '\\&' + text
72 text = text.replace('\n.', '\n\\&.')
73 + # We need to do the same thing for the inline literals, too
74 + if self._in_literal_inline and text[0] == '.':
75 + if self.body[-2].endswith('\n') and \
76 + self.body[-1] == self.defs['literal'][0]:
77 + self.body.append('\\&')
78 + # Single quotes starting a line are harmful, too.
79 + if text[0] == "'":
80 + text = '\\&' + text
81 + text = text.replace("\n'", "\n\\&'")
82 self.body.append(text)
84 def depart_Text(self, node):
85 @@ -386,7 +396,6 @@
86 if self.header_written:
87 return
88 self.body.append(self.header())
89 - self.body.append(MACRO_DEF)
90 self.header_written = 1
92 def visit_address(self, node):
93 @@ -800,8 +809,10 @@
95 def visit_literal(self, node):
96 self.body.append(self.defs['literal'][0])
97 + self._in_literal_inline = True
99 def depart_literal(self, node):
100 + self._in_literal_inline = False
101 self.body.append(self.defs['literal'][1])
103 def visit_literal_block(self, node):