# HG changeset patch # User Yoshiki Yazawa # Date 1232004883 -32400 # Node ID beab196f78da13932eba8291dc0023436e869f44 # Parent 5530934319b866d1ac368ca360e138ab00b31520 - more hook.tex - more daily.tex diff -r 5530934319b8 -r beab196f78da ja/daily.tex --- a/ja/daily.tex Fri Jan 09 23:05:26 2009 +0900 +++ b/ja/daily.tex Thu Jan 15 16:34:43 2009 +0900 @@ -54,58 +54,98 @@ %\subsection{Explicit versus implicit file naming} \subsection{明示的なファイル命名対暗黙のファイル命名} -A useful behaviour that Mercurial has is that if you pass the name of -a directory to a command, every Mercurial command will treat this as -``I want to operate on every file in this directory and its -subdirectories''. +%A useful behaviour that Mercurial has is that if you pass the name of +%a directory to a command, every Mercurial command will treat this as +%``I want to operate on every file in this directory and its +%subdirectories''. +%\interaction{daily.files.add-dir} +%Notice in this example that Mercurial printed the names of the files +%it added, whereas it didn't do so when we added the file named +%\filename{a} in the earlier example. + +Mercurialの全てのコマンドは,引数としてディレクトリ名を渡すと,ディレクト +リの内の全てのファイルとサブディレクトリに対する操作であると解釈するため +便利である. \interaction{daily.files.add-dir} -Notice in this example that Mercurial printed the names of the files -it added, whereas it didn't do so when we added the file named -\filename{a} in the earlier example. +この例ではMercurialは追加したファイル名を表示しているが,前の例で +\filename{a}という名前のファイルを追加した際には表示していなかった点に注 +意されたい. -What's going on is that in the former case, we explicitly named the -file to add on the command line, so the assumption that Mercurial -makes in such cases is that you know what you were doing, and it -doesn't print any output. +%What's going on is that in the former case, we explicitly named the +%file to add on the command line, so the assumption that Mercurial +%makes in such cases is that you know what you were doing, and it +%doesn't print any output. + +前の例ではコマンドラインでどのファイルを追加するのかを明示的に指定したた +め,Mercurialはユーザが何をしようとしているのか分かっていると推定して何も +表示しなかった. -However, when we \emph{imply} the names of files by giving the name of -a directory, Mercurial takes the extra step of printing the name of -each file that it does something with. This makes it more clear what -is happening, and reduces the likelihood of a silent and nasty -surprise. This behaviour is common to most Mercurial commands. +%However, when we \emph{imply} the names of files by giving the name of +%a directory, Mercurial takes the extra step of printing the name of +%each file that it does something with. This makes it more clear what +%is happening, and reduces the likelihood of a silent and nasty +%surprise. This behaviour is common to most Mercurial commands. + +しかしディレクトリ名を与えることでファイル名を暗黙的に与えた場合、 +Mercurialは関連するファイルの名前を1つずつ表示する追加のステップを踏む. +これによって何が起こっているのか理解しやすくすると共に,沈黙裏に厄介な問 +題が起こる可能性を減らしている.この挙動はMercurialの大半のコマンドに共 +通している. %\subsection{Aside: Mercurial tracks files, not directories} -\subsection{こぼれ話: Mercurialはディレクトリではなくファイルを追跡する} +\subsection{余談: Mercurialはディレクトリではなくファイルを追跡する} -Mercurial does not track directory information. Instead, it tracks -the path to a file. Before creating a file, it first creates any -missing directory components of the path. After it deletes a file, it -then deletes any empty directories that were in the deleted file's -path. This sounds like a trivial distinction, but it has one minor -practical consequence: it is not possible to represent a completely -empty directory in Mercurial. +%Mercurial does not track directory information. Instead, it tracks +%the path to a file. Before creating a file, it first creates any +%missing directory components of the path. After it deletes a file, it +%then deletes any empty directories that were in the deleted file's +%path. This sounds like a trivial distinction, but it has one minor +%practical consequence: it is not possible to represent a completely +%empty directory in Mercurial. + +Mercurialはディレクトリ情報を追跡しない.その代わり,ファイルへのパスを追 +跡している.ファイルを作成する際には,まずパスのディレクトリ部分を補完す +る.ファイルを消去した後は,ファイルの含まれていた空のディレクトリを全て +消去する.これは当然の挙動のように見えるが,実際上は小さな問題を引き起こ +す.すなわち,Mercurialは完全に空のディレクトリを表現することができないの +である. -Empty directories are rarely useful, and there are unintrusive -workarounds that you can use to achieve an appropriate effect. The -developers of Mercurial thus felt that the complexity that would be -required to manage empty directories was not worth the limited benefit -this feature would bring. +%Empty directories are rarely useful, and there are unintrusive +%workarounds that you can use to achieve an appropriate effect. The +%developers of Mercurial thus felt that the complexity that would be +%required to manage empty directories was not worth the limited benefit +%this feature would bring. + +空のディレクトリが有用であることは滅多にないが,適当なワークアラウンドと +して,リポジトリの動きを妨げない方法が存在する. +Mercurialの開発者たちは,空のディレクトリを表現するために加わる複雑さは,そ +の機能に見合わないと考えた. -If you need an empty directory in your repository, there are a few -ways to achieve this. One is to create a directory, then \hgcmd{add} a -``hidden'' file to that directory. On Unix-like systems, any file -name that begins with a period (``\texttt{.}'') is treated as hidden -by most commands and GUI tools. This approach is illustrated in -figure~\ref{ex:daily:hidden}. +%If you need an empty directory in your repository, there are a few +%ways to achieve this. One is to create a directory, then \hgcmd{add} a +%``hidden'' file to that directory. On Unix-like systems, any file +%name that begins with a period (``\texttt{.}'') is treated as hidden +%by most commands and GUI tools. This approach is illustrated in +%figure~\ref{ex:daily:hidden}. + +リポジトリに空のディレクトリが必要な場合,これを実現する方法がいくつかあ +る.1つ目は,まずディレクトリを作成し,隠しファイルをこのディレクトリ内に +\hgcmd{add}する.Unix系システムでは,ピリオド(``\texttt{.}'')で始まるファ +イルは大半のコマンドとGUIツールで隠しファイルとして取り扱われる. +詳細については図~\ref{ex:daily:hidden}を参照されたい. \begin{figure}[ht] \interaction{daily.files.hidden} - \caption{Simulating an empty directory using a hidden file} +% \caption{Simulating an empty directory using a hidden file} + \caption{隠しファイルを使って空のディレクトリをシミュレートする} \label{ex:daily:hidden} \end{figure} -Another way to tackle a need for an empty directory is to simply -create one in your automated build scripts before they will need it. +%Another way to tackle a need for an empty directory is to simply +%create one in your automated build scripts before they will need it. + +空のディレクトリを扱う別の方法には,自動ビルドスクリプトの中で,必要になる +前に作成することがある. %\section{How to stop tracking a file} \section{ファイル追跡の停止} diff -r 5530934319b8 -r beab196f78da ja/hook.tex --- a/ja/hook.tex Fri Jan 09 23:05:26 2009 +0900 +++ b/ja/hook.tex Thu Jan 15 16:34:43 2009 +0900 @@ -442,123 +442,200 @@ \section{フックの使用法} \label{sec:hook:simple} -It is easy to write a Mercurial hook. Let's start with a hook that -runs when you finish a \hgcmd{commit}, and simply prints the hash of -the changeset you just created. The hook is called \hook{commit}. +%It is easy to write a Mercurial hook. Let's start with a hook that +%runs when you finish a \hgcmd{commit}, and simply prints the hash of +%the changeset you just created. The hook is called \hook{commit}. + +Mercurialフックを書くのは容易い.ここでは\hgcmd{commit}コマンドが終了し +た際に,作成されたチェンジセットのハッシュ値を表示するくフックを書いてみ +よう.このフックを\hook{commit}と呼ぶことにする. \begin{figure}[ht] \interaction{hook.simple.init} - \caption{A simple hook that runs when a changeset is committed} +% \caption{A simple hook that runs when a changeset is committed} + \caption{チェンジセットがコミットされた時に動作する単純なフック} \label{ex:hook:init} \end{figure} -All hooks follow the pattern in example~\ref{ex:hook:init}. You add -an entry to the \rcsection{hooks} section of your \hgrc\. On the left -is the name of the event to trigger on; on the right is the action to -take. As you can see, you can run an arbitrary shell command in a -hook. Mercurial passes extra information to the hook using -environment variables (look for \envar{HG\_NODE} in the example). +%All hooks follow the pattern in example~\ref{ex:hook:init}. You add +%an entry to the \rcsection{hooks} section of your \hgrc\. On the left +%is the name of the event to trigger on; on the right is the action to +%take. As you can see, you can run an arbitrary shell command in a +%hook. Mercurial passes extra information to the hook using +%environment variables (look for \envar{HG\_NODE} in the example). + +全てのフックは例~\ref{ex:hook:init}と同じパターンになる. \hgrc ファイルの +\rcsection{hooks}セクションにエントリを追加する.左辺にトリガーとなるベン +トを記述し,右辺に対応するアクションを記述する.例に示した通り,フックに +は任意のシェルコマンドを書くことができる.環境変数を設定することで +Mercurialからフックに追加の情報を渡すことができる.(例の +\envar{HG\_NODE}を参照.) %\subsection{Performing multiple actions per event} \subsection{1つのイベントに複数のアクションを行う} -Quite often, you will want to define more than one hook for a -particular kind of event, as shown in example~\ref{ex:hook:ext}. -Mercurial lets you do this by adding an \emph{extension} to the end of -a hook's name. You extend a hook's name by giving the name of the -hook, followed by a full stop (the ``\texttt{.}'' character), followed -by some more text of your choosing. For example, Mercurial will run -both \texttt{commit.foo} and \texttt{commit.bar} when the -\texttt{commit} event occurs. +%Quite often, you will want to define more than one hook for a +%particular kind of event, as shown in example~\ref{ex:hook:ext}. +%Mercurial lets you do this by adding an \emph{extension} to the end of +%a hook's name. You extend a hook's name by giving the name of the +%hook, followed by a full stop (the ``\texttt{.}'' character), followed +%by some more text of your choosing. For example, Mercurial will run +%both \texttt{commit.foo} and \texttt{commit.bar} when the +%\texttt{commit} event occurs. + +例~\ref{ex:hook:ext}に示したように,特定のイベントに2つ以上のフックを定義 +することが必要になることが多いだろう. Mercurialでは,フック名の最後に +\emph{拡張子}を追加することでこれが可能になる.拡張子を付けるに +は,``\texttt{.}'' 文字と,これに続く何文字かからなる名前をフックにつけれ +ばよい.例えばMercurialは\texttt{commit}イベントが起きた時に +\texttt{commit.foo}と\texttt{commit.bar}フックの両方を呼び出す. \begin{figure}[ht] \interaction{hook.simple.ext} - \caption{Defining a second \hook{commit} hook} +% \caption{Defining a second \hook{commit} hook} + \caption{2番目の\hook{commit}フックを定義する} \label{ex:hook:ext} \end{figure} -To give a well-defined order of execution when there are multiple -hooks defined for an event, Mercurial sorts hooks by extension, and -executes the hook commands in this sorted order. In the above -example, it will execute \texttt{commit.bar} before -\texttt{commit.foo}, and \texttt{commit} before both. +%To give a well-defined order of execution when there are multiple +%hooks defined for an event, Mercurial sorts hooks by extension, and +%executes the hook commands in this sorted order. In the above +%example, it will execute \texttt{commit.bar} before +%\texttt{commit.foo}, and \texttt{commit} before both. + +1つのイベントに複数のフックが定義されている時,Mercurialはフックを拡張子 +でソートし,ソートされた順序に従ってフックを実行する.上記の例では +\texttt{commit},\texttt{commit.bar},\texttt{commit.foo}の順に実行する. -It is a good idea to use a somewhat descriptive extension when you -define a new hook. This will help you to remember what the hook was -for. If the hook fails, you'll get an error message that contains the -hook name and extension, so using a descriptive extension could give -you an immediate hint as to why the hook failed (see -section~\ref{sec:hook:perm} for an example). +%It is a good idea to use a somewhat descriptive extension when you +%define a new hook. This will help you to remember what the hook was +%for. If the hook fails, you'll get an error message that contains the +%hook name and extension, so using a descriptive extension could give +%you an immediate hint as to why the hook failed (see +%section~\ref{sec:hook:perm} for an example). + +新しいフックを定義する時に,内容を説明するような拡張子を付けるのはよい考 +えである.こうすることによって,フックの目的が何なのかを覚えやすくなる. +フックが失敗した場合,エラーメッセージにはフック名と拡張子が含まれる.説 +明的な拡張子はフックが失敗した理由を知るよい手がかりとなる.(例 +は~\ref{sec:hook:perm}を参照のこと.) %\subsection{Controlling whether an activity can proceed} \subsection{動作が進行できるかどうか制御する} \label{sec:hook:perm} -In our earlier examples, we used the \hook{commit} hook, which is -run after a commit has completed. This is one of several Mercurial -hooks that run after an activity finishes. Such hooks have no way of -influencing the activity itself. +%In our earlier examples, we used the \hook{commit} hook, which is +%run after a commit has completed. This is one of several Mercurial +%hooks that run after an activity finishes. Such hooks have no way of +%influencing the activity itself. + +前の例ではコミットが完了した後に実行される\hook{commit}フックを用いた.こ +れはMercurialフックのうち,動作が終了した後に実行されるもののうちの1つで +ある.このようなフックは,Mercurialの動作そのものに影響を及ぼさない. -Mercurial defines a number of events that occur before an activity -starts; or after it starts, but before it finishes. Hooks that -trigger on these events have the added ability to choose whether the -activity can continue, or will abort. +%Mercurial defines a number of events that occur before an activity +%starts; or after it starts, but before it finishes. Hooks that +%trigger on these events have the added ability to choose whether the +%activity can continue, or will abort. + +Mercurialは動作の開始前や,開始後終了するまでの間に発生するイベントを多数 +定義している.これらのイベントでトリガーされるフックは,動作を続行するか +中断するか決めることができる. -The \hook{pretxncommit} hook runs after a commit has all but -completed. In other words, the metadata representing the changeset -has been written out to disk, but the transaction has not yet been -allowed to complete. The \hook{pretxncommit} hook has the ability to -decide whether the transaction can complete, or must be rolled back. +%The \hook{pretxncommit} hook runs after a commit has all but +%completed. In other words, the metadata representing the changeset +%has been written out to disk, but the transaction has not yet been +%allowed to complete. The \hook{pretxncommit} hook has the ability to +%decide whether the transaction can complete, or must be rolled back. + +\hook{pretxncommit}フックはコミット後,コミットの完了前に呼び出される. +言い替えると,チェンジセットを示すメタデータがディスクに書き込まれた後 +で,トランザクションが完了する前に呼び出される. +\hook{pretxncommit}フックはトランザクションを完了するか,ロールバックす +るかを決定する機能がある. -If the \hook{pretxncommit} hook exits with a status code of zero, the -transaction is allowed to complete; the commit finishes; and the -\hook{commit} hook is run. If the \hook{pretxncommit} hook exits with -a non-zero status code, the transaction is rolled back; the metadata -representing the changeset is erased; and the \hook{commit} hook is -not run. +%If the \hook{pretxncommit} hook exits with a status code of zero, the +%transaction is allowed to complete; the commit finishes; and the +%\hook{commit} hook is run. If the \hook{pretxncommit} hook exits with +%a non-zero status code, the transaction is rolled back; the metadata +%representing the changeset is erased; and the \hook{commit} hook is +%not run. + +\hook{pretxncommit}フックがステータスコード0で終了するとトランザクション +は完了することができ,コミットが終了し,\hook{commit}フックが呼び出される. +\hook{pretxncommit}フックが非0のステータスコードで終了すると,トランザク +ションはロールバックされ,チェンジセットを示すメタデータは消去される.こ +の場合\hook{commit}フックは呼び出されない. \begin{figure}[ht] \interaction{hook.simple.pretxncommit} - \caption{Using the \hook{pretxncommit} hook to control commits} +% \caption{Using the \hook{pretxncommit} hook to control commits} + \caption{コミットを制御するために\hook{pretxncommit}フックを使用する} \label{ex:hook:pretxncommit} \end{figure} -The hook in example~\ref{ex:hook:pretxncommit} checks that a commit -comment contains a bug ID. If it does, the commit can complete. If -not, the commit is rolled back. +%The hook in example~\ref{ex:hook:pretxncommit} checks that a commit +%comment contains a bug ID. If it does, the commit can complete. If +%not, the commit is rolled back. + +~\ref{ex:hook:pretxncommit}はコミットコメントがバグIDを含むかをチェック +する.もし含まれればコミットは完了する.含まない場合はコミットはロールバッ +クされる. %\section{Writing your own hooks} \section{オリジナルのフックを書く} -When you are writing a hook, you might find it useful to run Mercurial -either with the \hggopt{-v} option, or the \rcitem{ui}{verbose} config -item set to ``true''. When you do so, Mercurial will print a message -before it calls each hook. +%When you are writing a hook, you might find it useful to run Mercurial +%either with the \hggopt{-v} option, or the \rcitem{ui}{verbose} config +%item set to ``true''. When you do so, Mercurial will print a message +%before it calls each hook. + +フックを書く場合,Mercurialを\hggopt{-v}オプションを付けたり +\rcitem{ui}{verbose}設定項目を``true''に設定することは役に立つ.この場 +合,Mercurialは各々のフックを呼ぶ前にメッセージを表示する. %\subsection{Choosing how your hook should run} \subsection{フックがの動作方法を選ぶ} \label{sec:hook:lang} -You can write a hook either as a normal program---typically a shell -script---or as a Python function that is executed within the Mercurial -process. +%You can write a hook either as a normal program---typically a shell +%script---or as a Python function that is executed within the Mercurial +%process. + +フックはシェルスクリプトのような通常のプログラムとして書くこともできるし, +Mercurialプロセスの内部で呼び出されるPython関数として書くこともできる. -Writing a hook as an external program has the advantage that it -requires no knowledge of Mercurial's internals. You can call normal -Mercurial commands to get any added information you need. The -trade-off is that external hooks are slower than in-process hooks. +%Writing a hook as an external program has the advantage that it +%requires no knowledge of Mercurial's internals. You can call normal +%Mercurial commands to get any added information you need. The +%trade-off is that external hooks are slower than in-process hooks. + +フックを外部プログラムとして書く利点はMercurialの内部動作を知らなくてもフッ +クが書けることである.必要な追加の情報を得るために通常のMercurialコマンド +を呼び出すことができる.外部フックはプロセス内フックよりも低速なのがトレー +ドオフである. -An in-process Python hook has complete access to the Mercurial API, -and does not ``shell out'' to another process, so it is inherently -faster than an external hook. It is also easier to obtain much of the -information that a hook requires by using the Mercurial API than by -running Mercurial commands. +%An in-process Python hook has complete access to the Mercurial API, +%and does not ``shell out'' to another process, so it is inherently +%faster than an external hook. It is also easier to obtain much of the +%information that a hook requires by using the Mercurial API than by +%running Mercurial commands. + +Pythonプロセス内フックはMercurial APIへの完全なアクセスが可能である. +他のプロセスを生成することがないため,本質的に外部フックよりも高速である. +フックが必要とする情報の大半は,Mercurialコマンドを実行するよりも +Mercurial APIを使って集める方が容易い. -If you are comfortable with Python, or require high performance, -writing your hooks in Python may be a good choice. However, when you -have a straightforward hook to write and you don't need to care about -performance (probably the majority of hooks), a shell script is -perfectly fine. +%If you are comfortable with Python, or require high performance, +%writing your hooks in Python may be a good choice. However, when you +%have a straightforward hook to write and you don't need to care about +%performance (probably the majority of hooks), a shell script is +%perfectly fine. + +Pythonを使い慣れていたり,高い性能が必要ならば,フックをPythonで書くのが +よいだろう.しかし書こうとするのが単純明解なフックで,(多くのフックがそ +うであるように)性能には特に関心がない場合,シェルスクリプトとして書いて +も全く問題ない. %\subsection{Hook parameters} \subsection{フックパラメータ}