Archive for svn

Subversion (SVN)

Install SVN 1.5

*Download and unzip Subversion 1.5 binary built for Apache 2.2 (svn-win32-1.5.5.zip) from here
*Create a new env variable: SVN_HOME=C:\prog\svn-win32-1.5.5
*Add %SVN_HOME%\bin to PATH: path=%SVN_HOME%\bin;%path%

SVN_HOME=C:\prog\svn-win32-1.5.5
path=%SVN_HOME%\bin;%path%

Create Repository

svnadmin create C:\work\svn

Eclipse plugin: Subclipse

* Eclipse update site URL: http://subclipse.tigris.org/update_1.4.x
* Install all
* Restart Eclipse
* Open SVN Perspective: SVN Repository Exploring. Add a SVN Repository location.
* Right click an Eclipse project, select the Team menu for SVN operations.

Install SVN on Apache 2

* See here for details.

Remove all subversion directories

Sometimes you want to remove a directory structure from subversion control. Simple remove all .svn folders. You can also use the following Ant target to do that. Important note is that you need to set defaultexcludes to false since .svn is one of the default excludes for Ant.

 
  <!-- - - - - - - - - - - - - - - - - -
          target: remove-svn
         - - - - - - - - - - - - - - - - - -->
    <target name="remove-svn">
      <delete includeemptydirs="true">
      <fileset dir="${basedir}" defaultexcludes="false">
          <include name="**/.svn/**"/>
      </fileset>
    </delete>
    </target>
 

Repository Access URLs

file:///
file:///x:/path/to/repos
http://
https://
svn://
svn+ssh://

Commands

Help

svn help 

Create a repository

svnadmin create C:\svn\repos1

List

svn list file:///c:/svn/repos1

Import

* Create directory structure to be imported.

project
-trunk
--mydir
---myfile.txt
-tags
-branches

* Go to project's parent directory and issue import command:

svn import project file:///c:/svn/repos1/project1 -m "Initial import of my project"
Adding         project\trunk
Adding         project\trunk\mydir
Adding         project\trunk\mydir\myfile.txt
Adding         project\branches
Adding         project\tags

Committed revision 1.

Checkout project

svn checkout file:///c:/svn/repos1/project1/trunk/mydir
A    mydir\myfile.txt
Checked out revision 1.

Checkout a particular revision

svn checkout --revision 1 file:///c:/svn/repos1/project1/trunk
A    trunk\mydir
A    trunk\mydir\myfile.txt
Checked out revision 1.

Update file

svn update

Update to a particular revision

svn update --revision 2
U    mydir\myfile.txt
Updated to revision 2.

Commit modified file

* Modify myfile.txt.
* Under mydir directory:

svn commit -m "Modified myfile.txt"
Sending        myfile.txt
Transmitting file data .
Committed revision 2.

View log

svn log myfile.txt
------------------------------------------------------------------------
r1 | JianmingLi | 2009-04-20 13:41:43 -0400 (Mon, 20 Apr 2009) | 1 line

Initial import of my project
------------------------------------------------------------------------

C:\Temp\svnwork\mydir>svn log myfile.txt
------------------------------------------------------------------------
r2 | JianmingLi | 2009-04-20 14:09:25 -0400 (Mon, 20 Apr 2009) | 1 line

Modified myfile.txt
------------------------------------------------------------------------
r1 | JianmingLi | 2009-04-20 13:41:43 -0400 (Mon, 20 Apr 2009) | 1 line

Initial import of my project
------------------------------------------------------------------------

svn log --revision 1:2
svn log -r 1:2

Add a new file to repository

* Create a new file in mydir directory.
* In mydir directory:

svn add addfile.txt
A         addfile.txt

svn commit -m "Add addfile.txt"
Adding         addfile.txt
Transmitting file data .
Committed revision 3.

Add all new files

svn add * --force

Copy file

* In mydir directory:

svn copy addfile.txt copyfile.txt
A         copyfile.txt

svn commit -m "Copy addfile to copyfile.txt"
Adding         copyfile.txt

Committed revision 4.

Delete file

svn delete addfile.txt
D         addfile.txt

svn commit -m "Delete addfile"
Deleting       addfile.txt

Committed revision 5.

Diff file

C:\Temp\svnwork\mydir>svn diff myfile.txt
Index: myfile.txt
=========================================
--- myfile.txt  (revision 2)
+++ myfile.txt  (working copy)
@@ -1 +1 @@
-modified text.
\ No newline at end of file
+modified text. modified again.
\ No newline at end of file

Revert changes

svn revert myfile.txt
Reverted 'myfile.txt'

svn diff myfile.txt

Print out a particular revision

svn cat --revision 1 myfile.txt
initial text.
svn cat --revision 2 myfile.txt
modified text.

List repository files

svn list file:///c:/svn/repos1/project1/trunk
mydir/

svn list file:///c:/svn/repos1/project1/trunk/mydir
copyfile.txt
myfile.txt

Cleanup work directory

svn cleanup

Backup repository

svnadmin hotcopy path/to/repo path/to/backup --clean-logs

References
SVN cheat sheet

Install Subversion 1.5 and Apache 2.2

Install Subverison 1.5

Download and unzip Subversion 1.5 binary built for Apache 2.2 (svn-win32-1.5.4.zip) from here

Install Apache 2.2

Download and install Apache 2.2 (apache_2.2.9-win32-x86-openssl-0.9.8h-r2.msi)

Integrate Subversion 1.5 with Apache 2.2

Enable SVN modules

* Copy from Subversion/bin directory to the Apache/modules directory.
mod_dav_svn.so
mod_authz_svn.so

* Add the Subversion/bin directory to the SYSTEM PATH so all the Subversion support dll's are visible to the Apache service.

* Edit the Apache configuration file (httpd.conf)

Uncomment:

 
#LoadModule dav_fs_module modules/mod_dav_fs.so
#LoadModule dav_module modules/mod_dav.so
 

Add:

 
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so
 

Use LDAP authentication

 
<Location /svn>
  DAV svn
  SVNPath your/repository/path
  #Use SVNParentPath if multiple svn repositories
 
  Order allow,deny
  Allow from all
  AuthType Basic
  AuthBasicProvider ldap
  AuthName "Subversion login"
  AuthzLDAPAuthoritative on
 
  #OpenLdap
  #AuthLDAPURL ldap://coe-soa-4/ou=Users,dc=example,dc=com
  #AuthLDAPBindDN "cn=Manager,dc=example,dc=com"
  #AuthLDAPBindPassword "secret"
 
  #Active directory note port 3268 NOT 389
  #AuthLDAPURL "ldap://adserver.company.com:3268/DC=company,DC=com?sAMAccountName?sub?(objectClass=user)"
  #AuthLDAPBindDN       ldap-auth-user@company.com
  #AuthLDAPBindPassword "the_password"
 
  Require valid-user
</Location>
 

Use local files for authentication

Add to httpd.conf

 
<Location /svn>
  DAV svn
  #SVNPath c:\path\to\repo
  #Use SVNParentPath if multiple svn repositories
  SVNParentPath C:\path\to\repo
  AuthType Basic
  AuthName "SVN Repository"
  AuthUserFile passwd
  AuthzSVNAccessFile authz
  Require valid-user
</Location>
 

Create passwd File

* Create passwd file

cd %Apache2%
bin\htpasswd -c passwd 

* Add additional users

bin\htpasswd passwd 

Create authz File

# Define some project groups
[groups]
project1-developers = user11, user12, user13
project2-developers = user21, user22, user23

# project1 usrs have read and write access to path1 and all sub folders
[path1:/]
@project1-developers = rw

# project2 users have read and write access to path2 and sub folders
# under the path 1 foler
[path1:/path2]
@project2-developers = rw

Restart Apache

Don't forget to restart Apache.

AnkhSVN Visual Studio 2005 Install

Install
-Download AnkhSVN (e.g. AnkhSVN 2.0.5250) from CollabNet download page at http://ankhsvn.open.collab.net/servlets/ProjectProcess?pageID=3794.
-Install by double clicking and accept all default options.
-Start VS2005
-Set current source control plug-in to AnkhSVN: Tools -> Options -> Source Control.

Browse Repository
-Start VS2005
-Open Repository Explorer (View -> Repository Explorer)
-Click the second icon under the Repository Explorer tab (a globe with a plus sign to the upper right) to add a new URL to repository
-Enter your SVN repository URL (e.g. svn://localhost/trunk/myproject)

Check Out A Directory
-Open Repository Explorer (View -> Repository Explorer)
-Highlight the directory to be checked out
-Click the first icon under the Repository Explorer tab (red heart icon with a green check mark to the lower right)
-Enter the destination folder to check out or accept the default location
-Select the revision to check out. Default to Head which is the most current revision.

Open A VS Solution
-Open a VS solution as usual. If the solution folder is checked out from SVN and AnkhSVN is set as current source control plug-in, you should see SVN icons replacing the usual Windows Explorer icons under the Solution Explorer.
-Right click entries under Solution Explorer (solution, project, file. etc.), a SVN context menu will be available for various SVN operations.