我可以在没有工作副本的情况下使用 PHP4 与 SVN 存储库交互吗?

发布于 2024-08-17 05:14:16 字数 515 浏览 10 评论 0原文

我想在 SVN 存储库上执行 SVN 操作(通过 HTTP,如果重要的话),而不需要工作副本。基本上,这是我想做的事情:

  1. 检查远程目录是否存在。

    • 如果该目录不存在,则创建它
  2. 检查存储库中是否存在文件

    1. 如果该文件不存在,则使用我的内容在存储库中创建一个新文件
      • 这必须使用我提供的作者姓名,而不是经过身份验证的 WebDAV 作者姓名(这就是 WebDAV 方法对我不起作用的原因)
    2. 如果该文件确实存在,请将其内容替换为我指定文件的内容。

我一直在尝试使用自动版本控制方法,但该方法要求我为 WebDAV 服务器设置身份验证,这在我的情况下不太理想。我可以使用 FS 操作(客户端是 SVN 1.6,因此浅工作副本 + 命令行可以工作),但这既慢又不优雅。

是否有一个库(必须可以从 PHP 4.4 开始使用!)可以实现我所描述的功能?

I would like to perform SVN operations on an SVN repository (over HTTP, if it matters) without requiring a working copy. Basically, here are the things I want to do:

  1. Check if a directory exists remotely.

    • If the directory does not exist, create it
  2. Check if a file exists in the repository

    1. if the file does not exist, create a new file in the repository with my content
      • This has to use an author name that I provide, not the authenticated WebDAV author (which is why the WebDAV approach doesn't work for me)
    2. If the file does exist, replace its contents with the contents of my specified file.

I have been trying to use the autoversioning approach, but that method requires me to set up authentication for the WebDAV server, which is less than ideal in my circumstance. I could use FS operations (the client is SVN 1.6, so shallow working copies + command line would work) but that's both slow and inelegant.

Is there a library (which MUST be useable from PHP 4.4!) that can do what I describe?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

空城仅有旧梦在 2024-08-24 05:14:16

根据我在 PHP 中使用 SVN 的一点点经验:如果您可以从 PHP 脚本通过命令行访问 svn 可执行文件,那就这样做吧。

它总是比协议的 PHP 实现更快,而且更可靠。

我尝试过的所有 PHP SVN 客户端都有缺陷、错误,或者完全不稳定。 (不过我不知道 PECL。)

From what little experience I have dabbling with SVN from PHP: If you have command line access from your PHP script to the svn executable, go that way.

It's always faster than a PHP implementation of the protocol, and more reliable.

All PHP SVN clients I've tried had flaws, bugs, or were altogether shaky. (I don't know the PECL one, though.)

〗斷ホ乔殘χμё〖 2024-08-24 05:14:16

查找 svn 命令行或 svn 扩展等效项:

检查远程目录是否存在。

svn info <URL>

如果目录不存在,则创建它

svn mkdir <URL>

检查存储库中是否存在文件

svn info <URL>

如果该文件不存在,则使用我的内容在存储库中创建一个新文件

如果没有工作副本,这个文件会更难。您可以创建一个临时文件,然后:

svn import /tmp/mytempfile <URL>

如果该文件确实存在,则将其内容替换为我指定的文件的内容。

svn delete <URL>

接下来,如果没有工作副本,则无法修改文件。请注意,这会导致 Subversion 的使用非常不理想。它旨在存储更改,而不是文件。我不建议删除/导入来更改几行文本。

这必须使用我提供的作者姓名,而不是经过身份验证的 WebDAV 作者姓名(这就是 WebDAV 方法对我不起作用的原因)

您无法使用 webdav 提供任意作者姓名,您可以通过 HTTP(S) 进行身份验证远程服务器,该名称用作作者。如果您需要其他名称,则需要在服务器上创建另一个用户,并授予该用户访问存储库的权限。

Find the svn commandline, or svn extension equivalents of:

check if a directory exists remotely.

svn info <URL>

If the directory does not exist, create it

svn mkdir <URL>

Check if a file exists in the repository

svn info <URL>

if the file does not exist, create a new file in the repository with my content

This one is harder without a working copy. You could create a tempfile and then:

svn import /tmp/mytempfile <URL>

If the file does exist, replace its contents with the contents of my specified file.

svn delete <URL>

followed by the above, you can't modify a file without a working copy. Note that this causes a very suboptimal use of Subversion. It's designed to store changes, not files. I wouldn't recommend a delete/import to change a few lines of text.

This has to use an author name that I provide, not the authenticated WebDAV author (which is why the WebDAV approach doesn't work for me)

You can't provide an arbitrary author name using webdav, you authenticate over HTTP(S) to the remote server, and that name is used as author. If you need another name, you need to create another user on the server, and give that user access to the repository.

是你 2024-08-24 05:14:16

您可以尝试这个课程: http://www.phpclasses.org/browse/package/ 4270.html

据说它从 PHP 3 开始工作......

You can try this class: http://www.phpclasses.org/browse/package/4270.html

It's supposedly working starting at PHP 3...

傲娇萝莉攻 2024-08-24 05:14:16

也许 PECL::svn 扩展 (手册) 可以吗?

对于最新版本,要求是:

PHP Version: PHP 4.0.0 or newer

似乎有些功能可以做你想做的事;例如:

  • svn_mkdir :在工作副本或存储库中创建目录。

但不确定这些功能是否可以满足您想要的一切...

Maybe the PECL::svn extension (manual) would do ?

For the last version, the requirement is :

PHP Version: PHP 4.0.0 or newer

And it seems there are functions that could do what you want ; for instance :

  • svn_mkdir : Creates a directory in a working copy or repository.

But not sure the are functions for everything you want, though...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文