WordPress:Using Subversion

来自站长百科
跳转至: 导航、​ 搜索



This page only applies to developers, so if it's all Greek to you, don't worry!

这个网页适用于开发人员,因此如果你完全不懂,请不要担心!

Most software projects, including WordPress, use a version-control system to keep track of their source code and its revisions behind the scenes, and periodically release versions of the software for public use. Prior to the WordPress 1.5 release, the WordPress source code was stored in the CVS version-control system at Sourceforge. Since WordPress 1.5, WordPress has been using its own installation of Subversion for version control. Most WordPress users will never want to use Subversion, because they will only install the released versions of WordPress. However, developers of plugins and themes may want to test their software against the latest development version of WordPress, and people interested in WordPress:Contributing to WordPress by testing or fixing bugs will also need to have access to the code that is in development.

大多数软件包,包括WordPress,使用版本控制系统,追踪后台的源码和修订本,而且定期地发行软件,供公众使用。在发行WordPress 1.5版本 之前,WordPress源码储存在 Sourceforge中的CVS版本控制系统中。从WordPress 1.5版本开始, WordPress 使用自身安装的 子版本进行版本控制。大多数用户永远都不想使用子版本,因为他们只会安装WordPress已经发行的版本。然而,插件和主题的开发人员可能想要测试最新的WordPress版本上的软件,而且有兴趣通过测试或者解决程序问题 奉献于WordPress的人,也需要使用正在研发的代码。

This development code can only be accessed via Subversion. In this article, we'll cover the basics of connecting to the WordPress Subversion repository and running the commands that are available to most WordPress users.

This article assumes that you have Subversion (or at least a Subversion client) installed already, and it only covers the most basic commands. For installation instructions, alternative clients, and more detailed information, check out these resources:

处于研发状态的代码,只有通常查看子版本,才能够被用到。在这篇文章中,我们会介绍一些基本信息,关于连接到WordPress子版本资源库,以及运行大多数WordPress用户能够使用的字符串。

Note that if you choose to use Tortoise, Subclipse, or another graphical client, the commands below will be menu selections -- however, the same principles apply. Check the help files for your client to figure out how to connect to the repository and execute the equivalent commands.

注如果你选择使用Tortoise, Subclipse,或者其它的图形client,下面的命令就会是菜单选择—然而,同样的原则也可以使用。为你的client查看帮助文件,了解怎样链接到子版本资源库,执行对等的命令。

Repository, Branches, Trunk, and Tags[ ]

资源库, Branches, Trunk, 标签[ ]

The basic idea of Subversion is that the source code and revisions are kept in a repository on a server. Users connect to the repository by using a client program, which allows the user to check out, view, edit, patch, and commit changes to the source code files (depending on the client's permission level; in the WordPress project, only a couple of people have permission to commit changes to the repository).

子版本的基本理念是源代码和修订本保存在服务器的资源库中。用户可以使用client程序,连接到资源库,client程序能够使用户检查,浏览,编辑,修补,更改源代码文件(这取决于client的权限级别;在WordPress项目中,只有几个人拥有更改资源库的权限)。

The WordPress repository is at http://svn.automattic.com/wordpress/. Within the repository, there are three sections:

WordPress资源库在http://svn.automattic.com/wordpress/。在资源库的内部,拥有三个部分:

  • branches: Sometimes when major new versions of WordPress are created, the WordPress development team makes a committment to maintain the previous release with bug fixes (usually limited to major bugs and security issues). So, for instance, the latest development code on the 2.0 branch of WordPress can be found at http://svn.automattic.com/wordpress/branches/2.0/
  • branches:有时候,当新的WordPress版本创建的时候,WordPress开发小组承诺维护先前的版本,解决先前版本的程序错误(通过仅限于主要的程序错误和安全问题)。因此,例如,WordPress2.0版本的开发代码,可以在http://svn.automattic.com/wordpress/branches/2.0/中找到。

Checking Out the Code[ ]

检查代码[ ]

Once you have Subversion installed, the first step you'll need to do is to check out the code, which basically means that you will download a version from the repository to your computer. To do this, make an empty directory for your copy of the code, change to that directory, and execute the checkout command on the trunk, branch, or tag you are interested in. For instance, to check out the trunk (latest development version):

安装好了子版本,你需要做的第一步是检查代码,基本的意思就是你会从资源库中将版本下载到你的电脑上。要做到这一点,为你的代码制作一个空目录,更改到那个目录,然后在trunk,branch,或者你感兴趣的标签上执行checkout command,来check out trunk(最近发展的版本):

 svn co http://svn.automattic.com/wordpress/trunk/ 
 svn co http://svn.automattic.com/wordpress/trunk/ 

After a short wait (depending on your Internet connection speed), the result will be that the directory is filled with all of the WordPress files, as well as some hidden .svn sub-directories containing Subversion information.

等待了一会后(等待时间取决于网络连接的速度),结果是目录填满了所有的WordPress文件,而且一些隐藏的.svn子目录包含了子版本信息。

Updating Your Copy of the Code[ ]

更新你的那份代码[ ]

If some time has passed since you checked out the code, and you would like to update to the latest version now available, use the update command, after first changing to the directory where you checked out the code originally:

如果你checked out代码后,已经过去了一段时间,而且你想要更新到现在的最新的版本,在切换到到你最初checked out代码的目录之后,使用更新命令

 svn update 
 svn update 

Exporting the Code[ ]

导出代码[ ]

If you are not planning to do any editing, updating, hacking, or bug fixing in the WordPress code, but just want to download the latest version so you can install it somewhere, you can use the export command (after first creating a new directory to hold the results, and changing to that directory):

如果你不准备编辑,更新,hacking,或者解决WordPress代码的程序错误,只是想要下载最新的WordPress版本,将其安装在某个位置,你可以使用导出命令(首先创建一个新的目录保存结果,然后再转换为那个目录):

 svn export http://svn.automattic.com/wordpress/trunk/ 
 svn export http://svn.automattic.com/wordpress/trunk/ 

This will give you the same WordPress code as using svn co, but without the hidden .svn directories. None of the other Subversion commands will work after an export -- you need to do a checkout if you want to use the other Subversion commands.

如使用svn co,这会给你提供同样的WordPress代码,但是没有隐藏的.svn目录。导出后,其它的任何子版本命令都不会运行—如果你想要使用其它的子版本命令,你需要checkout。

Browsing the Code[ ]

浏览代码[ ]

To list all the files in the repository, without updating, checking out, etc, you can use the list command:

在资源库中列出所有的文件,checking out,等等,你可以使用list命令:

svn list http://svn.automattic.com/wordpress/trunk/

To list files in a sub-directory, such as wp-includes:

svn list http://svn.automattic.com/wordpress/trunk/wp-includes/
svn list http://svn.automattic.com/wordpress/trunk/

在子目录中列出列表文件, 如 wp-includes:

svn 列表http://svn.automattic.com/wordpress/trunk/wp-includes/

There is also an online browser for the WordPress Subversion repository.

对于WordPress子版本资源库,也有一个在线浏览器

Developer's commands[ ]

开发人员的命令[ ]

If you are fixing bugs in WordPress, edit the files in the directory where you checked out the code. When you are ready to submit your fixes for inclusion in an upcoming version of WordPress, read WordPress:Reporting Bugs to find out how to create a bug ticket on Trac (the WordPress bug tracking system), and then use the commands below.

You may need to change to a sub-directory (such as trunk) to execute these commands.

如果你解决WordPress中的程序错误,在你check out代码的目录中编辑文件。当你准备将程序错误的解决方法递交到即将发行的WordPress版本的时候,请阅读报告程序错误找出怎样在Trac创建程序错误ticket(WordPress程序错误追踪系统),然后使用下面的命令。

你可能要切换到一个子目录(例如 trunk)来执行这些命令。

 svn status 
 svn status 
  • To show the changes you have made in a line-by-line patch format, use the diff command. This will output a unified diff of all the changes you have made to the entire tree of source code:
 svn diff 
  • 要显示你对每行patch格式更改的内容,请使用diff command。这会输出unified diff关于你对整个源代码树做的更改。
  • To show the differences for just one source file:
 svn diff path/to/file 
  • 显示一个源文件的不同之处:
 svn diff path/to/file 
  • To save the output of a diff into a file (so that you can attach it as a patch to a Trac report), use redirection:
 svn diff > my-patch-file.diff 
  • diff输出保存到一个文件中(这样你可以将其配置到Trac报告中,作为一个补丁),请使用redirection:
 svn diff > my-patch-file.diff 
  • To reset your working copy to the code you checked out (to throw away any changes you've made):
svn revert . -R
  • 重新将你的working copy设置为你checked out的代码(去除任何你已经更改的内容):
svn revert . -R
  • You can also do a revert for just a single file:
svn revert path/to/file
  • 你也可以为一个单一的文件,做一个revert
svn revert path/to/file
  • If you already have a working copy of the trunk, but you want to switch back to one of the released versions, you can use the 'svn switch' command to bring all the files in your working copy back to the state of the released version. For instance, to switch back to version 2.0:
  • 如果你已经有一个trunk的working copy,但是你想要转回到某个已经发行的版本,你可以使用'svn switch'命令将你的working copy中的所有文件,返回到已经发行的版本的状态。例如,转回到2.0版本:
 svn switch http://svn.automattic.com/wordpress/tags/2.0
 svn switch http://svn.automattic.com/wordpress/tags/2.0

Other Resources[ ]

其它的资源[ ]