darcs 2.3.0 → 2.3.1
raw patch · 12 files changed
+309/−309 lines, 12 filesdep ~hashed-storagenew-uploader
Dependency ranges changed: hashed-storage
Files
- NEWS +18/−0
- README +2/−33
- darcs.cabal +4/−6
- release/distributed-context +1/−1
- src/Darcs/Commands/Changes.lhs +41/−42
- src/Darcs/Commands/Help.lhs +20/−6
- src/Darcs/Commands/Replace.lhs +26/−18
- src/Darcs/Commands/WhatsNew.lhs +12/−2
- src/Preproc.hs +183/−0
- src/building_darcs.tex +0/−17
- src/darcs.hs +2/−0
- src/preproc.hs +0/−184
NEWS view
@@ -1,3 +1,21 @@+Darcs 2.3.1, 20 Sep 2009++ * Important changes in Darcs 2.3.1++ * Fix bugs introduced by optimizations in 2.3.0 (Petr, Salvatore)+ * Documentation improvements (Taylor, Trent)+ * Remove autoconf build system (Petr)++ * Bugs Fixed in Darcs 2.3.1++ See http://bugs.darcs.net/issueN for details on bug number N.++ * issue1373 darcs manual wrongly promises [^ ] is a valid token spec (Trent)+ * issue1478: document summary mnemonics (Trent)+ * issue1582 DeleteFile: permission denied (Access is denied.) (Salvatore)+ * issue1507 whatsnew does not use 'current' when 'pristine' is missing (Petr)++ Darcs 2.3.0, 23 Jul 2009 * Important changes in Darcs 2.3.0
README view
@@ -11,15 +11,8 @@ Compilation and Installation ============================ -Darcs currently supports two build systems: a cabal-based system and a legacy-autotools-based system, and a cabal-based system. CABAL IS RECOMMENDED and the-autotools system is deprecated: in future releases, autotools support will be-removed.--If a "configure" file is present, autotools is supported. If a-"Setup.lhs" file is present, cabal is supported. Currently there is a-separate source tarball for each build system; either can be used in-unstable checkouts.+Building Darcs requires the cabal package, version 1.6 or higher. The+cabal-install package is also recommended. Using GHC 6.10.3 or newer is STRONGLY RECOMMENDED. You can compile darcs with GHC 6.8, but there are several caveats. If you are using 6.8.2 or older, please@@ -33,12 +26,6 @@ 64-bit system, darcs may hang when you exit a pager when compiled with GHC older than 6.10.3. Although this is harmless, it is quite inconvenient. -Using Cabal--------------This method requires the cabal package, version 1.6 or higher. The-cabal-install package is also recommended.- If you have the "cabal-install" package on your system (that is, there is a "cabal" executable in your path), you can use the following command to create an executable in ~/.cabal/bin/darcs (this will also automatically fetch and@@ -63,24 +50,6 @@ Please also note that the cabal-based build by default requires the cURL library (and development headers). If, for some reason, you cannot provide cURL, please pass "-f-curl" to the configure step above.--Using Autotools------------------If you have the normal, autotools-based tarball, this sequence should work-for you (if you are in doubt, this is likely the case):-- $ ./configure- $ make- # make install--You first need to run `autoconf` if you obtained the source tree from the-darcs repository (but this is not needed for release tarballs).--For more information, please see the manual:-- * http://www.darcs.net/manual- * doc/manual/darcs.ps Hacking
darcs.cabal view
@@ -1,5 +1,5 @@ Name: darcs-version: 2.3.0+version: 2.3.1 License: GPL License-file: COPYING Author: David Roundy <droundy@darcs.net>, <darcs-users@darcs.net>@@ -41,9 +41,6 @@ src/*.h src/Crypt/sha2.h src/win32/send_email.h src/win32/sys/mman.h - -- TODO: factor out these standalone executables to other sections- src/preproc.hs, src/unit.lhs,- -- The contrib directory would make a sensible 'darcs-contrib' package contrib/_darcs.zsh, contrib/darcs_completion, contrib/cygwin-wrapper.bash, contrib/update_roundup.pl, contrib/upload.cgi,@@ -316,7 +313,7 @@ html == 1.0.*, filepath == 1.1.*, haskeline >= 0.6.1 && < 0.7,- hashed-storage >= 0.3.6 && < 0.4+ hashed-storage >= 0.3.8 && < 0.4 if !os(windows) build-depends: unix >= 1.0 && < 2.4@@ -433,6 +430,7 @@ System.Posix System.Posix.Files System.Posix.IO+ Preproc cpp-options: -DWIN32 c-sources: src/win32/send_email.c @@ -446,7 +444,7 @@ html == 1.0.*, filepath == 1.1.*, haskeline >= 0.6.1 && < 0.7,- hashed-storage >= 0.3.6 && < 0.4+ hashed-storage >= 0.3.8 && < 0.4 if !os(windows) build-depends: unix >= 1.0 && < 2.4
release/distributed-context view
@@ -1,1 +1,1 @@-Just "\nContext:\n\n[TAG 2.3.0\nPetr Rockai <me@mornfall.net>**20090723115125\n Ignore-this: e326d4ddff92c578e8fe8a3c23d00193\n] \n"+Just "\nContext:\n\n[TAG 2.3.1\nReinier Lamers <tux_rocker@reinier.de>**20090920174331\n Ignore-this: a5da37b9925e1dfe3e81f0b67183ef1f\n] \n"
src/Darcs/Commands/Changes.lhs view
@@ -70,12 +70,15 @@ #include "impossible.h" changes_description :: String-changes_description = "Gives a changelog-style summary of the repository history."+changes_description = "List patches in the repository." changes_help :: String changes_help =- "Changes gives a changelog-style summary of the repository history,\n"++- "including options for altering how the patches are selected and displayed.\n"+ "The `darcs changes' command lists the patches that constitute the\n" +++ "current repository. Without options or arguments, ALL patches will be\n" +++ "listed.\n" +++ "\n" ++ changes_help' +++ "\n" ++ changes_help'' changes :: DarcsCommand changes = DarcsCommand {command_name = "changes",@@ -132,32 +135,27 @@ where maybe_reverse (xs,b,c) = if Reverse `elem` opts then (reverse xs, b, c) else (xs, b, c)-\end{code} -When given one or more files or directories as an argument, changes lists only-those patches which affect those files or the contents of those directories or,-of course, the directories themselves. This includes changes that happened to-files before they were moved or renamed. -\begin{options}---from-match, --from-patch, --from-tag-\end{options}--If changes is given a \verb!--from-patch!, \verb!--from-match!, or-\verb!--from-tag! option, it outputs only those changes since that tag or-patch.--Without any options to limit the scope of the changes, history will be displayed-going back as far as possible.--\begin{options}---max-count-\end{options}--If changes is given a \verb!--max-count! option, it only outputs up to as that-number of changes.+-- FIXME: this prose is unreadable. --twb, 2009-08+changes_help' :: String+changes_help' =+ "When given one or more files or directories as an argument, only\n" +++ "patches which affect those files or directories are listed. This\n" +++ "includes changes that happened to files before they were moved or\n" +++ "renamed.\n" +++ "\n" +++ "When given a --from-tag, --from-patch or --from-match, only changes\n" +++ "since that tag or patch are listed. Similarly, the --to-tag,\n" +++ "--to-patch and --to-match options restrict the list to older patches.\n" +++ "\n" +++ "The --last and --max-count options both limit the number of patches\n" +++ "listed. The former applies BEFORE other filters, whereas the latter\n" +++ "applies AFTER other filters. For example `darcs changes foo.c\n" +++ "--max-count 3' will print the last three patches that affect foo.c,\n" +++ "whereas `darcs changes --last 3 foo.c' will, of the last three\n" +++ "patches, print only those that affect foo.c.\n" -\begin{code} get_changes_info :: RepoPatch p => [DarcsFlag] -> [FilePath] -> PatchSet p -> ([(PatchInfoAnd p, [FilePath])], [FilePath], Doc) get_changes_info opts plain_fs ps =@@ -261,23 +259,24 @@ pis = map fst pis_and_fs description' = description . fst -\end{code}--\begin{options}---context, --human-readable, --xml-output-\end{options}+-- FIXME: this prose is unreadable. --twb, 2009-08+changes_help'' :: String+changes_help'' =+ "Three output formats exist. The default is --human-readable. You can\n" +++ "also select --context, which is the internal format (as seen in patch\n" +++ "bundles) that can be re-read by Darcs (e.g. `darcs get --context').\n" +++ "\n" +++ "Finally, there is --xml-output, which emits valid XML... unless a the\n" +++ "patch metadata (author, name or description) contains a non-ASCII\n" +++ "character and was recorded in a non-UTF8 locale.\n" +++ "\n" +++ -- FIXME: can't we just disallow the following usage?+ "Note that while the --context flag may be used in conjunction with\n" +++ "--xml-output or --human-readable, in neither case will darcs get be\n" +++ "able to read the output. On the other hand, sufficient information\n" +++ "WILL be output for a knowledgeable human to recreate the current state\n" +++ "of the repository.\n" -When given the \verb!--context! flag, darcs changes outputs sufficient-information to allow the current state of the repository to be-recreated at a later date. This information should generally be piped to a-file, and then can be used later in conjunction with-\verb!darcs get --context! to recreate the current version. Note that-while the \verb!--context! flag may be used in conjunction with-\verb!--xml-output! or \verb!--human-readable!, in neither case will darcs-get be able to read the output. On the other hand, sufficient information-\emph{will} be output for a knowledgeable human to recreate the current-state of the repository.-\begin{code} changes_context :: RepoPatch p => Repository p -> [DarcsFlag] -> IO () changes_context repository opts = do r <- read_repo repository
src/Darcs/Commands/Help.lhs view
@@ -162,7 +162,7 @@ ".TP 3", "\\(bu", "Distributed: Every user has access to the full", "command set, removing boundaries between server and",- "client or committer and non-committers.",+ "client or committer and non\\(hycommitters.", ".TP", "\\(bu", "Interactive: Darcs is easy to learn and efficient to", "use because it asks you questions in response to",@@ -183,14 +183,14 @@ "Each command's most important options are listed in the", ".B COMMANDS", "section. For a full list of all options accepted by",- "a particular command, run `darcs", ".I command", "--help'.",- ".SS " ++ helpOnMatchers, -- FIXME: this is a kludge.+ "a particular command, run `darcs", ".I command", "\\-\\-help'.",+ ".SS " ++ escape helpOnMatchers, -- FIXME: this is a kludge. ".SH COMMANDS", unlines commands, unlines environment, ".SH FILES", ".SS \"_darcs/prefs/binaries\"",- unlines binaries_file_help,+ escape $ unlines binaries_file_help, ".SH BUGS", "At http://bugs.darcs.net/ you can find a list of known", "bugs in Darcs. Unknown bugs can be reported at that",@@ -244,7 +244,7 @@ render prefix c = [".B darcs " ++ prefix ++ command_name c] ++ (map mangle_args $ command_extra_arg_help c) ++- [".RS 4", command_help c, ".RE"]+ [".RS 4", escape $ command_help c, ".RE"] -- | Now I'm showing off: mangle the extra arguments of Darcs commands -- so as to use the ideal format for manpages, italic words and roman@@ -260,7 +260,21 @@ environment :: [String] environment = ".SH ENVIRONMENT" : concat- [(".SS \"" ++ andClauses ks ++ "\"") : ds+ [(".SS \"" ++ andClauses ks ++ "\"") : map escape ds | (ks, ds) <- environmentHelp]++ -- | Copied from Preproc.escape_latex_specials.+ escape :: String -> String+ escape = minus . bs -- Order is important+ where+ minus = replace "-" "\\-"+ bs = replace "\\" "\\\\"++ replace :: Eq a => [a] -> [a] -> [a] -> [a]+ replace _ _ [] = []+ replace find repl s =+ if take (length find) s == find+ then repl ++ (replace find repl (drop (length find) s))+ else [head s] ++ replace find repl (tail s) \end{code}
src/Darcs/Commands/Replace.lhs view
@@ -64,30 +64,20 @@ "\n" ++ "Files are tokenized according to one simple rule: words are strings of\n" ++ "valid token characters, and everything between them (punctuation and\n" ++- "whitespace) is discarded.\n" ++- "\n" ++- "The tokenizer treats files as byte strings, so it is not possible for\n" ++- "--token-chars to include multi-byte characters, such as the non-ASCII\n" ++- "parts of UTF-8. Similarly, trying to replace a `high-bit' character\n" ++- "from a unibyte encoding will also result in replacement of the same\n" ++- "byte in files with different encodings. For example, an acute a from\n" ++- "ISO 8859-1 will also match an alpha from ISO 8859-7.\n" ++- "\n" ++ -- FIXME: this heuristic is ham-fisted and silly. Can we drop it?- "By default, valid token characters are letters, numbers and the\n" ++- "underscore (i.e. [A-Za-z0-9_]). However if the old and/or new token\n" ++- "contains either a hyphen or period, BOTH hyphen and period are treated\n" ++- "as valid by default (i.e. [A-Za-z0-9_.-]).\n" +++ "whitespace) is discarded. By default, valid token characters are\n" +++ "letters, numbers and the underscore (i.e. [A-Za-z0-9_]). However if\n" +++ "the old and/or new token contains either a hyphen or period, BOTH\n" +++ "hyphen and period are treated as valid (i.e. [A-Za-z0-9_.-]).\n" ++ "\n" ++ "The set of valid characters can be customized using the --token-chars\n" ++ "option. The argument must be surrounded by square brackets. If a\n" ++ "hyphen occurs between two characters in the set, it is treated as a\n" ++ "set range. For example, in most locales [A-Z] denotes all uppercase\n" ++ "letters. If the first character is a caret, valid tokens are taken to\n" ++- "be the complement of the remaining characters. For example, [^ \\n\\t]\n" ++- "declares all characters except the space, tab and newline as valid\n" ++- "within a word. Unlike the tr(1) and grep(1) utilities, character\n" ++- "classes (such as [[:alnum:]]) are NOT supported.\n" +++ "be the complement of the remaining characters. For example, [^:\\n]\n" +++ "could be used to match fields in the passwd(5), where records and\n" +++ "fields are separated by newlines and colons respectively.\n" ++ "\n" ++ "If you choose to use --token-chars, you are STRONGLY encouraged to do\n" ++ "so consistently. The consequences of using multiple replace patches\n" ++@@ -98,7 +88,25 @@ "is already in use, because the replacements would be not be\n" ++ "distinguishable from the existing tokens. This behaviour can be\n" ++ "overridden by supplying the --force option, but an attempt to `darcs\n" ++- "rollback' the resulting patch will affect these existing tokens.\n"+ "rollback' the resulting patch will affect these existing tokens.\n" +++ "\n" +++ "Limitations:\n" +++ "\n" +++ "The tokenizer treats files as byte strings, so it is not possible for\n" +++ "--token-chars to include multi-byte characters, such as the non-ASCII\n" +++ "parts of UTF-8. Similarly, trying to replace a `high-bit' character\n" +++ "from a unibyte encoding will also result in replacement of the same\n" +++ "byte in files with different encodings. For example, an acute a from\n" +++ "ISO 8859-1 will also match an alpha from ISO 8859-7.\n" +++ "\n" +++ "Due to limitations in the patch file format, --token-chars arguments\n" +++ "cannot contain literal whitespace. For example, [^ \\n\\t] cannot be\n" +++ "used to declare all characters except the space, tab and newline as\n" +++ "valid within a word, because it contains a literal space.\n" +++ "\n" +++ "Unlike POSIX regex(7) bracket expressions, character classes (such as\n" +++ "[[:alnum:]]) are NOT supported by --token-chars, and will be silently\n" +++ "treated as a simple set of characters.\n" -- FIXME: can we just delete the remaining text? It seems more an -- instance of "look how clever I am; I made commutation work" rather
src/Darcs/Commands/WhatsNew.lhs view
@@ -68,12 +68,22 @@ "With the --summary option, the changes are condensed to one line per\n" ++ "file, with mnemonics to indicate the nature and extent of the change.\n" ++ "The --look-for-adds option causes candidates for `darcs add' to be\n" ++- "included in the summary output.\n" +++ "included in the summary output. Summary mnemonics are as follows:\n" ++ "\n" +++ " `A f' and `A d/' respectively mean an added file or directory.\n" +++ " `R f' and `R d/' respectively mean a removed file or directory.\n" +++ " `M f -N +M rP' means a modified file, with N lines deleted, M\n" +++ " lines added, and P lexical replacements.\n" +++ " `f -> g' means a moved file or directory.\n" +++ "\n" +++ " An exclamation mark (!) as in `R! foo.c', means the hunk is known to\n" +++ " conflict with a hunk in another patch. The phrase `duplicated'\n" +++ " means the hunk is known to be identical to a hunk in another patch.\n" +++ "\n" ++ "By default, `darcs whatsnew' uses Darcs' internal format for changes.\n" ++ "To see some context (unchanged lines) around each change, use the\n" ++ "--unified option. To view changes in conventional `diff' format, use\n" ++- "the `darcs diff' comand; but note that `darcs whatsnew' is faster.\n" +++ "the `darcs diff' command; but note that `darcs whatsnew' is faster.\n" ++ "\n" ++ "This command exits unsuccessfully (returns a non-zero exit status) if\n" ++ "there are no unrecorded changes.\n"
+ src/Preproc.hs view
@@ -0,0 +1,183 @@+-- | This program mangles a pseudo-LaTeX document into actual LaTeX.+-- There are three key changes to the input:+--+-- * \\input{foo} is replaced by the contents of the file foo (after+-- it, too, is mangled). Note that this is relative to the+-- working directory, *not* relative to the file being parsed.+--+-- * Anything between \\begin{code} and \\end{code} is deleted.+-- Note that this is quite unlike normal literate documentation+-- (for which we use Haddock, not LaTeX).+--+-- * Some nonstandard pseudo-LaTeX commands are expanded into actual+-- LaTeX text. In particular, \\darcsCommand{foo} is replaced by+-- LaTeX markup describing the command @foo@.+module Preproc ( preproc_main ) where+import System.FilePath ( (</>) )+import System.Environment ( getArgs )+import System.Exit ( exitWith, ExitCode(..) )+import Text.Regex ( matchRegex, mkRegex )+import Darcs.Commands ( DarcsCommand(SuperCommand,+ command_sub_commands, command_name,+ command_extra_arg_help, command_basic_options,+ command_advanced_options, command_help,+ command_description),+ extract_commands )+import Darcs.Arguments ( options_latex )+import Darcs.Commands.Help ( command_control_list, environmentHelp )+import English ( andClauses )+import ThisVersion ( darcs_version )++the_commands :: [DarcsCommand]+the_commands = extract_commands command_control_list++-- | The entry point for this program. The path to the TeX master+-- file is supplied as the first argument. Bootstrapping into+-- 'preproc' then happens by passing it a pseudo-document that+-- contains a single input (include) line.+preproc_main :: [String] -> IO ()+preproc_main args = do+ if length args < 1+ then exitWith $ ExitFailure 1+ else return ()+ putStrLn "%% This file was automatically generated by preproc."+ c <- preproc ["\\input{"++head args++"}"]+ mapM_ putStrLn c++-- | Depending on whether pdflatex or htlatex is to be used, the LaTeX+-- output of this program must vary subtly. This procedure returns+-- true iff the command-line arguments contain @--html@.+am_html :: IO Bool+am_html = do args <- getArgs+ return $ elem "--html" args++-- | Given a list of input lines in pseudo-LaTeX, return the same+-- document in LaTeX. The pseudo-LaTeX lines are replaced, other+-- lines are used unmodified.+preproc :: [String] -> IO [String]+preproc [] = return [] -- Empty input, empty output.+preproc ("\\usepackage{html}":ss) = -- only use html package with latex2html+ do rest <- preproc ss+ ah <- am_html+ if ah then return $ "\\usepackage{html}" : rest+ else return $ "\\usepackage{hyperref}" : rest+preproc ("\\begin{code}":ss) = ignore ss+ where ignore :: [String] -> IO [String]+ ignore ("\\end{code}":ss') = preproc ss'+ ignore (_:ss') = ignore ss'+ ignore [] = return []+preproc ("\\begin{options}":ss) =+ do rest <- preproc ss+ ah <- am_html+ if ah then return $ "\\begin{rawhtml}" : "<div class=\"cmd-opt-hdr\">" : rest+ else return $ ("\\begin{Verbatim}[frame=lines,xleftmargin=1cm," +++ "xrightmargin=1cm]") : rest+preproc ("\\end{options}":ss) =+ do rest <- preproc ss+ ah <- am_html+ if ah then return $ "</div>" : "\\end{rawhtml}" : rest+ else return $ "\\end{Verbatim}" : rest+preproc ("\\darcsVersion":ss) = do+ rest <- preproc ss+ return $ darcs_version:rest+preproc (s:ss) = do+ rest <- preproc ss+ let rx = mkRegex "^\\\\(input|darcs(Command|Env))\\{(.+)\\}$"+ case matchRegex rx s of+ Just ["input", _, path] ->+ do cs <- readFile $ "src" </> path -- ratify readFile: not part of darcs executable+ this <- preproc $ lines cs+ return $ this ++ rest+ Just ["darcsCommand", _, command] ->+ return $ commandHelp command : rest+ Just ["darcsEnv", _, variable] ->+ return $ envHelp variable : rest+ -- The base case for the whole preproc function. Nothing to+ -- mangle, so this is an ordinary line of TeX, and we append it to+ -- the result unmodified.+ _ -> return $ s : rest++commandHelp :: String -> String+commandHelp command = section ++ "{darcs " ++ command ++ "}\n" +++ "\\label{" ++ command ++ "}\n" +++ gh ++ get_options command ++ gd+ where+ section = if ' ' `elem` command then "\\subsubsection" else "\\subsection"+ -- | Given a Darcs command name as a string, return that command's (multi-line) help string.+ gh :: String+ gh = escape_latex_specials $ command_property command_help the_commands command+ -- | Given a Darcs command name as a string, return that command's (one-line) description string.+ gd :: String+ gd = command_property command_description the_commands command++get_options :: String -> String+get_options comm = get_com_options $ get_c names the_commands+ where names = words comm++get_c :: [String] -> [DarcsCommand] -> [DarcsCommand]+get_c (name:ns) commands =+ case ns of+ [] -> [get name commands]+ _ -> case get name commands of+ c@SuperCommand { } ->+ c:(get_c ns $ extract_commands $ command_sub_commands c)+ _ ->+ error $ "Not a supercommand: " ++ name+ where get n (c:cs) | command_name c == n = c+ | otherwise = get n cs+ get n [] = error $ "No such command: "++n+get_c [] _ = error "no command specified"++get_com_options :: [DarcsCommand] -> String+get_com_options c =+ "\\par\\verb!Usage: darcs " ++ cmd ++ " [OPTION]... " +++ args ++ "!\n\n" ++ "Options:\n\n" ++ options_latex opts1 +++ (if null opts2 then "" else "\n\n" ++ "Advanced options:\n\n" ++ options_latex opts2)+ where cmd = unwords $ map command_name c+ args = unwords $ command_extra_arg_help $ last c+ opts1 = command_basic_options $ last c+ opts2 = command_advanced_options $ last c++command_property :: (DarcsCommand -> String) -> [DarcsCommand] -> String+ -> String+command_property property commands name =+ property $ last c+ where names = words name+ c = get_c names commands++++envHelp :: String -> String+envHelp var = unlines $ render $ entry environmentHelp+ where render (ks, ds) =+ ("\\paragraph{" ++ escape_latex_specials (andClauses ks) ++ "}") :+ ("\\label{env:" ++ var ++ "}") :+ map escape_latex_specials ds+ entry [] = undefined+ entry (x:xs) | elem var $ fst x = x+ | otherwise = entry xs++-- | LaTeX treats a number of characters or sequences specially.+-- Therefore when including ordinary help text in a LaTeX document, it+-- is necessary to escape these characters in the way LaTeX expects.+escape_latex_specials :: String -> String+-- Order is important+escape_latex_specials =+ (bs2 . amp . percent . carrot . dollar . underscore . rbrace . lbrace . bs1)+ where+ amp = replace "&" "\\&"+ bs1 = replace "\\" "\001"+ bs2 = replace "\001" "$\\backslash$"+ carrot = replace "^" "\\^{}"+ dollar = replace "$" "\\$"+ lbrace = replace "{" "\\{"+ percent = replace "%" "\\%"+ rbrace = replace "}" "\\}"+ underscore = replace "_" "\\_"++ replace :: Eq a => [a] -> [a] -> [a] -> [a]+ replace _ _ [] = []+ replace find repl s =+ if take (length find) s == find+ then repl ++ (replace find repl (drop (length find) s))+ else [head s] ++ replace find repl (tail s)
src/building_darcs.tex view
@@ -74,20 +74,3 @@ \item zlib 0.5. \end{itemize} \end{itemize}--\section{The Old Way}-Darcs can still be built with GNU autotools; this approach is-deprecated and will be removed after the 2.3 release. Run-\begin{verbatim}-autoconf-./configure-make-make install-\end{verbatim}--The build dependencies are identical to the previous approach, except-that instead of the \texttt{Cabal} package, you will need-\begin{itemize}-\item GNU Make; and-\item GNU autoconf 2.50 or higher.-\end{itemize}
src/darcs.hs view
@@ -33,6 +33,7 @@ import Darcs.SignalHandler ( withSignalsHandled ) import Context ( context ) import Darcs.Global ( with_atexit )+import Preproc( preproc_main ) import Exec ( ExecException(..) ) #include "impossible.h" @@ -65,6 +66,7 @@ ["--exact-version"] -> do putStrLn $ "darcs compiled on "++__DATE__++", at "++__TIME__ putStrLn context+ ("--preprocess-manual":rest) -> preproc_main rest -- User called a normal darcs command, "darcs foo [args]". _ -> do hSetBinaryMode stdin True
− src/preproc.hs
@@ -1,184 +0,0 @@--- | This program mangles a pseudo-LaTeX document into actual LaTeX.--- There are three key changes to the input:------ * \\input{foo} is replaced by the contents of the file foo (after--- it, too, is mangled). Note that this is relative to the--- working directory, *not* relative to the file being parsed.------ * Anything between \\begin{code} and \\end{code} is deleted.--- Note that this is quite unlike normal literate documentation--- (for which we use Haddock, not LaTeX).------ * Some nonstandard pseudo-LaTeX commands are expanded into actual--- LaTeX text. In particular, \\darcsCommand{foo} is replaced by--- LaTeX markup describing the command @foo@.-module Main (main) where-import System.FilePath ( (</>) )-import System.Environment ( getArgs )-import System.Exit ( exitWith, ExitCode(..) )-import Text.Regex ( matchRegex, mkRegex )-import Darcs.Commands ( DarcsCommand(SuperCommand,- command_sub_commands, command_name,- command_extra_arg_help, command_basic_options,- command_advanced_options, command_help,- command_description),- extract_commands )-import Darcs.Arguments ( options_latex )-import Darcs.Commands.Help ( command_control_list, environmentHelp )-import English ( andClauses )-import ThisVersion ( darcs_version )--the_commands :: [DarcsCommand]-the_commands = extract_commands command_control_list---- | The entry point for this program. The path to the TeX master--- file is supplied as the first argument. Bootstrapping into--- 'preproc' then happens by passing it a pseudo-document that--- contains a single input (include) line.-main :: IO ()-main = do- args <- getArgs- if length args < 1- then exitWith $ ExitFailure 1- else return ()- putStrLn "%% This file was automatically generated by preproc."- c <- preproc ["\\input{"++head args++"}"]- mapM_ putStrLn c---- | Depending on whether pdflatex or htlatex is to be used, the LaTeX--- output of this program must vary subtly. This procedure returns--- true iff the command-line arguments contain @--html@.-am_html :: IO Bool-am_html = do args <- getArgs- return $ elem "--html" args---- | Given a list of input lines in pseudo-LaTeX, return the same--- document in LaTeX. The pseudo-LaTeX lines are replaced, other--- lines are used unmodified.-preproc :: [String] -> IO [String]-preproc [] = return [] -- Empty input, empty output.-preproc ("\\usepackage{html}":ss) = -- only use html package with latex2html- do rest <- preproc ss- ah <- am_html- if ah then return $ "\\usepackage{html}" : rest- else return $ "\\usepackage{hyperref}" : rest-preproc ("\\begin{code}":ss) = ignore ss- where ignore :: [String] -> IO [String]- ignore ("\\end{code}":ss') = preproc ss'- ignore (_:ss') = ignore ss'- ignore [] = return []-preproc ("\\begin{options}":ss) =- do rest <- preproc ss- ah <- am_html- if ah then return $ "\\begin{rawhtml}" : "<div class=\"cmd-opt-hdr\">" : rest- else return $ ("\\begin{Verbatim}[frame=lines,xleftmargin=1cm," ++- "xrightmargin=1cm]") : rest-preproc ("\\end{options}":ss) =- do rest <- preproc ss- ah <- am_html- if ah then return $ "</div>" : "\\end{rawhtml}" : rest- else return $ "\\end{Verbatim}" : rest-preproc ("\\darcsVersion":ss) = do- rest <- preproc ss- return $ darcs_version:rest-preproc (s:ss) = do- rest <- preproc ss- let rx = mkRegex "^\\\\(input|darcs(Command|Env))\\{(.+)\\}$"- case matchRegex rx s of- Just ["input", _, path] ->- do cs <- readFile $ "src" </> path -- ratify readFile: not part of darcs executable- this <- preproc $ lines cs- return $ this ++ rest- Just ["darcsCommand", _, command] ->- return $ commandHelp command : rest- Just ["darcsEnv", _, variable] ->- return $ envHelp variable : rest- -- The base case for the whole preproc function. Nothing to- -- mangle, so this is an ordinary line of TeX, and we append it to- -- the result unmodified.- _ -> return $ s : rest--commandHelp :: String -> String-commandHelp command = section ++ "{darcs " ++ command ++ "}\n" ++- "\\label{" ++ command ++ "}\n" ++- gh ++ get_options command ++ gd- where- section = if ' ' `elem` command then "\\subsubsection" else "\\subsection"- -- | Given a Darcs command name as a string, return that command's (multi-line) help string.- gh :: String- gh = escape_latex_specials $ command_property command_help the_commands command- -- | Given a Darcs command name as a string, return that command's (one-line) description string.- gd :: String- gd = command_property command_description the_commands command--get_options :: String -> String-get_options comm = get_com_options $ get_c names the_commands- where names = words comm--get_c :: [String] -> [DarcsCommand] -> [DarcsCommand]-get_c (name:ns) commands =- case ns of- [] -> [get name commands]- _ -> case get name commands of- c@SuperCommand { } ->- c:(get_c ns $ extract_commands $ command_sub_commands c)- _ ->- error $ "Not a supercommand: " ++ name- where get n (c:cs) | command_name c == n = c- | otherwise = get n cs- get n [] = error $ "No such command: "++n-get_c [] _ = error "no command specified"--get_com_options :: [DarcsCommand] -> String-get_com_options c =- "\\par\\verb!Usage: darcs " ++ cmd ++ " [OPTION]... " ++- args ++ "!\n\n" ++ "Options:\n\n" ++ options_latex opts1 ++- (if null opts2 then "" else "\n\n" ++ "Advanced options:\n\n" ++ options_latex opts2)- where cmd = unwords $ map command_name c- args = unwords $ command_extra_arg_help $ last c- opts1 = command_basic_options $ last c- opts2 = command_advanced_options $ last c--command_property :: (DarcsCommand -> String) -> [DarcsCommand] -> String- -> String-command_property property commands name =- property $ last c- where names = words name- c = get_c names commands----envHelp :: String -> String-envHelp var = unlines $ render $ entry environmentHelp- where render (ks, ds) =- ("\\paragraph{" ++ escape_latex_specials (andClauses ks) ++ "}") :- ("\\label{env:" ++ var ++ "}") :- map escape_latex_specials ds- entry [] = undefined- entry (x:xs) | elem var $ fst x = x- | otherwise = entry xs---- | LaTeX treats a number of characters or sequences specially.--- Therefore when including ordinary help text in a LaTeX document, it--- is necessary to escape these characters in the way LaTeX expects.-escape_latex_specials :: String -> String--- Order is important-escape_latex_specials =- (bs2 . amp . percent . carrot . dollar . underscore . rbrace . lbrace . bs1)- where- amp = replace "&" "\\&"- bs1 = replace "\\" "\001"- bs2 = replace "\001" "$\\backslash$"- carrot = replace "^" "\\^{}"- dollar = replace "$" "\\$"- lbrace = replace "{" "\\{"- percent = replace "%" "\\%"- rbrace = replace "}" "\\}"- underscore = replace "_" "\\_"-- replace :: Eq a => [a] -> [a] -> [a] -> [a]- replace _ _ [] = []- replace find repl s =- if take (length find) s == find- then repl ++ (replace find repl (drop (length find) s))- else [head s] ++ replace find repl (tail s)