Difference between revisions of "Creating A Patch/ja"

From Free Pascal wiki
Jump to navigationJump to search
Line 3: Line 3:
 
{{Japanese Menu}}
 
{{Japanese Menu}}
  
==導入==
+
FPC や Lazarus を改良したコードを提出する場合は、開発者がマージしやすいようにパッチで提出するようにしてください。
ここでは、LazarusをSVNから入手しているものと仮定します。[[Getting Lazarus#Via SVN| Getting Lazarus Via SVN]]
 
  
コマンドを開くか、cmdプロンプトなどで、Lazarusのソースのあるディレクトリに移動してください。
+
例外事項:
 +
# 翻訳用の .po ファイルはパッチではなくファイルをそのまま提出してください
 +
# 新規に作られたファイルは、ファイルをそのまま提出して、設置場所を明記してください
  
'''Windowsでの導入:'''
+
__TOC__
 +
==必要なもの==
  
Lazarusの開発環境を C:\lazarus でSVNチェックアウトしたと仮定します。
+
You need the trunk/development version of Lazarus. You can get Lazarus using either SVN or Git.
 +
* SVN: [[Getting Lazarus#Getting Lazarus SVN development version | Getting Lazarus SVN development version]]. This is the native repository.
 +
* Git: [[git mirrors | Git mirrors]] and [[Lazarus git-svn | Lazarus Git-svn]]. Lazarus is mirrored in GitHub. Git can also use SVN server directly with git-svn link.
  
# MS-DOSプロンプトを開いてください。
+
==プラットフォームで異なるところ==
# c: {enterを押す}
+
The instructions later assume you have opened a command prompt and moved (cd) to the directory of the repository. Here are the details :
# cd \lazarus {enterを押す}
 
# svn diff > mypatch.dif {enterを押す}
 
  
'''Linux/BSD、その他での導入:'''
+
===Windows===
 +
チェックアウトした Lazarus が C:\lazarus にある場合:
  
あなたがLazarusを $HOME/lazarus でSVNチェックアウトしたと仮定します。
+
# コマンドプロンプトを開きます(例:「ファイル名を指定して実行」で '''cmd.exe''' と入力)
 +
# <syntaxhighlight lang="dos">c:</syntaxhighlight>
 +
# <syntaxhighlight lang="dos">cd \lazarus</syntaxhighlight>
  
# 好きなターミナルプログラムを開いて下さい。
+
{{Note| If using [http://tortoisesvn.tigris.org/ TortoiseSVN], you can select the folder where Lazarus was checked out in Windows Explorer then right click to select TortoiseSVN->Create Patch... }}
# cd $HOME {enterを押す}
 
# cd lazarus {enterを押す}
 
# svn diff > mypatch.diff {enterを押す}
 
  
 +
See also [[TortoiseSvn#Troubleshooting]] if you have problems.
  
''注:私はなにかそこにありそうもないものがないかどうか、ファイルを見わたすのも好きです。''
+
===Unix 系===
 +
チェックアウトした Lazarus が ~/lazarus にある場合:
  
パッチを適用するのにおすすめの方法は、[http://bugs.freepascal.org bug tracker]による方法です。もし、あなたのパッチを修正したという報告があれば、それを使います。そうでない場合に、新しい問題点の項目を作成します。ファイルをアップロードして、問題点をそれに添付します。
+
# 端末を開きます
 +
# <syntaxhighlight lang="bash">cd ~/lazarus</syntaxhighlight>
  
別の方法として、あなたの作ったパッチをzipやgzipで圧縮して、Lazarusメーリングリストにemailすることです。(最大40kBです。)もしくは、パッチ専用メール[mailto:patch@lazarus.dommelstein.net patch@lazarus.dommelstein.net]へ送って下さい。
+
==SVN を使ってパッチを作成==
 +
<syntaxhighlight lang="bash">svn diff > mypatch.diff</syntaxhighlight>
 +
こうして作られたパッチには、SVN リポジトリのすべての変更が含まれます。
  
これで全てです。
+
You can also define the individual files, to make sure no garbage is included, eg. :
 +
<syntaxhighlight lang="bash">svn diff ide/main.pp ideintf/objectinspector.pp > mypatch.diff</syntaxhighlight>
  
== トラブルの解消 ==
+
==Git を使ってパッチを作成==
ほとんどの場合はWindowsだけでなく、他のプラットホームにも当てはまります。
+
First, develop your code in a separate branch!
 +
While your development branch is active, you can create patches of all your local commits by :
 +
<syntaxhighlight lang="bash">git format-patch master</syntaxhighlight>
 +
It creates a set of patches named like "0001-CommitMsg.patch", "0002-CommitMsg.patch" and so on.
  
'''"svn command not found"(あるいは、似たような)エラーがでたとき'''
+
If you want all the changes in one patch, either combine the commits using "git rebase -i ..." or use the following command :
 +
<syntaxhighlight lang="bash">git format-patch master --stdout > mypatch.patch</syntaxhighlight>
  
ほとんどの場合、svn.exeが環境変数のPATHにないからでしょう。次のステップでこの問題を解決できます。
+
{{Note| "master" branch follows the SVN trunk by default when using git-svn link.
 +
However the mirror repository in GitHub uses "upstream" branch instead.
 +
Then you must replace "master" with "upstream" in the above commands.}}
  
# スタートメニューのFind Files機能をつかってsvn.exeをおきます。
+
==パッチの提出==
# svn.exeを一旦置いたら、PATHにそのディレクトリを必ず追加します。
+
パッチを提出する前に、それで問題ないか入念な確認をお願いいたします。
たとえば: コマンドプロンプトから次のように打ってください:
 
  set PATH=%PATH%;"C:\Program Files\TortoiseSVN\"
 
  
''注意: あなたの環境でのsvn.exeがはいっているディレクトリは、この文書とは違うかもしれません。これはあくまでもサンプルです。''
+
[http://bugs.freepascal.org bug tracker] を通してパッチを提出するのがお勧めの方法です。詳しくは、[[How do I create a bug report/ja|不具合報告のやり方]]をご覧になってください。bug tracker に報告されている課題を修正するパッチであればその課題項目へ、そうでない場合は bug tracker 上に新しく課題項目を作成しそこへパッチを提出します。課題項目に対してアップロードできたら提出完了です。
  
次はオプション的な事項です。
+
==フォークした Git リポジトリを直接使用する==
 +
It is possible to use Git in a distributed manner also for Lazarus development.
 +
At least developers JuhaManninen and Alexander Klenin ("Ask") are ready to accept code in a Git repository.
  
'''これを恒久的にするには'''
+
In practice the repository must be forked from the Lazarus mirror in GitHub.
 +
The code must be in a separate branch and rebased against "upstream" branch.
 +
This is not tested yet, we can add more details here when somebody actually forks the repo and creates code.
  
Windows98以前のWindowsOSでは,上に書いたようなことを、C:\autoexec.batの終わりのほうに書きます。
+
The limitation of this model is that the code must belong to the area of expertise of the developers working with Git.
 +
If the code is outside that area, you can still use Git but you must create patches and send them to bug tracker.
  
Windows2000 以降では、ディレクトリをパスに加えるには、:
+
==パッチの適用==
 +
ここでは、他のだれかが作ったパッチをお使いになられているローカルリポジトリに適用する方法について説明します。以下のように --dry-run スイッチを使うことでパッチの影響テストが行えます。
 +
<syntaxhighlight lang="bash">patch --dry-run < somepatch.diff</syntaxhighlight>
 +
The output of the patch program will be identical to the actual patching, only it does not alter the sourcecode files. Very handy for testing, without the possibility to screw up your source.
  
# "マイコンピュータ"を右クリックします。
+
==="svn diff" で作られたパッチ===
# "プロパティ"を選択します。
+
To do the final patching, use the following commandline:
# "詳細設定" タブを選択します。
+
<syntaxhighlight lang="bash">patch < somepatch.diff</syntaxhighlight>
# "環境変数" ボタンを押します。
+
これで動作しないのは、お使いになられている環境がパッチが作られた環境と異なっているからです。その場合は、以下のようにしてパス情報をすべて引き出すように指定してください。
# "システム変数"の"パス"の最後に、"C:\Program Files\TortoiseSVN\" を加えます。
+
<syntaxhighlight lang="bash">patch -p0 < somepatch.diff</syntaxhighlight>
  
''注意: あなたの環境でのsvn.exeがはいっているディレクトリは、この文書とは違うかもしれません。これはあくまでもサンプルです。''
+
Windows 用の GUI バージョン管理ツールでもこれらのパッチは適用できます。
  
==パッチを適用する==
+
==="git format-patch" で作られたパッチ===
パッチを適用するのは簡単です。次のように、--dry-runトグルスイッチを使うことで、パッチをテストすることができます。:
+
====Git====
 +
Git にパッチを適用するには以下のようにします。
 +
<syntaxhighlight lang="bash">git apply 0001-gitpatch.patch</syntaxhighlight>
  
 +
====patch コマンド====
 +
The "patch" command now supports git format patches with -p1. This is tested with patch v.2.6.1 on Linux, old versions may not support it.
  
  patch --dry-run < mypatch.diff
+
<syntaxhighlight lang="bash">patch -p1 < 0001-gitpatch.patch</syntaxhighlight>
  
 +
"patch" コマンドは Windows でも利用できます。また、GUI ツールにも同じ機能があります。
  
パッチプログラムの出力は、実際のパッチと同じになるでしょう。それだけで、ソースコードファイルを変更する必要はありません。ソースをあれこれする必要はなく、テストは簡単です。
+
====TortoiseMerge====
 +
TortoiseMerge supports the Git format patch without problems.
 +
It is installed together with Tortoise SVN but is not integrated in explorer. It must be opened from the Start menu.
  
最終的なパッチをあてるには、コマンドラインから次のようにします。
+
ToDo: add more GUI tools that support Git format patches
  
 +
===トラブルシューティング===
 +
Finally, patches may have a Unix/Linux line ending (LF) while your local file has Windows (CR+LF) line endings or vice versa. You'll have to convert the patch file before applying on Windows at least, as the supplied patch.exe is picky about line endings.
  
  patch < mypatch.diff
+
On Windows, the patch.exe supplied with FPC/Lazarus is very picky; you may have better luck with the patch.exe supplied by Git:
 
+
<syntaxhighlight lang="dos">"C:\Program Files (x86)\Git\bin\patch.exe" -p0 < mypatch.diff</syntaxhighlight>
もしくは、セパレータを修正するなら:
+
... or the svn patch command available sinds SVN 1.7.
 
 
  patch -p0 < mypatch.diff
 
  
 +
==関連項目==
 +
* [[How do I create a bug report/ja|不具合報告のやり方]] 不具合報告の一般的な情報
 +
* [[Tips on writing bug reports]] detailed information on what should be covered in a bug report.
 +
* [[Database bug reporting]] Specific info and sample programs for database bugs
  
 
[[Category:Debugging/ja]]
 
[[Category:Debugging/ja]]
 +
[[Category:Lazarus/ja]]
 +
[[Category:FPC/ja]]

Revision as of 12:21, 19 December 2013

Deutsch (de) English (en) español (es) français (fr) 日本語 (ja) português (pt) русский (ru) slovenčina (sk)

日本語版メニュー
メインページ - Lazarus Documentation日本語版 - 翻訳ノート - 日本語障害情報

FPC や Lazarus を改良したコードを提出する場合は、開発者がマージしやすいようにパッチで提出するようにしてください。

例外事項:

  1. 翻訳用の .po ファイルはパッチではなくファイルをそのまま提出してください
  2. 新規に作られたファイルは、ファイルをそのまま提出して、設置場所を明記してください

必要なもの

You need the trunk/development version of Lazarus. You can get Lazarus using either SVN or Git.

プラットフォームで異なるところ

The instructions later assume you have opened a command prompt and moved (cd) to the directory of the repository. Here are the details :

Windows

チェックアウトした Lazarus が C:\lazarus にある場合:

  1. コマンドプロンプトを開きます(例:「ファイル名を指定して実行」で cmd.exe と入力)
  2. c:
    
  3. cd \lazarus
    
Light bulb  Note: If using TortoiseSVN, you can select the folder where Lazarus was checked out in Windows Explorer then right click to select TortoiseSVN->Create Patch...

See also TortoiseSvn#Troubleshooting if you have problems.

Unix 系

チェックアウトした Lazarus が ~/lazarus にある場合:

  1. 端末を開きます
  2. cd ~/lazarus
    

SVN を使ってパッチを作成

svn diff > mypatch.diff

こうして作られたパッチには、SVN リポジトリのすべての変更が含まれます。

You can also define the individual files, to make sure no garbage is included, eg. :

svn diff ide/main.pp ideintf/objectinspector.pp > mypatch.diff

Git を使ってパッチを作成

First, develop your code in a separate branch! While your development branch is active, you can create patches of all your local commits by :

git format-patch master

It creates a set of patches named like "0001-CommitMsg.patch", "0002-CommitMsg.patch" and so on.

If you want all the changes in one patch, either combine the commits using "git rebase -i ..." or use the following command :

git format-patch master --stdout > mypatch.patch

Light bulb  Note: "master" branch follows the SVN trunk by default when using git-svn link. However the mirror repository in GitHub uses "upstream" branch instead.

Then you must replace "master" with "upstream" in the above commands.

パッチの提出

パッチを提出する前に、それで問題ないか入念な確認をお願いいたします。

bug tracker を通してパッチを提出するのがお勧めの方法です。詳しくは、不具合報告のやり方をご覧になってください。bug tracker に報告されている課題を修正するパッチであればその課題項目へ、そうでない場合は bug tracker 上に新しく課題項目を作成しそこへパッチを提出します。課題項目に対してアップロードできたら提出完了です。

フォークした Git リポジトリを直接使用する

It is possible to use Git in a distributed manner also for Lazarus development. At least developers JuhaManninen and Alexander Klenin ("Ask") are ready to accept code in a Git repository.

In practice the repository must be forked from the Lazarus mirror in GitHub. The code must be in a separate branch and rebased against "upstream" branch. This is not tested yet, we can add more details here when somebody actually forks the repo and creates code.

The limitation of this model is that the code must belong to the area of expertise of the developers working with Git. If the code is outside that area, you can still use Git but you must create patches and send them to bug tracker.

パッチの適用

ここでは、他のだれかが作ったパッチをお使いになられているローカルリポジトリに適用する方法について説明します。以下のように --dry-run スイッチを使うことでパッチの影響テストが行えます。

patch --dry-run < somepatch.diff

The output of the patch program will be identical to the actual patching, only it does not alter the sourcecode files. Very handy for testing, without the possibility to screw up your source.

"svn diff" で作られたパッチ

To do the final patching, use the following commandline:

patch < somepatch.diff

これで動作しないのは、お使いになられている環境がパッチが作られた環境と異なっているからです。その場合は、以下のようにしてパス情報をすべて引き出すように指定してください。

patch -p0 < somepatch.diff

Windows 用の GUI バージョン管理ツールでもこれらのパッチは適用できます。

"git format-patch" で作られたパッチ

Git

Git にパッチを適用するには以下のようにします。

git apply 0001-gitpatch.patch

patch コマンド

The "patch" command now supports git format patches with -p1. This is tested with patch v.2.6.1 on Linux, old versions may not support it.

patch -p1 < 0001-gitpatch.patch

"patch" コマンドは Windows でも利用できます。また、GUI ツールにも同じ機能があります。

TortoiseMerge

TortoiseMerge supports the Git format patch without problems. It is installed together with Tortoise SVN but is not integrated in explorer. It must be opened from the Start menu.

ToDo: add more GUI tools that support Git format patches

トラブルシューティング

Finally, patches may have a Unix/Linux line ending (LF) while your local file has Windows (CR+LF) line endings or vice versa. You'll have to convert the patch file before applying on Windows at least, as the supplied patch.exe is picky about line endings.

On Windows, the patch.exe supplied with FPC/Lazarus is very picky; you may have better luck with the patch.exe supplied by Git:

"C:\Program Files (x86)\Git\bin\patch.exe" -p0 < mypatch.diff

... or the svn patch command available sinds SVN 1.7.

関連項目