changeset 3:906d9021f9e5

Making progress on autogenerated example output.
author Bryan O'Sullivan <bos@serpentine.com>
date Sat, 24 Jun 2006 17:42:40 -0700
parents 379a802c0210
children 33a2e7b9978d
files en/00book.tex en/99defs.tex en/examples/mq.qinit-help en/examples/run-example en/mq.tex
diffstat 5 files changed, 79 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/en/00book.tex	Sat Jun 24 16:14:02 2006 -0700
+++ b/en/00book.tex	Sat Jun 24 17:42:40 2006 -0700
@@ -2,6 +2,7 @@
 \usepackage{fullpage}
 \usepackage{graphics}
 \usepackage{newcent}
+\usepackage{fancyvrb}
 \usepackage{hyperref}
 
 \include{99defs}
--- a/en/99defs.tex	Sat Jun 24 16:14:02 2006 -0700
+++ b/en/99defs.tex	Sat Jun 24 17:42:40 2006 -0700
@@ -1,8 +1,11 @@
+\newcommand{\tildefile}[1]{\texttt{\~/#1}}
 \newcommand{\filename}[1]{\texttt{#1}}
 \newcommand{\hgext}[1]{\texttt{#1}}
 \newcommand{\hgcmd}[1]{``\texttt{hg #1}''}
 \newcommand{\hgcmdargs}[2]{``\texttt{hg #1 #2}''}
 
+\DefineVerbatimEnvironment{codesample}{Verbatim}{frame=single,gobble=2,numbers=left}
+
 %%% Local Variables: 
 %%% mode: latex
 %%% TeX-master: "00book"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/en/examples/mq.qinit-help	Sat Jun 24 17:42:40 2006 -0700
@@ -0,0 +1,2 @@
+# name: help
+hg help qinit
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/en/examples/run-example	Sat Jun 24 17:42:40 2006 -0700
@@ -0,0 +1,58 @@
+#!/usr/bin/python
+
+import cStringIO
+import os
+import pty
+import re
+import sys
+
+class example:
+    def __init__(self, name):
+        self.name = name
+
+    def parse(self):
+        fp = open(self.name)
+        cfp = cStringIO.StringIO()
+        for line in fp:
+            cfp.write(line)
+            if not line.rstrip().endswith('\\'):
+                yield cfp.getvalue()
+                cfp.seek(0)
+                cfp.truncate()
+        
+    name_re = re.compile('#\s*name:\s*(.*)$')
+    
+    def status(self, s):
+        sys.stdout.write(s)
+        if not s.endswith('\n'):
+            sys.stdout.flush()
+
+    def run(self):
+        ofp = None
+        self.status('running %s ' % os.path.basename(self.name))
+        for hunk in self.parse():
+            m = self.name_re.match(hunk)
+            if m:
+                self.status('.')
+                out = m.group(1)
+                assert os.sep not in out
+                if out:
+                    ofp = open('%s.%s.out' % (self.name, out), 'w')
+                else:
+                    ofp = None
+            elif ofp: ofp.write(hunk)
+        self.status('\n')
+
+def main(path='.'):
+    args = sys.argv[1:]
+    if args:
+        for a in args:
+            example(a).run()
+        return
+    for name in os.listdir(path):
+        if name == 'run-example' or name.startswith('.'): continue
+        if name.endswith('.out') or name.endswith('~'): continue
+        example(os.path.join(path, name)).run()
+
+if __name__ == '__main__':
+    main()
--- a/en/mq.tex	Sat Jun 24 16:14:02 2006 -0700
+++ b/en/mq.tex	Sat Jun 24 17:42:40 2006 -0700
@@ -21,7 +21,7 @@
 
 The patch management problem arises in many situations.  Probably the
 most visible is that a user of an open source software project will
-contribute a bugfix or new feature to the project's maintainers in the
+contribute a bug fix or new feature to the project's maintainers in the
 form of a patch.
 
 Distributors of operating systems that include open source software
@@ -35,7 +35,7 @@
 patch will contain only one bug fix (the patch might modify several
 files, but it's doing ``only one thing''), and you may have a number
 of such patches for different bugs you need fixed and local changes
-you require.  In this situation, if you submit a bugfix patch to the
+you require.  In this situation, if you submit a bug fix patch to the
 upstream maintainers of a package and they include your fix in a
 subsequent release, you can simply drop that single patch when you're
 updating to the newer release.
@@ -99,7 +99,7 @@
 modifications those patches make.
 
 Quilt knows nothing about revision control tools, so it works equally
-well on top of an unpacked tarball or a Suversion repository.
+well on top of an unpacked tarball or a Subversion repository.
 
 \subsection{From patchwork quilt to Mercurial Queues}
 \label{sec:mq:quilt-mq}
@@ -128,15 +128,19 @@
 \section{Getting started with Mercurial Queues}
 \label{sec:mq:start}
 
-Because MQ is implemented as an extension, you have to explicitly
-enable it in order to use it.  (You don't need to download anything;
-MQ ships with the standard Mercurial distribution.)  To enable it,
-edit your \filename{~/.hgrc} file, and add the following lines:
+Because MQ is implemented as an extension, you must explicitly enable
+before you can use it.  (You don't need to download anything; MQ ships
+with the standard Mercurial distribution.)  To enable MQ, edit your
+\tildefile{.hgrc} file, and add the following lines:
 
-\begin{verbatim}
-[extensions]
-hgext.mq =
-\end{verbatim}
+\begin{codesample}
+  [extensions]
+  hgext.mq =
+\end{codesample}
+
+Once the extension is enabled, it will make a number of new commands
+available.  
+
 
 %%% Local Variables: 
 %%% mode: latex