# HG changeset patch # User Yoshiki Yazawa # Date 1206952104 -32400 # Node ID b8791971ba654a7b1a18aae7b5401b454626975d # Parent 57fb4684b8e3019b4fd312bbc5e754d70d4aedfc more mq.tex diff -r 57fb4684b8e3 -r b8791971ba65 ja/mq.tex --- a/ja/mq.tex Mon Mar 31 05:33:05 2008 +0900 +++ b/ja/mq.tex Mon Mar 31 17:28:24 2008 +0900 @@ -753,60 +753,110 @@ \section{さらにパッチについて} \label{sec:mq:adv-patch} -MQ uses the GNU \command{patch} command to apply patches, so it's -helpful to know a few more detailed aspects of how \command{patch} -works, and about patches themselves. +%MQ uses the GNU \command{patch} command to apply patches, so it's +%helpful to know a few more detailed aspects of how \command{patch} +%works, and about patches themselves. + +MQはパッチの適用にGNUの\command{patch}コマンドを用いる.そのため, +\command{patch}の動作とパッチ自体についてより詳しく知っておくことは有用 +である. %\subsection{The strip count} \subsection{ストリップカウント} -If you look at the file headers in a patch, you will notice that the -pathnames usually have an extra component on the front that isn't -present in the actual path name. This is a holdover from the way that -people used to generate patches (people still do this, but it's -somewhat rare with modern revision control tools). +%If you look at the file headers in a patch, you will notice that the +%pathnames usually have an extra component on the front that isn't +%present in the actual path name. This is a holdover from the way that +%people used to generate patches (people still do this, but it's +%somewhat rare with modern revision control tools). + +パッチのファイルヘッダを見ると,パスネームの最初に追加の部分がついている +のに気づくはずだ.これは実際のパスネームには存在しないもので,パッチを生 +成する時の習慣からの遺物である.(多くの人がいまだこの方法を使っているが, +近代的なリビジョンコントロールツールではほとんど見られない.) -Alice would unpack a tarball, edit her files, then decide that she -wanted to create a patch. So she'd rename her working directory, -unpack the tarball again (hence the need for the rename), and use the -\cmdopt{diff}{-r} and \cmdopt{diff}{-N} options to \command{diff} to -recursively generate a patch between the unmodified directory and the -modified one. The result would be that the name of the unmodified -directory would be at the front of the left-hand path in every file -header, and the name of the modified directory would be at the front -of the right-hand path. +%Alice would unpack a tarball, edit her files, then decide that she +%wanted to create a patch. So she'd rename her working directory, +%unpack the tarball again (hence the need for the rename), and use the +%\cmdopt{diff}{-r} and \cmdopt{diff}{-N} options to \command{diff} to +%recursively generate a patch between the unmodified directory and the +%modified one. +%The result would be that the name of the unmodified +%directory would be at the front of the left-hand path in every file +%header, and the name of the modified directory would be at the front +%of the right-hand path. + +アリスがtarボールを解凍し,ファイルを編集し,パッチを作りたいと思っている +とする.彼女はワーキングディレクトリをリネームしてtarボールをもう一度解凍 +し(このためにリネームが必要だった),\command{diff}に\cmdopt{diff}{-r}と +\cmdopt{diff}{-N}オプションをつけて,元のままのディレクトリと変更したディ +レクトリの間で再帰的にパッチを生成するだろう.生成されたパッチでは,全て +のファイルヘッダで元のままのディレクトリの名前が左側のパスの先頭に,変更 +されたディレクトリの名前が右側のパスの先頭に現れる. -Since someone receiving a patch from the Alices of the net would be -unlikely to have unmodified and modified directories with exactly the -same names, the \command{patch} command has a \cmdopt{patch}{-p} -option that indicates the number of leading path name components to -strip when trying to apply a patch. This number is called the -\emph{strip count}. +%Since someone receiving a patch from the Alices of the net would be +%unlikely to have unmodified and modified directories with exactly the +%same names, the \command{patch} command has a \cmdopt{patch}{-p} +%option that indicates the number of leading path name components to +%strip when trying to apply a patch. This number is called the +%\emph{strip count}. + +ネット上のアリスたちからパッチを受け取った人は,変更なしのディレクトリと +変更されたディレクトリの両方をアリスと同じ名前で持っている可能性はまずな +い.\command{patch}コマンドには\cmdopt{patch}{-p}オプションがあり,パッ +チを適用する時にパスの要素を先頭からいくつ削るかを指定できる.この数は +\emph{ストリップカウント}と呼ばれる. -An option of ``\texttt{-p1}'' means ``use a strip count of one''. If -\command{patch} sees a file name \filename{foo/bar/baz} in a file -header, it will strip \filename{foo} and try to patch a file named -\filename{bar/baz}. (Strictly speaking, the strip count refers to the -number of \emph{path separators} (and the components that go with them -) to strip. A strip count of one will turn \filename{foo/bar} into -\filename{bar}, but \filename{/foo/bar} (notice the extra leading -slash) into \filename{foo/bar}.) +%An option of ``\texttt{-p1}'' means ``use a strip count of one''. If +%\command{patch} sees a file name \filename{foo/bar/baz} in a file +%header, it will strip \filename{foo} and try to patch a file named +%\filename{bar/baz}. (Strictly speaking, the strip count refers to the +%number of \emph{path separators} (and the components that go with them +%) to strip. A strip count of one will turn \filename{foo/bar} into +%\filename{bar}, but \filename{/foo/bar} (notice the extra leading +%slash) into \filename{foo/bar}.) -The ``standard'' strip count for patches is one; almost all patches -contain one leading path name component that needs to be stripped. -Mercurial's \hgcmd{diff} command generates path names in this form, -and the \hgcmd{import} command and MQ expect patches to have a strip -count of one. +オプション``\texttt{-p1}''は``ストリップカウント1を使う''という意味であ +る.もし\command{patch}がファイルヘッダに\filename{foo/bar/baz}を見つけ +た時は,\filename{foo}を落して\filename{bar/baz}という名前のファイルにパッ +チを試みる.(厳密に言うとストリップカウントは\emph{パスセパレータ}の数 +を参照している(結果として要素も参照される)ストリップカウント1は +\filename{foo/bar}を\filename{bar}に変える.また\filename{/foo/bar}(前 +に置かれたスラッシュに注意)は\filename{foo/bar}となる.) + +%The ``standard'' strip count for patches is one; almost all patches +%contain one leading path name component that needs to be stripped. +%Mercurial's \hgcmd{diff} command generates path names in this form, +%and the \hgcmd{import} command and MQ expect patches to have a strip +%count of one. + +パッチへの``標準的な''ストリップカウントは1である.ほとんど全てのパッチ +は取り除くべきパス要素を一つ持っている.Mercurialの\hgcmd{diff}コマンド +はパス名をこの形式で生成し,\hgcmd{import}コマンドとMQはストリップカウン +ト1を前提としている. If you receive a patch from someone that you want to add to your patch queue, and the patch needs a strip count other than one, you cannot just \hgxcmd{mq}{qimport} the patch, because \hgxcmd{mq}{qimport} does not yet -have a \texttt{-p} option (see~\bug{311}). Your best bet is to +have a \texttt{-p} option (see~\bug{311}). + +Your best bet is to \hgxcmd{mq}{qnew} a patch of your own, then use \cmdargs{patch}{-p\emph{N}} to apply their patch, followed by \hgcmd{addremove} to pick up any files added or removed by the patch, followed by \hgxcmd{mq}{qrefresh}. This complexity may become unnecessary; see~\bug{311} for details. +誰かからパッチを受け取り,パッチキューに追加しようとする時,パッチカウン +トが1以外であれば単に\hgxcmd{mq}{qimport}することはできない.これは +\hgxcmd{mq}{qimport}コマンドがまだ\texttt{-p}オプションを持っていないた +めだ(\bug{311}を参照). + +一番良さそうなのは,\hgxcmd{mq}{qnew}で新たにパッチを作り, +\cmdargs{patch}{-p\emph{N}}を実行して受け取ったパッチを適用した後, +パッチによって追加されたり削除されたファイルを\hgcmd{addremove}によって +ピックアップし,\hgxcmd{mq}{qrefresh}を実行することである.この複雑な手 +順は将来的には必要なくなるはずだ(\bug{311}を参照). + %\subsection{Strategies for applying a patch} \subsection{パッチ適用のための戦略} @@ -816,6 +866,9 @@ that was generated against an old version of a file, and apply it against a newer version of that file. +\command{patch}がhunkを適用するとき, + + First, \command{patch} tries an exact match, where the line numbers, the context, and the text to be modified must apply exactly. If it cannot make an exact match, it tries to find an exact match for the @@ -1319,8 +1372,11 @@ %\subsection{Merging part of one patch into another} \subsection{パッチの一部分を別のパッチへマージする} -Merging \emph{part} of one patch into another is more difficult than -combining entire patches. +%Merging \emph{part} of one patch into another is more difficult than +%combining entire patches. + +パッチの\emph{一部}を別のパッチへマージすることは,パッチを結合するより +は難しい. If you want to move changes to entire files, you can use \command{filterdiff}'s \cmdopt{filterdiff}{-i} and @@ -1332,6 +1388,9 @@ other patch), and you can simply \hgxcmd{mq}{qrefresh} the patch to drop the duplicate hunks. + + + If you have a patch that has multiple hunks modifying a file, and you only want to move a few of those hunks, the job becomes more messy, but you can still partly automate it. Use \cmdargs{lsdiff}{-nvv} to