Difference between revisions of "Creating A Patch/ja"

From Free Pascal wiki
Jump to navigationJump to search
Line 26: Line 26:
 
# <syntaxhighlight lang="dos">cd \lazarus</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... }}
+
{{Note|[http://tortoisesvn.tigris.org/ TortoiseSVN] をお使いでしたら、Windows エクスプローラ上の Lazarus をチェックアウトしたフォルダを選択し、右クリックから TortoiseSVN → パッチを作成 からでも行えます。}}
  
See also [[TortoiseSvn#Troubleshooting]] if you have problems.
+
問題がある場合は、[[TortoiseSvn#Troubleshooting]] もご覧になってください。
  
 
===Unix 系===
 
===Unix 系===
Line 40: Line 40:
 
こうして作られたパッチには、SVN リポジトリのすべての変更が含まれます。
 
こうして作られたパッチには、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>
 
<syntaxhighlight lang="bash">svn diff ide/main.pp ideintf/objectinspector.pp > mypatch.diff</syntaxhighlight>
  
Line 75: Line 75:
 
ここでは、他のだれかが作ったパッチをお使いになられているローカルリポジトリに適用する方法について説明します。以下のように --dry-run スイッチを使うことでパッチの影響テストが行えます。
 
ここでは、他のだれかが作ったパッチをお使いになられているローカルリポジトリに適用する方法について説明します。以下のように --dry-run スイッチを使うことでパッチの影響テストが行えます。
 
<syntaxhighlight lang="bash">patch --dry-run < somepatch.diff</syntaxhighlight>
 
<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" で作られたパッチ===
 
==="svn diff" で作られたパッチ===
To do the final patching, use the following commandline:
+
テストで問題なかったら、以下のコマンドを使ってパッチを適用します。
 
<syntaxhighlight lang="bash">patch < somepatch.diff</syntaxhighlight>
 
<syntaxhighlight lang="bash">patch < somepatch.diff</syntaxhighlight>
 
これで動作しないのは、お使いになられている環境がパッチが作られた環境と異なっているからです。その場合は、以下のようにしてパス情報をすべて引き出すように指定してください。
 
これで動作しないのは、お使いになられている環境がパッチが作られた環境と異なっているからです。その場合は、以下のようにしてパス情報をすべて引き出すように指定してください。
Line 91: Line 91:
  
 
====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 スイッチで git 書式にも対応しています。Linux 版の patch v.2.6.1 で動作確認しました。古いバージョンはおそらく対応していないでしょう。
  
 
<syntaxhighlight lang="bash">patch -p1 < 0001-gitpatch.patch</syntaxhighlight>
 
<syntaxhighlight lang="bash">patch -p1 < 0001-gitpatch.patch</syntaxhighlight>
  
"patch" コマンドは Windows でも利用できます。また、GUI ツールにも同じ機能があります。
+
patch コマンドは Windows でも利用できます。また、GUI ツールにも同じ機能があります。
  
 
====TortoiseMerge====
 
====TortoiseMerge====

Revision as of 14:22, 20 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: 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

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

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

"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 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.

関連項目