Difference between revisions of "Creating A Patch/ja"

From Free Pascal wiki
Jump to navigationJump to search
Line 17: Line 17:
  
 
==プラットフォームで異なるところ==
 
==プラットフォームで異なるところ==
The instructions later assume you have opened a command prompt and moved (cd) to the directory of the repository. Here are the details :
+
コマンドプロンプトを開いてリポジトリのあるディレクトリに移動 (cd) する部分が若干異なります。詳しくは以下に示します。
  
 
===Windows===
 
===Windows===
Line 47: Line 47:
 
While your development branch is active, you can create patches of all your local commits by :
 
While your development branch is active, you can create patches of all your local commits by :
 
<syntaxhighlight lang="bash">git format-patch master</syntaxhighlight>
 
<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.
+
"0001-CommitMsg.patch""0002-CommitMsg.patch" といった名前のファイルの組が作成されます。
  
If you want all the changes in one patch, either combine the commits using "git rebase -i ..." or use the following command :
+
1 つのパッチにすべての変更をまとめたいのであれば、"git rebase -i ..." を使ってコミットをまとめるか、以下のコマンドを使います。
 
<syntaxhighlight lang="bash">git format-patch master --stdout > mypatch.patch</syntaxhighlight>
 
<syntaxhighlight lang="bash">git format-patch master --stdout > mypatch.patch</syntaxhighlight>
  
{{Note| "master" branch follows the SVN trunk by default when using git-svn link.
+
{{Note| git-svn 連携を使用している場合、デフォルトでは "master" ブランチが SVN trunk を追従するようになっています。ですが、GitHub のミラーリポジトリではそうではなく "upstream" ブランチが使われています。上述のコマンドは "master" "upstream" に置き換えて使用してください。}}
However the mirror repository in GitHub uses "upstream" branch instead.
 
Then you must replace "master" with "upstream" in the above commands.}}
 
  
 
==パッチの提出==
 
==パッチの提出==
Line 98: Line 96:
  
 
====TortoiseMerge====
 
====TortoiseMerge====
TortoiseMerge supports the Git format patch without problems.
+
TortoiseMerge Git 書式のパッチも問題なく使用できます。Tortoise SVN をインストールすると TortoiseMerge もインストールされますが、エクスプローラの右クリックメニューには表示されません。スタートメニューから起動してください。(訳注:TortoiseMerge ずばりの名称は右クリックメニューには出ませんが、標準の設定であれば パッチを適用 とかで開かれものが TortoiseMerge です。)
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
+
ToDo:Git 書式のパッチをサポートする GUI ツールが他にもあるようでしたらここに追加してください
  
 
===トラブルシューティング===
 
===トラブルシューティング===
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.
+
パッチを適用する段階になって Unix/Linux の改行コード (LF) Windows の改行コード (CR+LF) が異なってうまくいかないことがあります。Windows 環境では patch.exe が改行コードの処理がいい加減なので、パッチ適用前にファイルを変換する必要があるでしょう。
  
On Windows, the patch.exe supplied with FPC/Lazarus is very picky; you may have better luck with the patch.exe supplied by Git:
+
Windows 版の FPC/Lazarus に付属している patch.exe はかなり使いづらいです。Git に付属している patch.exe の方がいいでしょう。
 
<syntaxhighlight lang="dos">"C:\Program Files (x86)\Git\bin\patch.exe" -p0 < mypatch.diff</syntaxhighlight>
 
<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.
+
SVN 1.7 以降でしたら SVN の patch コマンドも利用できます。
  
 
==関連項目==
 
==関連項目==

Revision as of 03:45, 22 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.

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

コマンドプロンプトを開いてリポジトリのあるディレクトリに移動 (cd) する部分が若干異なります。詳しくは以下に示します。

Windows

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

  1. コマンドプロンプトを開きます(例:「ファイル名を指定して実行」で cmd.exe と入力)
  2. c:
    
  3. cd \lazarus
    
Light bulb  Note: TortoiseSVN をお使いでしたら、Windows エクスプローラ上の Lazarus をチェックアウトしたフォルダを選択し、右クリックから TortoiseSVN → パッチを作成 からでも行えます。

問題がある場合は、TortoiseSvn#Troubleshooting もご覧になってください。

Unix 系

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

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

SVN を使ってパッチを作成

svn diff > mypatch.diff

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

個別にパッチを作りたい場合は、関係のないものが含まれないように以下のように行います。

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

"0001-CommitMsg.patch"、"0002-CommitMsg.patch" といった名前のファイルの組が作成されます。

1 つのパッチにすべての変更をまとめたいのであれば、"git rebase -i ..." を使ってコミットをまとめるか、以下のコマンドを使います。

git format-patch master --stdout > mypatch.patch
Light bulb  Note: git-svn 連携を使用している場合、デフォルトでは "master" ブランチが SVN の trunk を追従するようになっています。ですが、GitHub のミラーリポジトリではそうではなく "upstream" ブランチが使われています。上述のコマンドは "master" を "upstream" に置き換えて使用してください。

パッチの提出

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

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

このパッチテストの出力結果は実際に行われるパッチと同じものですが、ソースファイルを変更することはありません。かなり厳格なテストなので、お使いになられている環境のソースファイルが思いがけず乱されるということはほとんどありません。

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

テストで問題なかったら、以下のコマンドを使ってパッチを適用します。

patch < somepatch.diff

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

patch -p0 < somepatch.diff

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

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

Git

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

git apply 0001-gitpatch.patch

patch コマンド

patch コマンドは -p1 スイッチで git 書式にも対応しています。Linux 版の patch v.2.6.1 で動作確認しました。古いバージョンはおそらく対応していないでしょう。

patch -p1 < 0001-gitpatch.patch

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

TortoiseMerge

TortoiseMerge は Git 書式のパッチも問題なく使用できます。Tortoise SVN をインストールすると TortoiseMerge もインストールされますが、エクスプローラの右クリックメニューには表示されません。スタートメニューから起動してください。(訳注:TortoiseMerge ずばりの名称は右クリックメニューには出ませんが、標準の設定であれば パッチを適用 とかで開かれものが TortoiseMerge です。)

ToDo:Git 書式のパッチをサポートする GUI ツールが他にもあるようでしたらここに追加してください

トラブルシューティング

パッチを適用する段階になって Unix/Linux の改行コード (LF) と Windows の改行コード (CR+LF) が異なってうまくいかないことがあります。Windows 環境では patch.exe が改行コードの処理がいい加減なので、パッチ適用前にファイルを変換する必要があるでしょう。

Windows 版の FPC/Lazarus に付属している patch.exe はかなり使いづらいです。Git に付属している patch.exe の方がいいでしょう。

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

SVN 1.7 以降でしたら SVN の patch コマンドも利用できます。

関連項目