Mercurial > hgbook
changeset 363:bc92b28fc970
finished template.tex
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Tue, 23 Sep 2008 12:27:24 +0900 |
parents | df4ac9043db0 |
children | 1b372620963a |
files | ja/template.tex ja/todo.txt |
diffstat | 2 files changed, 189 insertions(+), 96 deletions(-) [+] |
line wrap: on
line diff
--- a/ja/template.tex Tue Sep 23 02:21:24 2008 +0900 +++ b/ja/template.tex Tue Sep 23 12:27:24 2008 +0900 @@ -185,7 +185,7 @@ \begin{itemize} %\item[\tplkword{author}] String. The unmodified author of the changeset. -\item[\tplkword{author}] $BJ8;zNs!%%A%'%s%8%;%C%H$NCx<T$,$=$N$b$N!%(B +\item[\tplkword{author}] $BJ8;zNs!%%A%'%s%8%;%C%H$NCx<T!%(B %\item[\tplkword{branches}] String. The name of the branch on which % the changeset was committed. Will be empty if the branch name was % \texttt{default}. @@ -463,16 +463,14 @@ \item[\tplkwfilt{author}{person}] $BG$0U$N%F%-%9%H!%(B\tplkword{author}$B%-!<(B $B%o!<%I$H9g$o$;$F;H$&>l9g$b$C$H$bM-MQ!%(Bemail$B%"%I%l%9$NA0$N%F(B - $B%-%9%H$rCj=P$9$k!%Nc$($P(B``\Verb+Bryan O'Sullivan - <bos@serpentine.com>+''$B$O(B``\Verb+Bryan O'Sullivan+''$B$H$J$k!%(B + $B%-%9%H$rCj=P$9$k!%Nc$($P(B``\Verb+Bryan O'Sullivan <bos@serpentine.com>+''$B$O(B``\Verb+Bryan O'Sullivan+''$B$H$J$k!%(B %\item[\tplkwfilt{date}{rfc822date}] \tplkword{date} keyword. Render a % date using the same format used in email headers. Yields a string % like ``\Verb+Mon, 04 Sep 2006 15:13:13 -0700+''. \item[\tplkwfilt{date}{rfc822date}] \tplkword{date}$B%-!<%o!<%I!%F|;~$r(B - email$B%X%C%@$HF1$87A<0$G@07A$9$k!%(B``\Verb+Mon, 04 Sep 2006 - 15:13:13 -0700+''$B$N$h$&$JJ8;zNs$r@8@.$9$k!%(B + email$B%X%C%@$HF1$87A<0$G@07A$9$k!%(B``\Verb+Mon, 04 Sep 2006 15:13:13 -0700+''$B$N$h$&$JJ8;zNs$r@8@.$9$k!%(B %\item[\tplkwfilt{node}{short}] Changeset hash. Yield the short form % of a changeset hash, i.e.~a 12-byte hexadecimal string. @@ -515,8 +513,7 @@ \item[\tplkwfilt{author}{user}] $BG$0U$N%F%-%9%H!%(B\tplkword{author}$B%-!<%o!<(B $B%I$H6&$K;H$C$?>l9g$K:G$bM-MQ!%(Bemail$B%"%I%l%9$+$i%f!<%6L>$NIt(B - $BJ,$rH4$-=P$9!%Nc$($P(B``\Verb+Bryan O'Sullivan - <bos@serpentine.com>+''$B$O(B``\Verb+bos+''$B$H$J$k!%(B + $BJ,$rH4$-=P$9!%Nc$($P(B``\Verb+Bryan O'Sullivan <bos@serpentine.com>+''$B$O(B``\Verb+bos+''$B$H$J$k!%(B \end{itemize} \begin{figure} @@ -596,124 +593,189 @@ %\subsection{The simplest of style files} \subsection{$B:G$bC1=c$J%9%?%$%k%U%!%$%k(B} -Our simple style file contains just one line: +%Our simple style file contains just one line: + +$B%5%s%W%k%9%?%$%k%U%!%$%k$O$?$@$N(B1$B9T$+$i$J$k(B: \interaction{template.simple.rev} -This tells Mercurial, ``if you're printing a changeset, use the text -on the right as the template''. +%This tells Mercurial, ``if you're printing a changeset, use the text +%on the right as the template''. + +$B$3$l$O(BMercurial$B$K(B``$B%A%'%s%8%;%C%H$r=PNO$9$k;~$O1&$N%F%-%9%H$r%F%s%W%l!<%H(B +$B$H$7$F;H$((B''$B$H$$$&;X<($rM?$($k!%(B %\subsection{Style file syntax} \subsection{$B%9%?%$%k%U%!%$%k$NJ8K!(B} -The syntax rules for a style file are simple. +%The syntax rules for a style file are simple. + +$B%9%?%$%k%U%!%$%k$NJ8K!5,B'$OC1=c$G$"$k!%(B \begin{itemize} -\item The file is processed one line at a time. +%\item The file is processed one line at a time. +\item $B%U%!%$%k$O0lEY$K(B1$B9T$:$D=hM}$5$l$k(B -\item Leading and trailing white space are ignored. +%\item Leading and trailing white space are ignored. +\item $BA08e$N6uGr$OL5;k$5$l$k(B -\item Empty lines are skipped. +%\item Empty lines are skipped. +\item $B6u9T$O%9%-%C%W$5$l$k(B -\item If a line starts with either of the characters ``\texttt{\#}'' or - ``\texttt{;}'', the entire line is treated as a comment, and skipped - as if empty. +%\item If a line starts with either of the characters ``\texttt{\#}'' or +% ``\texttt{;}'', the entire line is treated as a comment, and skipped +% as if empty. +\item $B9T$,(B``\texttt{\#}''$B$^$?$O(B``\texttt{;}''$B$G;O$^$k>l9g$O!$9TA4BN$,%3(B + $B%a%s%H$H$7$F07$o$l!$6uGr$HF1MM$K%9%-%C%W$5$l$k!%(B -\item A line starts with a keyword. This must start with an - alphabetic character or underscore, and can subsequently contain any - alphanumeric character or underscore. (In regexp notation, a - keyword must match \Verb+[A-Za-z_][A-Za-z0-9_]*+.) +%\item A line starts with a keyword. This must start with an +% alphabetic character or underscore, and can subsequently contain any +% alphanumeric character or underscore. (In regexp notation, a +% keyword must match \Verb+[A-Za-z_][A-Za-z0-9_]*+.) +\item $B9T$O%-!<%o!<%I$G;O$^$k!%I,$:%"%k%U%!%Y%C%H$+%"%s%@!<%9%3%"$G;O$^$k(B + $BI,MW$,$"$j!$8eB3$NJ8;z$O%"%k%U%!%Y%C%H!$?t;z!$%"%s%@!<%9%3%"$N$$$:(B + $B$l$+$G$"$C$F$h$$!%!J@55,I=8=$G$O(B\Verb+[A-Za-z_][A-Za-z0-9_]*+$B$H%^%C(B + $B%A$9$k!K(B -\item The next element must be an ``\texttt{=}'' character, which can - be preceded or followed by an arbitrary amount of white space. +%\item The next element must be an ``\texttt{=}'' character, which can +% be preceded or followed by an arbitrary amount of white space. +\item $B<!$NMWAG$OJ8;z(B``\texttt{=}''$B$G!$A08e$K6uGr$,F~$C$F$bNI$$!%(B -\item If the rest of the line starts and ends with matching quote - characters (either single or double quote), it is treated as a - template body. +%\item If the rest of the line starts and ends with matching quote +% characters (either single or double quote), it is treated as a +% template body. +\item $B?t$ND`$j9g$C$?%7%s%0%k%/%)!<%H$^$?$O%@%V%k%/%)!<%H$G3g$i$l$kItJ,$,(B + $BB3$/>l9g$O$3$l$,%F%s%W%l!<%H%\%G%#$H$7$F07$o$l$k!%(B -\item If the rest of the line \emph{does not} start with a quote - character, it is treated as the name of a file; the contents of this - file will be read and used as a template body. +%\item If the rest of the line \emph{does not} start with a quote +% character, it is treated as the name of a file; the contents of this +% file will be read and used as a template body. +\item $BB3$/ItJ,$,%/%)!<%HJ8;z$G;O$^$i$J$$>l9g$O%U%!%$%kL>$H$7$F07$o$l!$%U%!(B + $B%$%k$NFbMF$,%F%s%W%l!<%H%\%G%#$H$7$F;H$o$l$k!%(B + \end{itemize} %\section{Style files by example} \section{$B%9%?%$%k%U%!%$%k$NNc(B} -To illustrate how to write a style file, we will construct a few by -example. Rather than provide a complete style file and walk through -it, we'll mirror the usual process of developing a style file by -starting with something very simple, and walking through a series of -successively more complete examples. +%To illustrate how to write a style file, we will construct a few by +%example. Rather than provide a complete style file and walk through +%it, we'll mirror the usual process of developing a style file by +%starting with something very simple, and walking through a series of +%successively more complete examples. + +$B%9%?%$%k%U%!%$%k$N=q$-J}$r@bL@$9$k$?$a$K$$$/$D$+$NNcBj$r5s$2$F$_$k!%40A4(B +$B$J%9%?%$%k%U%!%$%k$rMQ0U$7$F$3$l$r@bL@$9$k$N$G$O$J$/!$$H$F$bC1=c$JNc$+$i(B +$B;O$a$F!$$@$s$@$s$HJ#;($JNc$K?J$`$3$H$G%9%?%$%k%U%!%$%k$NDL>o$N3+H/%W%m%;(B +$B%9$rLOJo$7$F$_$k!%(B %\subsection{Identifying mistakes in style files} \subsection{$B%9%?%$%k%U%!%$%k$G$N8m$j$rFCDj$9$k(B} -If Mercurial encounters a problem in a style file you are working on, -it prints a terse error message that, once you figure out what it -means, is actually quite useful. +%If Mercurial encounters a problem in a style file you are working on, +%it prints a terse error message that, once you figure out what it +%means, is actually quite useful. + +Mercurial$B$,%9%?%$%k%U%!%$%k$GLdBj$KD>LL$9$k$H!$4J7i$J%(%i!<%a%C%;!<%8$rI=(B +$B<($9$k!%$3$N%a%C%;!<%8$O$=$N0UL#$9$k$H$3$m$,J,$+$C$F$$$l$P$H$F$bM-1W$G$"(B +$B$k!%(B \interaction{template.svnstyle.syntax.input} -Notice that \filename{broken.style} attempts to define a -\texttt{changeset} keyword, but forgets to give any content for it. -When instructed to use this style file, Mercurial promptly complains. +%Notice that \filename{broken.style} attempts to define a +%\texttt{changeset} keyword, but forgets to give any content for it. +%When instructed to use this style file, Mercurial promptly complains. + +\filename{broken.style}$B$G(B\texttt{changeset}$B%-!<%o!<%I$rDj5A$7$h$&$H$7$F$$(B +$B$k$,!$Dj5A$NFbMF$,A4$/M?$($i$l$F$$$J$$!%$3$N%9%?%$%k%U%!%$%k$r;H$*$&$H$9(B +$B$k$H!$(BMercurial$B$O$9$0$5$^%(%i!<$rI=<($9$k!%(B \interaction{template.svnstyle.syntax.error} -This error message looks intimidating, but it is not too hard to -follow. +%This error message looks intimidating, but it is not too hard to +%follow. + +$B$3$N%(%i!<%a%C%;!<%8$O62$m$7$2$@$,!$BP1~$9$k$N$O$5$[$IFq$7$/$J$$!%(B \begin{itemize} -\item The first component is simply Mercurial's way of saying ``I am - giving up''. +%\item The first component is simply Mercurial's way of saying ``I am +% giving up''. + \item $B:G=i$NItJ,$O(B``$B%.%V%"%C%W(B''$B$N(BMercurial$BE*$JI=8=$G$"$k!%(B \begin{codesample4} \textbf{abort:} broken.style:1: parse error \end{codesample4} -\item Next comes the name of the style file that contains the error. +%\item Next comes the name of the style file that contains the error. +\item $B<!$K%(%i!<$N$"$k%9%?%$%k%U%!%$%kL>$,I=<($5$l$k(B \begin{codesample4} abort: \textbf{broken.style}:1: parse error \end{codesample4} -\item Following the file name is the line number where the error was - encountered. +%\item Following the file name is the line number where the error was +% encountered. + \item $B%U%!%$%kL>$N8e$K%(%i!<$N5/$-$?9THV9f$,B3$/!%(B \begin{codesample4} abort: broken.style:\textbf{1}: parse error \end{codesample4} -\item Finally, a description of what went wrong. +%\item Finally, a description of what went wrong. + \item $B:G8e$KLdBjE@$N@bL@$,I=<($5$l$k(B \begin{codesample4} abort: broken.style:1: \textbf{parse error} \end{codesample4} - The description of the problem is not always clear (as in this - case), but even when it is cryptic, it is almost always trivial to - visually inspect the offending line in the style file and see what - is wrong. +% The description of the problem is not always clear (as in this +% case), but even when it is cryptic, it is almost always trivial to +% visually inspect the offending line in the style file and see what +% is wrong. +$BLdBj$N@bL@$O>o$KL@2w$G$"$k$H$O8B$i$J$$!%!J$3$NNc$N$h$&$K!%!K$7$+$7Ff$a$$(B + $B$F$$$?$H$7$F$b!$KX$s$I$N>l9g!$%9%?%$%k%U%!%$%k$NLdBj$N$"$k9T$r8+(B + $B$k$H!$$4$/:3:Y$JLdBj$K$9$.$J$$$b$N$G$"$k!%(B \end{itemize} %\subsection{Uniquely identifying a repository} \subsection{$B%j%]%8%H%j$NFCDj(B} -If you would like to be able to identify a Mercurial repository -``fairly uniquely'' using a short string as an identifier, you can -use the first revision in the repository. -\interaction{template.svnstyle.id} -This is not guaranteed to be unique, but it is nevertheless useful in -many cases. +%If you would like to be able to identify a Mercurial repository +%``fairly uniquely'' using a short string as an identifier, you can +%use the first revision in the repository. +%\interaction{template.svnstyle.id} + +%This is not guaranteed to be unique, but it is nevertheless useful in +%many cases. + +$BC;$$J8;zNs$r<1JL;R$K;H$C$F(BMercurial$B%j%]%8%H%j$rFCDj$7$?$$>l9g$O(B +$B%j%]%8%H%jFb$N:G=i$N%j%S%8%g%s$r;H$&$3$H$,$G$-$k!%(B +\interaction{template.svnstyle.id} +$B$3$l$O%f%K!<%/$G$"$k$3$H$,J]>Z$5$l$F$$$k$o$1$G$O$J$$$,!$B?$/$N>l9g$KM-MQ(B +$B$G$"$k$3$H$O$$$&$^$G$b$J$$!%(B + \begin{itemize} -\item It will not work in a completely empty repository, because such - a repository does not have a revision~zero. -\item Neither will it work in the (extremely rare) case where a - repository is a merge of two or more formerly independent - repositories, and you still have those repositories around. +%\item It will not work in a completely empty repository, because such +% a repository does not have a revision~zero. + \item $B40A4$K6u$N%j%]%8%H%j$G$O$3$NJ}K!$O;H$($J$$!%6u$N%j%]%8%H%j$K$O%j(B + $B%S%8%g%s(B~$B%<%m$9$iB8:_$7$J$$$?$a$G$"$k!%(B + +%\item Neither will it work in the (extremely rare) case where a +% repository is a merge of two or more formerly independent +% repositories, and you still have those repositories around. + \item $BFHN)$7$?J#?t$N%j%]%8%H%j$r%^!<%8$7$F%j%]%8%H%j$r:n@.$7!$$3$l$i$N(B + $B%j%]%8%H%j$,0MA3$H$7$FB8:_$9$k$J$I$N!J$-$o$a$F5)$J!K>l9g$O$3$NJ}(B + $BK!$O;H$($J$$!%(B \end{itemize} -Here are some uses to which you could put this identifier: +%Here are some uses to which you could put this identifier: +$B$3$N<1JL;R$N;HMQNc$r<($9(B: \begin{itemize} -\item As a key into a table for a database that manages repositories - on a server. -\item As half of a \{\emph{repository~ID}, \emph{revision~ID}\} tuple. - Save this information away when you run an automated build or other - activity, so that you can ``replay'' the build later if necessary. +%\item As a key into a table for a database that manages repositories +% on a server. + \item $B%5!<%P>e$G%j%]%8%H%j$r4IM}$9$k%G!<%?%Y!<%9MQ$N%F!<%V%k$X$N%-!<$H$7$F!%(B + +%\item As half of a \{\emph{repository~ID}, \emph{revision~ID}\} tuple. +% Save this information away when you run an automated build or other +% activity, so that you can ``replay'' the build later if necessary. + \item \{\emph{repository~ID}, \emph{revision~ID}\}$B%?%W%k$NH>J,$H$7$F!%<+(B +$BF0%S%k%I$d$=$NB>$NA`:n$r9T$&$H$-$K$3$N>pJs$r%;!<%V$7$F$*$-!$8e$G%S%k%I$r(B +$B:F8=$9$k$3$H$,I,MW$H$J$C$?$i(B``$B%j%W%l%$(B''$B$r9T$($k$h$&$K$9$k!%(B + \end{itemize} %\subsection{Mimicking Subversion's output} @@ -733,40 +795,71 @@ Subversion$B$N=PNO%9%?%$%k$O$+$J$jC1=c$J$N$G!$=PNO$+$i%U%!%$%k$X(Bhunk$B$r%3%T!<(B $B!u%Z!<%9%H$7!$(BSubversion$B$,@8@.$7$?%F%-%9%H$r%F%s%W%l!<%H$K$h$C$FCV49$9$k(B -$B$N$O4JC1$G$"$k!%(B \interaction{template.svnstyle.template} +$B$N$O4JC1$G$"$k!%(B +\interaction{template.svnstyle.template} %There are a few small ways in which this template deviates from the %output produced by Subversion. +$B%F%s%W%l!<%H$K$h$k=PNO$,(BSubversion$B$,@8@.$9$k=PNO$H0[$J$k(B2, 3$B$NNc$,$"$k!%(B + \begin{itemize} -\item Subversion prints a ``readable'' date (the ``\texttt{Wed, 27 Sep - 2006}'' in the example output above) in parentheses. Mercurial's - templating engine does not provide a way to display a date in this - format without also printing the time and time zone. -\item We emulate Subversion's printing of ``separator'' lines full of - ``\texttt{-}'' characters by ending the template with such a line. - We use the templating engine's \tplkword{header} keyword to print a - separator line as the first line of output (see below), thus - achieving similar output to Subversion. -\item Subversion's output includes a count in the header of the number - of lines in the commit message. We cannot replicate this in - Mercurial; the templating engine does not currently provide a filter - that counts the number of items it is passed. +%\item Subversion prints a ``readable'' date (the ``\texttt{Wed, 27 Sep +% 2006}'' in the example output above) in parentheses. Mercurial's +% templating engine does not provide a way to display a date in this +% format without also printing the time and time zone. + \item Subversion$B$OCf3g8L$G0O$^$l$?(B``$B2DFI$J(B''$BF|;~$r=PNO$9$k!%!J>e$NNc$G$O(B + ``\texttt{Wed, 27 Sep 2006}''$B!%!K(B Mercurial$B$N%F%s%W%l!<%H%(%s%8%s(B + $B$O$3$N%U%)!<%^%C%H$G;~9o$H%?%$%`%>!<%s$r4^$^$J$$7A$GF|;~$r=PNO$9$k(B + $B$3$H$,$G$-$J$$!%(B + +%\item We emulate Subversion's printing of ``separator'' lines full of +% ``\texttt{-}'' characters by ending the template with such a line. +% We use the templating engine's \tplkword{header} keyword to print a +% separator line as the first line of output (see below), thus +% achieving similar output to Subversion. + \item Subversion$B$N(B``$B%;%Q%l!<%?(B''$B9T$N=PNO$r%F%s%W%l!<%H$r9TI}0lGU$N(B + ``\texttt{-}''$BJ8;z$G=*$($k$3$H$G%(%_%e%l!<%H$7$F$$$k!%%F%s%W%l!<%H(B + $B%(%s%8%s$N(B\tplkword{header}$B%-!<%o!<%I$r;H$C$F%;%Q%l!<%?9T$r=PNO$N(B + $B:G=i$N9T$H$7$F=PNO$9$k!%!J2<5-$r;2>H!%!K$3$l$K$h$C$F(BSubversion$B$H;w(B + $BDL$C$?=PNO$r9T$C$F$$$k!%(B + +%\item Subversion's output includes a count in the header of the number +% of lines in the commit message. We cannot replicate this in +% Mercurial; the templating engine does not currently provide a filter +% that counts the number of items it is passed. + \item Subversion$B$N=PNO$O%X%C%@Fb$K%3%_%C%H%a%C%;!<%8$N9T?t$N%+%&%s%H$r(B + $B4^$s$G$$$k!%(BMercurial$B$G$O$3$l$r:F8=$9$k$3$H$O$G$-$J$$!%%F%s%W%l!<(B + $B%H%(%s%8%s$O8=>u$G$OEO$5$l$?%"%$%F%`$r?t$($k%U%#%k%?$r:n$k$3$H$,(B + $B$G$-$J$$!%(B \end{itemize} -It took me no more than a minute or two of work to replace literal -text from an example of Subversion's output with some keywords and -filters to give the template above. The style file simply refers to -the template. +%It took me no more than a minute or two of work to replace literal +%text from an example of Subversion's output with some keywords and +%filters to give the template above. The style file simply refers to +%the template. + +Subversion$B$N=PNO$r;29M$K!$%F%-%9%H$rCV49$9$k%-!<%o!<%I!$%F%s%W%l!<%H$NF~$C(B +$B$?%U%#%k%?$r=`Hw$9$k$N$K$O$[$s$N#1!$#2J,$7$+$+$+$i$J$+$C$?!%%9%?%$%k%U%!(B +$B%$%k$OC1=c$K%F%s%W%l!<%H$r;2>H$9$k$N$_$G$"$k(B + \interaction{template.svnstyle.style} -We could have included the text of the template file directly in the -style file by enclosing it in quotes and replacing the newlines with -``\texttt{\\n}'' sequences, but it would have made the style file too -difficult to read. Readability is a good guide when you're trying to -decide whether some text belongs in a style file, or in a template -file that the style file points to. If the style file will look too -big or cluttered if you insert a literal piece of text, drop it into a -template instead. +%We could have included the text of the template file directly in the +%style file by enclosing it in quotes and replacing the newlines with +%``\texttt{\\n}'' sequences, but it would have made the style file too +%difficult to read. Readability is a good guide when you're trying to +%decide whether some text belongs in a style file, or in a template +%file that the style file points to. If the style file will look too +%big or cluttered if you insert a literal piece of text, drop it into a +%template instead. + +$B%F%s%W%l!<%H%U%!%$%k$N%F%-%9%H$r%/%)!<%H$G3g$j!$2~9T$r(B``\texttt{\\n}''$B$G(B +$B%(%9%1!<%W$9$k$3$H$G%9%?%$%k%U%!%$%k$KD>@\DI2C$9$k$3$H$b2DG=$G$O$"$k!%$7(B +$B$+$7$=$&$7$?>l9g!$%9%?%$%k%U%!%$%k$,$[$H$s$IFI$a$J$$$[$IJ#;($K$J$C$F$7$^(B +$B$&$@$m$&!%%F%-%9%H$r%9%?%$%k%U%!%$%k$KF~$l$k$+!$%9%?%$%k%U%!%$%k$+$i8F$P(B +$B$l$k%F%s%W%l!<%H%U%!%$%k$KF~$l$k$+$O!$2DFI@-$r9MN8$7$F7hDj$9$Y$-$G$"$k!%(B +$B$b$7%F%-%9%H$rDI2C$7$?$3$H$G%9%?%$%k%U%!%$%k$,Bg$-$/$J$j2a$.$?$j!$Mp;($K(B +$B$J$C$?$j$7$?>l9g$O!$%F%s%W%l!<%H$X$N0\F0$r9MN8$9$k$H$h$$!%(B %%% Local Variables: %%% mode: yatex