CakeFest 2024: The Official CakePHP Conference

svn_cat

(PECL svn >= 0.1.0)

svn_catリポジトリ内のファイルの内容を返す

説明

svn_cat(string $repos_url, int $revision_no = ?): string

リポジトリ内のファイルを指す URL repos_url の中身を返します。オプションでリビジョン番号 revision_no を指定します。

パラメータ

repos_url

リポジトリ内のアイテムへのパスを表す URL 文字列。

revision_no

取得したいリビジョン番号を表す整数値。デフォルトは HEAD リビジョン。

戻り値

成功した場合にアイテムの内容を表す文字列、失敗した場合に false を返します。

例1 基本的な例

この例は、あるファイルのリビジョン 20 の内容を取得します。

<?php
$contents
= svn_cat('http://www.example.com/svnroot/calc/gui.c', 28)
?>

注意

警告

この関数は、 実験的 なものです。この関数の動作・ 名前・その他ドキュメントに書かれている事項は、予告なく、将来的な PHP のリリースにおいて変更される可能性があります。 この関数は自己責任で使用してください。

add a note

User Contributed Notes 2 notes

up
1
Adam
11 years ago
There is a difference how svn cat works for deleted files. For deleted file commandline `svn cat -r xxx <full_url>` will give error, but 'svn cat <full_url>@xxx` will cat file from the past.
Unfortunately this method will not cat deleted file.
up
0
colm
10 years ago
Just to add to Adam's comment, when retrieving a file contents I found I got the best results using the same revision in both places every time; ie. as follows:

<?php
svn_cat
($url.'@'.$revision, $revision);
?>

The one appended to the URL is the peg revision, and the one in the second paramer is the operative revision.

This seems to cover all the bases.
To Top