Subversion Howto

From Edgar BV Wiki
Revision as of 09:21, 19 January 2017 by Red (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Wat is subversion


TortoiseSVN manual Nightly build of the manual (especially chapter 5 + are interesting for using TortoiseSVN)


Create a new repository:


In W:\websites\Admin\subs\ make a new directory with the project name (eg. test) Right click on test and choose 'create repository here'

This creates a directory with conf/, db/, hooks/, locks/, format and README.txt You can then surf to http://wip.mynet.int/svn/test/ to see the repo in the browser. (it will be empty).


The URL http://wip.mynet.int/svn/test works because of a server side directive which specifies that Location.


Then import the standard structure. Find the directory '0 Naam van opdracht' and right click on it. Choose TortoiseSVN -> Import... and put in the url of the repository (http://wip.mynet.int/svn/test/). This creates revision 1.

To work with the repository you need to check out the repository to your working copy.


Making a working copy:


make a directory wip on your local hd, eg. w:\websites\Admin\workingcopy

Inside that directory make a directory with the same name as the project you will check out into it, eg:

w:\websites\Admin\workingcopy

right click on the directory and choose 'SVN Checkout...'


In the URL of repository put the location of the repository (http://wip.mynet.int/svn/test/) and make sure it goes to the right destination URL.


Then in d:\wip\test\ you will find the files and directories of '0 Naam van opdracht'. This is where you do all your work!


Adding files to the repository:


In the working copy, create a new file. Right click on the file, TortoiseSVN -> Add.

You can add files by copying them into the directory as well: either select all the files and right-click-drag them in and then choose 'SVN Add files to this WC', or normally drag them in, select them in the working copy and then right click, TortoiseSVN -> Add.



Server Side:



/etc/apache2/mods-enabled/dav_svn.conf

<Location /svn>
  DAV svn
  SVNParentPath /export/var/www/website/Admin/subs/
</Location>

This will enable SVN on the server. Adding the following inside the <Location> tags above allows for PAM authentication using libapache-mod-auth-pam

 # Added for PAM authentication
 AuthType Basic
 # To silence error msg in /var/log/*error.log
 AuthUserFile /dev/null
 # AuthPAM_FallThrough off
 AuthName "SubversionRepository"
 AuthPAM_Enabled on
 require valid-user
 require group designers
 # Required to get mod_auth_pam working in apache > 2.0 
 AuthBasicAuthoritative off
 <LimitExcept GET PROPFIND OPTIONS REPORT>
 Satisfy all
 </LimitExcept>

You also need to add the user www-data to the group shadow: adduser www-data shadow

wiki source another source subversion FAQ

keywords: subversion, svn, SVN


SSH

#Create repository:
~ svnadmin create /path/to/repository/folder/project_repository_naam
~ chown -R www-data:designers project_repository_naam
#Import project into repository
~ svn import /export/home/store/pages/P/projectnaam http://wip.mynet.int/svn/project_repository_naam -m 'Eerste import'
#Create working copy
~ cd /export/var/www/website/JOUWNAAM/
~ mkdir projectnaam
~ chown -R www-data:designers projectnaam
~ svn checkout http://wip.mynet.int/project_repository_naam projectnaam
#ZEND 9 en SVN --> ZEND 9 NIET UPDATEN
# Je maakt eerst via PUTTY, zoals hierboven beschreven een project aan. Daarna maak je een CHECKOUT tevens via PUTTY
# Hierna ga je in ZEND een project toevoegen. Door te klikken op nieuw, waarna je kiest een "PHP project from excisting directory"
# Je loopt nu de wizard door, waarbij je met browse naar het nieuwe project gaat op de WIP.

# Zorg ervoor dat je op je PC tevens "TortoiseSVN-1.6.7.18415-x64-svn-1.6.9" hebt geinstalleerd staat deze werkt namelijk vlekkeloos samen met ZEND, geen hogere of lagere versie installeren 
# dit geeft conflicten

Voor hieronder moet je wel enigzins een idee hebben waar je mee bezig bent

Recursively delete .svn directories

# We use find command to find all .svn folders beginning from current directory. 
$ find /export/var/www/website/JOUWNAAM/projectnaam -type d -name .svn

#It is possible to pass these directories directly to rm command, using grave accent quotes (key to left of '1')
<strike>$ rm -rf `find /export/var/www/website/JOUWNAAM/projectnaam -type d -name .svn`</strike> 
#previous command couldn't remove directories with spaces in de foldername. The following command does!
find "/export/var/www/website/JOUWNAAM/projectnaam"  -name '*svn*' -exec rm -rf {} \;
#So, this will remove every .svn folder beginning from current directory. 
# Betere verwijder en zoekfunctie indien bovenstaande niet werkt. Voornamelijk met spaties is dit het geval
# KIJK UIT DAT JE NIET ALLES OP DE WIP VERWIJDERD BIJ TWIJFEL VRAGEN AAN PAUL
ZOEKEN: 		find /export/var/www/website/JOUWNAAM/projectnaam -name \*obselete* -print
VERWIJDEREN: 		find /export/var/www/website/JOUWNAAM/projectnaam -name "*obselete*" -exec rm -rf {} \;

Recursively delete lockfiles when cleanup does not work

Ik heb een alias gemaakt naar een sh file om recursief alle lock files uit de .svn mappen te verwijderen.

Om lock files te verwijderen voer je simpel het volgende commando uit in ssh:

    # rml /export/var/www/website/JOUWNAAM/projectnaam

rml is een virtuele alias naar /export/home/people/user/removeLocks.sh (alias rml='/export/home/people/paul/removeLocks.sh')

Het script doet dan het volgende:

#!/bin/bash
echo "Find lock files in directory $1 to lockfiles"
find $1 |grep ".svn/lock" > lockfiles
echo "Read lockfiles to see if some need to be removed"
cat lockfiles | grep -v "#" |
while read lockPath; do
        rm -rf "$lockPath"
        echo "$lockPath is removed"
done
echo "Remove lockfiles file"
rm -rf lockfiles