SVN

After installation, creation of an empty new repository [both as root]:

svnadmin create /var/svn/repos/newrep
mkdir /var/svn/repos/newrep

Initial importation of files into the repository [as root]:

svn import dir_with_initial_files file:///var/svn/repos/newrep/trunk

Check everything is OK [as the user owner of the working dir]:

svn list file:///var/svn/repos/newrep/

Checkout of the repository into a working directory [as the user owner of the working dir]:

svn checkout file:///var/svn/repos/newrep/trunk working_dir

Syncronisation with the server:

svn update

Checkin (there are many options available for this command):

Change the ownership of the repos directory to the user owner of the working dir


svn status [to have a list of all the files you have modified since your latest commit]

svn commit comma_separated_list_of_files_you_want_to_commit

This is a list of useful commands:

  • svn info The URL of the repo and other info
  • svn diff [filename]
  • svn diff -r19:21 [filename]
  • svn status [filename]
  • svn status –show-updates It will tell you also about updates from other SVN users
  • svn log [--verbose] The history of the revisions
  • svn revert [filename] To get the HEAD from the repo and overwrite your local changes
  • Recursive add in SVN:
    svn add –force *
    or
    svn add –depth=infinity *

Adding new files:

svn add PATH

svn commit

DELETING A FILE

You can do it simply from your working copy

svn delete filename

svn commit filename

or if there’s any problem, you could do that directly on the server

svn delete file://var/svn/repos/yourproject/your_dir/filename

////////////////////////////////////////////////////////////////////////////////////////

The common process in using a repo is:

  • svn update – to syncronize the local workspace with the repo
  • edit files
  • svn commit
  • svn update
  • …….

////////////////////////////////////////////////////////////////////////////////////////

Exclude some files from the control of SVN (very useful for cache directories):
svn propedit svn:ignore webroot/pwsafe/assets/cache/
After that, the editor will be opened were you can insert the types of files you want to exclude, i.e.:
*.php
*.cache
Inserting simply * seems not to work

Tip: probably SVN will complain because None of the environment variables SVN_EDITOR, VISUAL or EDITOR is set. Then just issue:

SVN_EDITOR=vim
export SVN_EDITOR

////////////////////////////////////////////////////////////////////////////////////////

Properties and Externals:
_ Go to the directory you want to act on
_ svn proplist
_ svn propedit svn:externals . [for example]
_ forums svn://testbox/externals/vbulletin/trunk/webroot
Properties is something you should commit as well

////////////////////////////////////////////////////////////////////////////////////////

A few notes:

////////////////////////////////////////////////////////////////////////////////////////

Reverting to a previous revision
svn merge –revision 109:107 https://repo_url/project_name/trunk
_ This if the current revision is the 109 and you want to go back to the 107
_ You can replace the repo URL with just the name of the file you want to revert

svn commit -m “after merge –revision 109:107 https://repo_url/project_name/trunk”

It may tell you there are some conflicts. That’s because you have made some changes between the revisions 107 and 109 (and locally you were running the revision 109)
_ Resolve the conflicts by editing the files
_ Issue the command: svn resolved filename1 < …>

_ Commit

When all the conflicts are solved:
svn update

////////////////////////////////////////////////////////////////////////////////////////

While committing, an error about the editor to use could raise. In that case:

SVN_EDITOR=/usr/bin/vim

export SVN_EDITOR

////////////////////////////////////////////////////////////////////////////////////////

Conflicts
When you commit or update, a conflict could arise. Then, two things can happen. The first is SVN was able to resolve the conflict by itself (the changes didn’t overlap). In this case the file is marked with C. The second one is that SVN wasn’t able to solve the conflict. Then the file will be marked with G and a message like this will come up:

svn: Aborting commit: '/home/sally/svn-work/sandwich.txt' remains in conflict

If you get an unresolved conflict, you need to do one of three things:

  • Merge the conflicted text “by hand” (by examining and editing the conflict markers within the file) after having done svn update <filename>.
  • Copy one of the temporary files on top of your working file.
  • Run svn revert <filename> to throw away all of your local changes.

Once you’ve resolved the conflict, you need to let Subversion know by running svn resolved. This removes the three temporary files and Subversion no longer considers the file to be in a state of conflict.[4]

$ svn resolved sandwich.txt
Resolved conflicted state of 'sandwich.txt'

Now you can commit.

////////////////////////////////////////////////////////////////////////////////////////
Associated to SVN there should be a server (probably on the /etc/init.d directory) so you can access the repository remotely
like this:
svn://machine_ip:3690/repos/project_name
////////////////////////////////////////////////////////////////////////////////////////

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

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

This will “check out” all of the files you’ll need. To update your working copy later, go into the directory and run this command:

svn update

That will update all your file to the latest. If you’ve made a change you want to submit back to the core this will show you what files you’ve 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

You can output this to a file by using redirection:

svn diff > my-patch.txt

///////////////////////////////////////////////////////////////////////////////////////

Create a branch from the trunk
svn copy -m “…….” svn://server/projects/projectA/trunk svn://server/projects/projectA/branches/daniele/2008-10-13_forum_upgrade

///////////////////////////////////////////////////////////////////////////////////////

Merging a branch into the trunk
Source for this chapter: http://www.sepcot.com/blog/2007/04/SVN-Merge-Branch-Trunk

  • Checkout a copy of the trunk (if you haven’t already done)
    svn co svn://server/path/to/trunk
  • Checkout a copy of the branch (if you haven’t already got)
    svn co svn://server/path/to/branch
  • A help: in order to find out which repository the current working directory refers to:
    svn info
  • Go to your ”’branch”’ working directory
  • Find out the revision the branch began at:
  • svn log --stop-on-copy

    Let’s call this number X

  • Go to your ”’trunk”’ working directory
  • svn update
  • Now you can perform the merge:
    svn merge -rX:HEAD svn://server/path/to/branch

    This will put all updates into your current working directory for trunk.
    N.B.: The HEAD revision is a synonym for the most recent revision (= the revision carrying the highest number).

  • Resolve any conflicts that arose during the merge
  • Check in to the repository using the conventional comment
This entry was posted in Linux, Web Development and tagged . Bookmark the permalink.

Leave a Reply