Using Subversion

From 워드프레스(WORDPRESS) 한국어 위키

Jump to: navigation, search

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

After the WordPress 1.5 release we moved our source control off of the legacy Sourceforge CVS system and on to a modern Subversion repository. When we get confused about Subversion we use this great Subversion book that is available for free online. That is a pretty involved read if all you want to do is access the latest WordPress code, so here are some quick tips for downloading and working with the WordPress source code.

This all assumes you have Subversion installed on the machine you are working on. If you do not, check out the links above.

There are two basic Subversion commands that you need to know. 'svn checkout' or just 'svn co' for short will 'check out' code from a 'repository'. Checking out code basically equates to downloading the code from the central repository, which is where all the code is stored.

Checking out the code

To check out the latest WordPress codebase, try this checkout command:

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

Tip: if you are not interested in hacking at the WordPress source code and just want to run it, try this command instead:

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

This will give you the same code as using 'svn co', but you won't get the hidden '.svn' directories that Subversion normally creates, and you won't be able to update using the 'svn update' command.

Updating your copy

To update your working copy later, go into the directory and run this command:

 svn update 

That is basically it as far as working with the code.

Developer's commands

Here are some commands you can use to keep track of what is going on.

If you have made a change you want to submit back to the core this will show you what files you have changed:

 svn status 

And this will output a line-by-line description of all the changes in a format that makes it easy for us to incorporate:

 svn diff 

Which will output a unified diff of all the changes you have made to the entire tree of source code. To get a similar diff for just one file,

 svn diff path/to/file 

You can output either of these two svn diff commands to a file by using redirection:

 svn diff > my-patch.txt 

To reset your working copy to the latest core code (to throw away any changes you've made):

svn diff | grep Index | sed 's/^Index: //' | xargs svn revert

You can also do this for just a single file:

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.

 svn switch http://svn.automattic.com/wordpress/tags/2.0

You can use the 'svn list' command to browse the contents of the repository, or use trac to browse the source.

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

This page is marked as incomplete. You can help Codex by expanding it.

Personal tools