SVN Tips
|
The Tiki project transitioned from a CVS repository to the SVN (Subversion) repository as of Tiki2. View source code: http://tikiwiki.svn.sourceforge.net/viewvc/tikiwiki/trunk Historical Revision Numbers: See: http://tikiwiki.svn.sourceforge.net/viewvc/tikiwiki/tags/ for the revision numbers of Tiki releases. For descriptions about each branch, please see: Where to commit for more information. |
Table of contents
|
Technical information
To get stable, development and experimental branches, see: Get code. Also see: Where to commit
First, the reference documentation for subversion:
http://svnbook.red-bean.com/
Basic SVN usage
Below are basic command lines to know. If you were using GUI like TortoiseCVS, just download TortoiseSVN instead ;)
- Tortoise SVN client: http://tortoisesvn.net/
Commands available to anyone on the internet
- To checkout the 6.x branch (creates a local SVN repository in your current directory including all the code):
svn checkout https://tikiwiki.svn.sourceforge.net/svnroot/tikiwiki/branches/6.x
- To checkout the development trunk (creates a local SVN repository in your current directory including all the code):
svn checkout https://tikiwiki.svn.sourceforge.net/svnroot/tikiwiki/trunk
- To build a new 6.x Tiki (all code without SVN specific files)
svn export https://tikiwiki.svn.sourceforge.net/svnroot/tikiwiki/branches/6.x DEST_DIRECTORY
- To update a checkout (caution: current version of trunk is experimental)
cd checkout_directory svn update
- To update/rollback an installation to a different revision (ahead or back)
svn update -r1234
- To update/rollback a single file to a different revision (ahead or back)
svn update -r1234 filename.php
- To update faster (in development, not production environments)
cd checkout_directory svn up --ignore-externals
- To see what will be committed
cd checkout_directory svn status svn diff
- To list the content of 6.x branch on the server:
svn ls https://tikiwiki.svn.sourceforge.net/svnroot/tikiwiki/branches/6.x
- To list the content of development trunk on the server:
svn ls https://tikiwiki.svn.sourceforge.net/svnroot/tikiwiki/trunk
Commands for Tiki developers
- To commit something inside a checkout
Committing requires a SourceForge login/password. Also, a Tiki admin needs to give you Write permissions. See How to get commit access
cd checkout_directory svn commit
Please commit with an inline message:
svn commit -m "[FIX] short fix description...."
Your first commit may require your sourceforge login/password
svn commit --username yourlogin -m "[FIX] short fix description...."
- To see the log of commit messages
cd checkout_directory svn update #this is to be sure to have the last log entries svn log
or page by page
svn log |less
svn diff -r1234:1235
svn merge -r1235:1234 svn ci
svn log -r1234
- Adding a file to the repository
cd checkout_directory svn add new_file svn commit -m "[ADD] feature: new file added in order to ....."
Please take care about the svn properties of the files that you add.
- php, inc, tpl, js, css files should have only one svn property: svn:keywords whose value is "Id" (without double-quotes). Please, see this page. You can add, in the header of these files a commented line
// $Id$
Once committed, this will expand and indicate the last commit on that file
- png, jpg, all image files : svn:mime-type ==> application/octet-stream. For those files, this prop is automatically added by the server when you commit
Useful tips
Those commands are faster if you use them on one precise directory or file
(e.g. svn log tiki-index.php ; svn diff lib/ ; ...)
Your SourceForge login/password will not be necessary until you commit something.
This means that anonymous and developer access are the same... This is very nice
Note that if you have a message like this one when trying to commit, it means that your password has expired and you need to login through SourceForge's web interface to change it. SourceForge will allow you to login and will not tell you the password is expired. Change it anyway.
svn: Commit failed (details follow): svn: MKACTIVITY of '/svnroot/tikiwiki/!svn/act/eac4ef53-cc7f-4415-ae1e-da1bac94a2ce': authorization failed (https://tikiwiki.svn.sourceforge.net)
Windows SVN Usage
Just because you don't know a grep from man page, doesn't mean you cannot contribute code. This section includes information for Windows users who prefer a GUI instead of a command line.
Getting set up.
- Get a Tiki and SourceForge account, then get SVN commit access.
- Download and install a SVN client, such as TortoiseSVN, that you will use to checkin/out files.
- Download and install an editor, such as Notepad++, phpStorm or PHP Designer, that you will use to edit the TPL and PHP files.
Note: When using your editor, whether you use a simple program like Notepad++ or something proprietary like Dreamweaver, you must make sure that you save your edited files with Unix-style line breaks ie just LF instead of the CR + LF that Windows would normally use.
Checking out the code.
- Download the Tiki source code to your PC.
- Create an empty directory.
- Right-click in the directory and select SVN Checkout from the popup menu.
- In the Checkout dialog, enter the following:
- URL of respository: https://tikiwiki.svn.sourceforge.net/svnroot/tikiwiki/trunk or https://tikiwiki.svn.sourceforge.net/svnroot/tikiwiki/branches/6.x
- Checkout directory: your local directory
- Revision: Select HEAD Revision to get the latest code
- Click OK. TortoiseSVN will download all the files to your local folder.
Checking in files.
- Right-click a file that you udpated, and select SVN Commit from the pop-up menu.
- In the Enter Log Message dialog, enter the following:
- Message: Enter a descriptive synopsis of your edits.
- File: Select the file to check in.
If you right-clicked a single file, only that file will be shown. If you right-clicked a folder, all files within that folder (and its sub-folders) that you have edited will be shown.
- Click OK. TortoiseSVN will upload the file and commit it to the SVN repository.
Updating files.
- Right-click a blank-area in your local folder, and select SVN Update from the pop-up menu.
- TortoiseSVN will compare the files in your local folder with those in the SVN repository, and download the newer version, if available.
About the repository directories structure
Subversion is usually structured a bit differently (but better from my point of view) compared to CVS. There is generally three directories at the root level:
- trunk/ => this is the development version (future 6.x at this date), where most of development is done. New functionalities are added here,
- branches/proposals/X.x (eg. proposals_3.x) => this is where you can propose some code for the next stable branch release (e.g. in order to backport fixes from trunk). The Quality Team will check your commit and, if accepted, backport your code to the stable branch (if still maintained),
- branches/X.x (eg. branches/4.x) => stable branches repository. If not member of the Quality Team, you should not commit to this branches. Please read (Quality Team),
- branches/experimental => repository for some experimental work before merging with trunk (once almost cleaned),
- tags/ => this is where we store a "snapshot" of each release. There should be no code modifications here.
We will have those "standard" directories + some others. There will be at least two additional directories:
- third_party/ => this contains one subfolder per third party library that is used by tiki but should not be modified (except to update it).
- mods/ => this contains the code of tiki mods, available on mods.tikiwiki.org
So, this means that we will now have this directory structure inside our repository:
tikiwiki/
trunk/
branches/
1.10/
2.0/
3.0/
4.x/
5.x/
6.x/
experimental/
workspaces/
webdav/
.
.
proposals/
6.x/
tags/
1.10.0b/
2.0/
.
3.0
.
mods/
trunk/
branches/
2.0/
third_party/
adodb/
fckeditor/
jscalendar/
phplayers/
smarty/
This means, for those who want to work on mods, that they will have to checkout the mods directory this way:
https://tikiwiki.svn.sourceforge.net/svnroot/tikiwiki/mods/trunk
Restore a deleted file
- Merge back specific commit from trunk
If you deleted a file in revision 19139
svn merge -r19139:19138 https://tikiwiki.svn.sourceforge.net/svnroot/tikiwiki/trunk
- Commit file
Add details to explain why, and use right file name
svn commit -m "[FIX] Restoring file" filename.php
Restore in trunk a file deleted in a branch
- Merge back specific commit from branches/4.x
If you deleted a file in revision 19139
svn merge -r19139:19138 https://tikiwiki.svn.sourceforge.net/svnroot/tikiwiki/branches/4.x
- Commit file
Add details to explain why, and use right file name
svn commit -m "[FIX] Restoring file" filename.php
How to figure out what revision number causes a bug
What revision number am I at? What branch am I using?
www-data@cdec01:/var/www$ svn info Path: . URL: https://tikiwiki.svn.sourceforge.net/svnroot/tikiwiki/branches/proposals/6.x Repository Root: https://tikiwiki.svn.sourceforge.net/svnroot/tikiwiki Repository UUID: b456876b-0849-0410-b77d-98878d47e9d5 Revision: 32580 Node Kind: directory Schedule: normal Last Changed Author: sylvieg Last Changed Rev: 32579 Last Changed Date: 2011-02-11 10:18:21 -0500 (Fri, 11 Feb 2011)
Proposing a commit to another branch
Related: Quality Team
- Checkout the code from the proposed branches
Checking out the new stable directory (6.x)
svn checkout https://tikiwiki.svn.sourceforge.net/svnroot/tikiwiki/branches/proposals/6.x .
- Merge specific commit from trunk or other branch
Merge revision 19139 from trunk
svn merge -r19138:19139 https://tikiwiki.svn.sourceforge.net/svnroot/tikiwiki/trunk
Merge revision 35100 from branch 7.xsvn merge -r35099:35100 https://tikiwiki.svn.sourceforge.net/svnroot/tikiwiki/branches/7.x
The cherry picking method can also be used. First check you have the good commit by running a diff, then merge the commit
Cherry picking 19139svn diff -c 19139 https://tikiwiki.svn.sourceforge.net/svnroot/tikiwiki/trunk svn merge -c 19139 https://tikiwiki.svn.sourceforge.net/svnroot/tikiwiki/trunk
- Test
Solve any conflict
Test tikiwiki - It is a good idea to have proposals branches installed and operational.
Be very careful to avoid regressions.Some useful svn tools#To see what will be commit svn diff | more #To pick again the version in trunk of this_file svn revert this_file #After conflict and edition, to tell svn that the version in proposed is the good one (commands depend on svn version svn revolved this_file svn resolve --accept working this_file
- Commit
svn commit -m "[bp/r19139][FIX] Mindmap was broken by changes to the flash plugin" tiki-mindmap.php
It starts with "[bp/r19139]", which means that it is a backport of a fix/feature commited on trunk at revision 19139. Then it is followed by the original commit message made on trunk. If multiple commits has been made on trunk to fix the same issue, they have to be proposed as one unique commit and the commit message will have multiple lines starting with [bp/r...]
Switching to another branch
For instance, you are in 6 and you want to go into 9, do
svn switch https://tikiwiki.svn.sourceforge.net/svnroot/tikiwiki/branches/9.x
Handling branches
Experimental branches
As of the release of Tiki2, releases will be made more often. In order to do so, trunk must remain somewhat stable. To make major changes, experimental branches can be used.
To work from an experimental branch:
- Check-out trunk
- Create your branch as follows:
- Open a Linux shell window (This is not tested on Windows)
- Position yourself at the root of the place where you checked out trunk.
- do `php doc/devtools/svnbranch.php branches/experimental/your_subproject_name`
- Example: php doc/devtools/svnbranch.php branches/experimental/plugin_ui
- Check-out your new branch
- Develop and commit in your branch
`php doc/devtools/svnbranchupdate.php trunk`.
Fix conflicts and commit using `svn commit -F svn-commit.tmp`.
- When done and ready to merge, update one last time from latest trunk code
- From the trunk check-out, run `php doc/devtools/svnmerge.php branches/experimental/your_subproject_name`
- Commit changes with a meaningful message.
All scripts provide you with the next steps for each of them. Follow those steps carefully.
Update from Stable branches
Removing an experimental branch
svn remove -m "[KIL] Lesser magic was merged long ago" http://tikiwiki.svn.sourceforge.net/svnroot/tikiwiki/branches/experimental/lesser-magic/
Creating a new proposals branch
svn copy -rHEAD https://tikiwiki.svn.sourceforge.net/svnroot/tikiwiki/branches/6.x https://tikiwiki.svn.sourceforge.net/svnroot/tikiwiki/branches/proposals/6.x
I (jonnyb) actually did this using Aptana with Subclipse. On a 6.x working copy project, I right clicked and selected Team->Branch/Tag, it asked me for a commit message and I added
[BRANCH] Manually created 6.x branch
and hopefully that's all - we shall see!
. I believe starting the commit with [BRANCH] is what the Tiki branch update script looks for to see where to start (that may not be relevant in proposals)
Merging branch to trunk while releasing
Update from Stable branches
- Check-out trunk
- Run `php doc/devtools/svnbranchupdate.php branches/version_number`
- Example: php doc/devtools/svnbranchupdate.php branches/7.x
- Fix conflicts and commit using `svn commit -F svn-commit.tmp`.
Notes from previous release processes
[+]TODO
As you can see, I didn't create some directories yet:
- mods/branches/ : this is because we never had branches for mod before, so no urgency.
Another important thing: Do NOT touch libs of third_party, neither in third_party directory, nor in branches/x.x/lib/ or trunk/lib/ ... the two last ones are "specials" because they use svn capabilities (svn:externals property) to point to those in third_party directory. It's like links. They are there just to make it easier to have a running tiki with all needed libs from a checkout of trunk or a branch.
Related

Last Comments