WordPress:Using Subversion
This page only applies to developers, so if it's all Greek to you, don't worry!
這個(gè)網(wǎng)頁適用于開發(fā)人員,因此如果你完全不懂,請(qǐng)不要擔(dān)心!
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.
大多數(shù)軟件包,包括WordPress,使用版本控制系統(tǒng),追蹤后臺(tái)的源碼和修訂本,而且定期地發(fā)行軟件,供公眾使用。在發(fā)行WordPress 1.5版本 之前,WordPress源碼儲(chǔ)存在 Sourceforge中的CVS版本控制系統(tǒng)中。從WordPress 1.5版本開始, WordPress 使用自身安裝的 子版本進(jìn)行版本控制。大多數(shù)用戶永遠(yuǎn)都不想使用子版本,因?yàn)樗麄冎粫?huì)安裝WordPress已經(jīng)發(fā)行的版本。然而,插件和主題的開發(fā)人員可能想要測(cè)試最新的WordPress版本上的軟件,而且有興趣通過測(cè)試或者解決程序問題 奉獻(xiàn)于WordPress的人,也需要使用正在研發(fā)的代碼。
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:
處于研發(fā)狀態(tài)的代碼,只有通常查看子版本,才能夠被用到。在這篇文章中,我們會(huì)介紹一些基本信息,關(guān)于連接到WordPress子版本資源庫,以及運(yùn)行大多數(shù)WordPress用戶能夠使用的字符串。
- Subversion web site
- Subversion FAQ
- Subclipse - a Subversion plugin for the Eclipse development environment
- Tortoise SVN - a popular Windows Subversion client
- The Subversion Book - available free online
- Subclipse - Eclipse 發(fā)展環(huán)境的一個(gè)子版本插件
- Tortoise SVN – 一個(gè)受歡迎的Windows子版本client
- Subversion 書籍 – 在線免費(fèi)獲取
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,下面的命令就會(huì)是菜單選擇—然而,同樣的原則也可以使用。為你的client查看幫助文件,了解怎樣鏈接到子版本資源庫,執(zhí)行對(duì)等的命令。
Repository, Branches, Trunk, and Tags[ ]
資源庫, Branches, Trunk, 標(biāo)簽[ ]
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).
子版本的基本理念是源代碼和修訂本保存在服務(wù)器的資源庫中。用戶可以使用client程序,連接到資源庫,client程序能夠使用戶檢查,瀏覽,編輯,修補(bǔ),更改源代碼文件(這取決于client的權(quán)限級(jí)別;在WordPress項(xiàng)目中,只有幾個(gè)人擁有更改資源庫的權(quán)限)。
The WordPress repository is at http://svn.automattic.com/wordpress/. Within the repository, there are three sections:
WordPress資源庫在http://svn.automattic.com/wordpress/。在資源庫的內(nèi)部,擁有三個(gè)部分:
- trunk: http://svn.automattic.com/wordpress/trunk/always contains the latest development code
- trunk: http://svn.automattic.com/wordpress/trunk/通常包含最近開發(fā)的代碼
- tags: When a version is released to the public, the source code is "tagged" with the version number. So for instance, WordPress 2.0.7 can be found at http://svn.automattic.com/wordpress/tags/2.0.7/
- tags:當(dāng)一個(gè)版本公開發(fā)行的時(shí)候,源代碼就會(huì)"標(biāo)上"版本數(shù)字。因此,例如,WordPress2.0.7可以在http://svn.automattic.com/wordpress/tags/2.0.7/中找到。
- 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:有時(shí)候,當(dāng)新的WordPress版本創(chuàng)建的時(shí)候,WordPress開發(fā)小組承諾維護(hù)先前的版本,解決先前版本的程序錯(cuò)誤(通過僅限于主要的程序錯(cuò)誤和安全問題)。因此,例如,WordPress2.0版本的開發(fā)代碼,可以在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):
安裝好了子版本,你需要做的第一步是檢查代碼,基本的意思就是你會(huì)從資源庫中將版本下載到你的電腦上。要做到這一點(diǎn),為你的代碼制作一個(gè)空目錄,更改到那個(gè)目錄,然后在trunk,branch,或者你感興趣的標(biāo)簽上執(zhí)行checkout command,來check out trunk(最近發(fā)展的版本):
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.
等待了一會(huì)后(等待時(shí)間取決于網(wǎng)絡(luò)連接的速度),結(jié)果是目錄填滿了所有的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代碼后,已經(jīng)過去了一段時(shí)間,而且你想要更新到現(xiàn)在的最新的版本,在切換到到你最初checked out代碼的目錄之后,使用更新命令:
svn update
svn update
Exporting the Code[ ]
導(dǎo)出代碼[ ]
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):
如果你不準(zhǔn)備編輯,更新,hacking,或者解決WordPress代碼的程序錯(cuò)誤,只是想要下載最新的WordPress版本,將其安裝在某個(gè)位置,你可以使用導(dǎo)出命令(首先創(chuàng)建一個(gè)新的目錄保存結(jié)果,然后再轉(zhuǎn)換為那個(gè)目錄):
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,這會(huì)給你提供同樣的WordPress代碼,但是沒有隱藏的.svn目錄。導(dǎo)出后,其它的任何子版本命令都不會(huì)運(yùn)行—如果你想要使用其它的子版本命令,你需要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.
對(duì)于WordPress子版本資源庫,也有一個(gè)在線瀏覽器。
Developer's commands[ ]
開發(fā)人員的命令[ ]
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中的程序錯(cuò)誤,在你check out代碼的目錄中編輯文件。當(dāng)你準(zhǔn)備將程序錯(cuò)誤的解決方法遞交到即將發(fā)行的WordPress版本的時(shí)候,請(qǐng)閱讀報(bào)告程序錯(cuò)誤找出怎樣在Trac創(chuàng)建程序錯(cuò)誤ticket(WordPress程序錯(cuò)誤追蹤系統(tǒng)),然后使用下面的命令。
你可能要切換到一個(gè)子目錄(例如 trunk)來執(zhí)行這些命令。
- To get a list of the files you have changed, use the status command:
svn status
- 要得到你已經(jīng)更改的文件的列表,請(qǐng)使用status command:
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
- 要顯示你對(duì)每行patch格式更改的內(nèi)容,請(qǐng)使用diff command。這會(huì)輸出unified diff關(guān)于你對(duì)整個(gè)源代碼樹做的更改。
- To show the differences for just one source file:
svn diff path/to/file
- 顯示一個(gè)源文件的不同之處:
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輸出保存到一個(gè)文件中(這樣你可以將其配置到Trac報(bào)告中,作為一個(gè)補(bǔ)?。?,請(qǐng)使用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設(shè)置為你checked out的代碼(去除任何你已經(jīng)更改的內(nèi)容):
svn revert . -R
- You can also do a revert for just a single file:
svn revert path/to/file
- 你也可以為一個(gè)單一的文件,做一個(gè)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:
- 如果你已經(jīng)有一個(gè)trunk的working copy,但是你想要轉(zhuǎn)回到某個(gè)已經(jīng)發(fā)行的版本,你可以使用'svn switch'命令將你的working copy中的所有文件,返回到已經(jīng)發(fā)行的版本的狀態(tài)。例如,轉(zhuǎn)回到2.0版本:
svn switch http://svn.automattic.com/wordpress/tags/2.0
svn switch http://svn.automattic.com/wordpress/tags/2.0
Other Resources[ ]
其它的資源[ ]
- How Mark Jaquith reverted the code related to tags in April 2007
- Mark Jaquith's Toolbox with Linux/Mac command-line explanations