Difference between revisions of "Subversion"

From Organic Design wiki
(typos etc)
(Change source-code blocks to standard format)
(45 intermediate revisions by 4 users not shown)
Line 1: Line 1:
[[Category:Projects]][[Category:peerix]]
+
MediaWiki's SVN uses SSH public key so you don't need a password, so you'll need to supply your ~/.ssh/id_rsa.pub file to the person setting up your [[MW:Commit access|commit access]] (if that files doesn't exist, run ssh-keygen from non-root shell using blank passwd when prompted, see [http://www.debian.org/devel/passwordlessssh this link] for details). Also, you need to set up your [[MW:Subversion/auto-props|auto-props]]. Note also that the commit's are automatically shown on the ''#mediawiki'' IRC channel (see [http://freenode.net/faq.shtml freenode FAQ] re registering a nickname etc) so it's good to have that open when working on the MediaWiki code.
*http://svn.peerix.org/peerix
 
*http://svn.organicdesign.co.nz/peerix
 
=Overview=
 
The typical work cycle looks like this:
 
  
;Update your working copy
+
== The WikiMedia repository ==
 +
See [[MW:Subversion]] for details about using MediaWikis SVN. Here's some examples showing retrieval of the current version of the code-base, the current version of an extension, and a version of an extension for MediaWiki 1.16 respectively.
 +
<source lang="bash">
 +
svn co http://svn.wikimedia.org/svnroot/mediawiki/trunk/phase3
  
svn update
+
svn co http://svn.wikimedia.org/svnroot/mediawiki/trunk/extensions/TreeAndMenu
  
;Make changes
+
svn co http://svn.wikimedia.org/svnroot/mediawiki/branches/REL1_16/extensions/TreeAndMenu
 +
</source>
  
svn add
+
== Usage ==
svn delete
+
The most important command to know is how to get help;
svn copy
+
<source>
  svn move
+
svn help
 +
svn help checkout # Help on check(ing)out project to CLIENT copy
 +
svn help commmit # Help on commit(ting) changes to SERVER
 +
</source>
  
;Examine your changes
 
  
svn status
+
To obtain a log of the changes made in a svn project;
svn diff
+
<source>
 +
svn log -v http://[PATH TO SERVER SVN PROJECT]
 +
</source>
  
;Possibly undo some changes
 
  
svn revert
+
Or to get changes between a certain date range in a local repo;
 +
<source>
 +
svn log -r {2012-02-10}:{2012-02-15}
 +
</source>
  
;Resolve Conflicts (Merge Others' Changes)
 
  
svn update
+
To create a new repository on the server ready for importing a directory of files;
svn resolved
+
<source>
 +
cd /tmp
 +
mkdir SERVER
 +
svnadmin create /tmp/SERVER/newrepos
 +
</source>
  
;Commit your changes
 
svn commit
 
 
=Usage=
 
The most important command to know is how to get help;
 
svn help
 
svn help checkout # Help on check(ing)out project to CLIENT copy
 
svn help commmit  # Help on commit(ting) changes to SERVER
 
 
To create a new repository on the server ready for importing a directory of files;
 
cd /tmp
 
mkdir SERVER
 
svnadmin create /tmp/SERVER/newrepos
 
  
 
This creates a concise database directory for the new repository on the SERVER in the directory called /tmp/SERVER;
 
This creates a concise database directory for the new repository on the SERVER in the directory called /tmp/SERVER;
<pre>
+
<source>
 
ls -l /tmp/SERVER/newrepos
 
ls -l /tmp/SERVER/newrepos
 
total 16
 
total 16
Line 55: Line 51:
 
drwxr-xr-x  11 User  wheel  374 Apr  3 13:58 hooks
 
drwxr-xr-x  11 User  wheel  374 Apr  3 13:58 hooks
 
drwxr-xr-x    4 User  wheel  136 Apr  3 13:58 locks
 
drwxr-xr-x    4 User  wheel  136 Apr  3 13:58 locks
</pre>
+
</source>
 +
 
 +
 
 
Create an example directory for upload;
 
Create an example directory for upload;
cd /tmp
+
<source>
mkdir MYTREE
+
cd /tmp
echo '#!/usr/bin/perl -w\nprint "hello world";' > /tmp/MYTREE/helloWorld.pl
+
mkdir MYTREE
svn import /tmp/MYTREE file:///tmp/SERVER/newrepos/some/project
+
echo '#!/usr/bin/perl -w\nprint "hello world";' > /tmp/MYTREE/helloWorld.pl
 +
svn import /tmp/MYTREE file:///tmp/SERVER/newrepos/some/project
 +
</source>
 +
 
  
 
Listing the contents in the repository directory path;
 
Listing the contents in the repository directory path;
svn list file:///tmp/SERVER/newrepos/some/project
+
<source>
 +
svn list file:///tmp/SERVER/newrepos/some/project
 +
</source>
 +
 
  
 
To make a local copy you need to use the checkout command. This creates a new directory (default called newrepos) which is a local copy of newrepos.
 
To make a local copy you need to use the checkout command. This creates a new directory (default called newrepos) which is a local copy of newrepos.
 +
<source>
 +
mkdir CLIENT
 +
cd CLIENT
 +
svn co file:///tmp/SERVER/newrepos/some/project/  # fetches project/test.pl
 +
svn co file:///tmp/SERVER/newrepos/some/          # fetches some/project/test.pl
 +
rm -rf /tmp/CLIENT 
 +
svn co file:///tmp/SERVER/newrepos/some/project/ /tmp/CLIENT # Creates CLIENT dir
 +
</source>
 +
''Note: The directory the svn command is run in determines where the local checkout directories and files will end up.''
  
mkdir CLIENT
 
cd CLIENT
 
svn co file:///tmp/SERVER/newrepos/some/project/  # fetches project/test.pl
 
svn co file:///tmp/SERVER/newrepos/some/          # fetches some/project/test.pl
 
rm -rf /tmp/CLIENT 
 
svn co file:///tmp/SERVER/newrepos/some/project/ /tmp/CLIENT # Creates CLIENT dir
 
 
''Note: The directory the svn command is run in determines where the local checkout directories and files will end up.''
 
  
 
Now that you have created a local copy all work should be conducted within it. There is a hidden directory called ''.svn'' which contains all the information required for the svn framework;
 
Now that you have created a local copy all work should be conducted within it. There is a hidden directory called ''.svn'' which contains all the information required for the svn framework;
 +
<source>
 +
cd /tmp/CLIENT # Work in the local copy of svn
 +
</source>
  
cd /tmp/CLIENT # Work in the local copy of svn
 
  
 
To update a file on your CLIENT directory;
 
To update a file on your CLIENT directory;
cd /tmp/CLIENT
+
<source>
svn update # "." is updated  
+
cd /tmp/CLIENT
cd /tmp
+
svn update # "." is updated  
svn update /tmp/CLIENT # Specifying path
+
cd /tmp
 +
svn update /tmp/CLIENT # Specifying path
 +
</source>
 +
 
  
 
To add a new file to the local svn copy, first make a new file within the directory structure;
 
To add a new file to the local svn copy, first make a new file within the directory structure;
cd /tmp/CLIENT
+
<source>
echo '#!/usr/bin/perl -w\nprint qq(hello world!);' > /tmp/CLIENT/helloWorld2.pl
+
cd /tmp/CLIENT
svn add helloWorld2.pl
+
echo '#!/usr/bin/perl -w\nprint qq(hello world!);' > /tmp/CLIENT/helloWorld2.pl
 +
svn add helloWorld2.pl
 +
</source>
 +
 
  
 
The ''status'' command will identify differences between the CLIENT copy and the SERVER copy of the repoistory;
 
The ''status'' command will identify differences between the CLIENT copy and the SERVER copy of the repoistory;
svn status /tmp/CLIENT
+
<source>
 +
svn status /tmp/CLIENT
 +
</source>
 +
 
 +
 
 
The following list provides the details of ''svn status'' output;
 
The following list provides the details of ''svn status'' output;
<pre>
+
<source>
L   abc.c              # svn has a lock in its .svn directory for abc.c
+
L     abc.c              # svn has a lock in its .svn directory for abc.c
 
M      bar.c              # the content in bar.c has local modifications
 
M      bar.c              # the content in bar.c has local modifications
M     baz.c              # baz.c has property but no content modifications
+
M     baz.c              # baz.c has property but no content modifications
 
X      3rd_party          # this dir is part of an externals definition
 
X      3rd_party          # this dir is part of an externals definition
 
?      foo.o              # svn doesn't manage foo.o
 
?      foo.o              # svn doesn't manage foo.o
Line 109: Line 126:
 
C      stuff/loot/lump.c  # this file has conflicts from an update
 
C      stuff/loot/lump.c  # this file has conflicts from an update
 
R      xyz.c              # this file is scheduled for replacement
 
R      xyz.c              # this file is scheduled for replacement
    S stuff/squawk        # this file or dir has been switched to a branch
+
S     stuff/squawk        # this file or dir has been switched to a branch
</pre>
+
</source>
 +
 
 +
=== Problems ===
 +
When attempting to import the ''/var/www'' structure into the ''/var/svn/www'' repository it bailed after coming across a filename containing special characters with the following fatal error:
 +
<source>
 +
svn: Can't convert string from native encoding to 'UTF-8':
 +
svn: A?\195?\164o?\195?\188.gif
 +
</source>
  
To upload the CLIENT copy changes to the SERVER copy use the ''commit'' command;
+
== SVN GUI's ==
svn commit /tmp/CLIENT
+
*[http://websvn.tigris.org/ WebSVN]
 
+
*Linux: [http://www.alwins-world.de/wiki/programs/kdesvn/ kdesvn] ''- and many others
Cleaning up directories in ''/tmp'';
+
*Windows: [http://tortoisesvn.net/downloads tortoisesvn]
rm -rf /tmp/SERVER /tmp/CLIENT /tmp/MYTREE
+
*Macos: [http://www.apple.com/downloads/macosx/development_tools/svnx.html svnx]
  
=External Links=
+
== See also ==
*[http://www.onlamp.com/pub/a/bsd/2005/08/11/FreeBSD_Basics.html?page=1 Secure subversion]
+
*[[Configure SVN]] ''- our procedure for setting up SVN and WebSVN on our servers''
*[http://www.chiark.greenend.org.uk/~sgtatham/svn.html cvs to svn Experiences]
+
*[[MediaWiki SVN Statistics]]
*[http://www.abbeyworkshop.com/howto/misc/svn01/ subversion cheatsheet]
+
*[http://www.abbeyworkshop.com/howto/misc/svn01/ Subversion cheatsheet]
*[http://centerstageproject.com/wiki/index.php/SVN_Tutorial Centrestage tutorial]
 
*[http://wiki.fhcrc.org/bioc/SvnHowTo BioConductor SVN tutorial]
 
 
*[http://svnbook.red-bean.com/nightly/en/index.html Subversion book]
 
*[http://svnbook.red-bean.com/nightly/en/index.html Subversion book]
**[http://svnbook.red-bean.com/nightly/en/svn.intro.html Subversion Quick-Start Guide]
+
*[http://vis.cs.ucdavis.edu/~ogawa/codeswarm CodeSwarm] ''- renders video's of subversion repository activity''
 +
*[http://home.introweb.nl/d/dodger/svnauthor.html Changing the username of a revision]
 +
[[Category:Subversion]]

Revision as of 16:54, 22 May 2015

MediaWiki's SVN uses SSH public key so you don't need a password, so you'll need to supply your ~/.ssh/id_rsa.pub file to the person setting up your commit access (if that files doesn't exist, run ssh-keygen from non-root shell using blank passwd when prompted, see this link for details). Also, you need to set up your auto-props. Note also that the commit's are automatically shown on the #mediawiki IRC channel (see freenode FAQ re registering a nickname etc) so it's good to have that open when working on the MediaWiki code.

The WikiMedia repository

See MW:Subversion for details about using MediaWikis SVN. Here's some examples showing retrieval of the current version of the code-base, the current version of an extension, and a version of an extension for MediaWiki 1.16 respectively.

svn co http://svn.wikimedia.org/svnroot/mediawiki/trunk/phase3

svn co http://svn.wikimedia.org/svnroot/mediawiki/trunk/extensions/TreeAndMenu

svn co http://svn.wikimedia.org/svnroot/mediawiki/branches/REL1_16/extensions/TreeAndMenu

Usage

The most important command to know is how to get help;

svn help
svn help checkout # Help on check(ing)out project to CLIENT copy
svn help commmit  # Help on commit(ting) changes to SERVER


To obtain a log of the changes made in a svn project;

svn log -v http://[PATH TO SERVER SVN PROJECT]


Or to get changes between a certain date range in a local repo;

svn log -r {2012-02-10}:{2012-02-15}


To create a new repository on the server ready for importing a directory of files;

cd /tmp
mkdir SERVER
svnadmin create /tmp/SERVER/newrepos


This creates a concise database directory for the new repository on the SERVER in the directory called /tmp/SERVER;

ls -l /tmp/SERVER/newrepos
total 16
-rw-r--r--    1 User  wheel  379 Apr  3 13:58 README.txt
drwxr-xr-x    4 User  wheel  136 Apr  3 13:58 conf
drwxr-xr-x    2 User  wheel   68 Apr  3 13:58 dav
drwxr-xr-x   10 User  wheel  340 Apr  3 13:58 db
-r--r--r--    1 User  wheel    2 Apr  3 13:58 format
drwxr-xr-x   11 User  wheel  374 Apr  3 13:58 hooks
drwxr-xr-x    4 User  wheel  136 Apr  3 13:58 locks


Create an example directory for upload;

cd /tmp
mkdir MYTREE
echo '#!/usr/bin/perl -w\nprint "hello world";' > /tmp/MYTREE/helloWorld.pl
svn import /tmp/MYTREE file:///tmp/SERVER/newrepos/some/project


Listing the contents in the repository directory path;

svn list file:///tmp/SERVER/newrepos/some/project


To make a local copy you need to use the checkout command. This creates a new directory (default called newrepos) which is a local copy of newrepos.

mkdir CLIENT
cd CLIENT
svn co file:///tmp/SERVER/newrepos/some/project/  # fetches project/test.pl
svn co file:///tmp/SERVER/newrepos/some/          # fetches some/project/test.pl
rm -rf /tmp/CLIENT  
svn co file:///tmp/SERVER/newrepos/some/project/ /tmp/CLIENT # Creates CLIENT dir

Note: The directory the svn command is run in determines where the local checkout directories and files will end up.


Now that you have created a local copy all work should be conducted within it. There is a hidden directory called .svn which contains all the information required for the svn framework;

cd /tmp/CLIENT # Work in the local copy of svn


To update a file on your CLIENT directory;

cd /tmp/CLIENT
svn update # "." is updated 
cd /tmp
svn update /tmp/CLIENT # Specifying path


To add a new file to the local svn copy, first make a new file within the directory structure;

cd /tmp/CLIENT
echo '#!/usr/bin/perl -w\nprint qq(hello world!);' > /tmp/CLIENT/helloWorld2.pl
svn add helloWorld2.pl


The status command will identify differences between the CLIENT copy and the SERVER copy of the repoistory;

svn status /tmp/CLIENT


The following list provides the details of svn status output;

L      abc.c               # svn has a lock in its .svn directory for abc.c
M      bar.c               # the content in bar.c has local modifications
M      baz.c               # baz.c has property but no content modifications
X      3rd_party           # this dir is part of an externals definition
?      foo.o               # svn doesn't manage foo.o
!      some_dir            # svn manages this, but it's either missing or incomplete
~      qux                 # versioned as file/dir/link, but type has changed
I      .screenrc           # svn doesn't manage this, and is configured to ignore it
A  +   moved_dir           # added with history of where it came from
M  +   moved_dir/README    # added with history and has local modifications
D      stuff/fish.c        # this file is scheduled for deletion
A      stuff/loot/bloo.h   # this file is scheduled for addition
C      stuff/loot/lump.c   # this file has conflicts from an update
R      xyz.c               # this file is scheduled for replacement
S      stuff/squawk        # this file or dir has been switched to a branch

Problems

When attempting to import the /var/www structure into the /var/svn/www repository it bailed after coming across a filename containing special characters with the following fatal error:

svn: Can't convert string from native encoding to 'UTF-8':
svn: A?\195?\164o?\195?\188.gif

SVN GUI's

See also