Changes

Jump to navigation Jump to search
6,202 bytes added ,  15:44, 6 December 2012
no edit summary
** a branches directory to contain branch copies
** and a tags directory to contain tag copies.
<pre>/proj1/trunk
/proj1/branches
/proj1/tags
 
/proj2/trunk
/proj2/branches
/proj2/tags
 
/proj3/trunk
...</pre>
==Getting Started==
* svn help <command>
* svnadmin create /var/svn/newrepos* svn admin create makedir file:///var/svn/newrepos/some/trunk -m "Setting up repository structure"
* svn import mytree file:///var/svn/newrepos/some/project -m "Initial Import"
* svn list file:///var/svn/newrepos/some/project
* svn status --verbose
* svn log = display the history of changes to a file or directory
* Remember to use the full path AS IT EXISTS ON THE SERVER if using svn+ssh, ex: svn co svn+ssh://iicbu2/srv/svn/repositories/iicbu
==typical work cycle==
* D - file is scheduled for deletion
* M - file has local modificaations
 
==Branching and Merging==
<pre>svn copy http://svn.example.com/repos/calc/trunk \
http://svn.example.com/repos/calc/branches/my-calc-branch \
-m "Creating a private branch of /calc/trunk."</pre>
* svn checkout http://svn.example.com/repos/calc/branches/my-calc-branch
* changeset = a collection of changes with a unique name. The changes might include textual edits to file contents, modifications to tree structure, or tweaks to meta data. "A patch with a name you can refer to."
** Compare tree N with tree N-1 derives the exact patch committed.
** "This issue was fixed by r9238"
** run svn log -r 9238 to read about the exact changeset that fixed the bug
** run svn diff -c 9238 to see the patch itself
* svn merge -c 9238 = merge changeset r9238 into your working copy
* svn merge -r LastRevisionMergedFromTrunkToBranch:HEAD url/of/trunk path/to/branch/wc
* svn switch http://svn.example.com/repos/calc/branches/my-calc-branch
** switch transforms an existing working copy to reflect a different branch
*# Copy the project's entire “trunk” to a new branch directory.
*# Switch only part of the trunk working copy to mirror the branch.
** That way, the user can continue to receive normal “trunk” updates to most of her working copy, but the switched portions will remain immune (unless someone commits a change to her branch)
* If you decided to save your local edits to its own branch
<pre>svn copy http://svn.example.com/repos/proj/trunk \
http://svn.example.com/repos/proj/branches/newbranch \
-m "Create branch 'newbranch'."</pre>
** then
<pre>svn switch http://svn.example.com/repos/proj/branches/newbranch</pre>
** The svn switch command, like svn update, preserves your local edits. At this point, your working copy is now a reflection of the newly created branch, and your next svn commit invocation will send your changes there.
===Merging in changes from the trunk===
# First make sure your working copy of the branch is “clean”—that it has no local modifications reported by svn status
# svn merge URL = merge all recent changes from the URL to the current working directory (which is typically the root of your working copy)
# svn status
# look at the changes carefully with svn diff
# build and test your branch
# can always abort the local changes by running svn revert . -R
# svn commit -m "Merged latest trunk changes to my-calc-branch."
* Note: using patch is inferior to merge since patch cannot track changes to directory structure.
===Merge your changes back to the trunk===
# Merge in all changes from trunk and commit your branch as above
# Get an up-to-date clean (no local edits) working copy of the trunk
# svn merge --reintegrate http://svn.example.com/repos/my_branch
# delete your branch using "svn delete http://svn.example.com/repos/the_proj/branches/my-branch -m "Remove my-branch.""
===Create Tag===
* create a tag
<pre>svn copy http://svn.example.com/repos/calc/trunk \
http://svn.example.com/repos/calc/tags/release-1.0 \
-m "Tagging the 1.0 release of the 'calc' project."</pre>
* tag my working copy
<pre>svn copy my-working-copy \
http://svn.example.com/repos/calc/tags/mytag \
-m "Tag my existing working copy state."</pre>
===Branch Maintenance===
* restore deleted
<pre>svn copy http://svn.example.com/repos/calc/branches/my-calc-branch@374 \
http://svn.example.com/repos/calc/branches/my-calc-branch \
-m "Restore my-calc-branch."</pre>
* tag a stable point
<pre>svn copy http://svn.example.com/repos/calc/trunk \
http://svn.example.com/repos/calc/branches/stable-1.0 \
-m "Creating stable branch of calc project."</pre>
==Administration==
* [http://www.linuxfromscratch.org/blfs/view/svn/general/svnserver.html Step-by-step directions]
* do everything as root
* svnadmin create /var/svn/repos
* svn mkdir file:///srv/svn/repositories/iicbu/wndchrm -m "Setting up repository structure"
* make hooks by copying hook template files to the appropriate location
 
* now go to <repository>/conf/
** IF YOU HAVE AUTHORIZATION FAILED ERRORS, THIS IS HOW YOU FIX THEM
* svnserv.conf = control configuration of the svnserve daemon
*# uncomment "anon-access = read"
*# uncomment "auth-access = write"
*# uncomment "password-db = passwd"
*# make up a good realm and add realm
* passwd
*# add authorized checker-inners and their passwords
* chown -R svn:svntest /srv/svn/repositories/svntest
* chmod -R g+w /srv/svn/repositories/svntest
* chmod g+s /srv/svn/repositories/svntest/db
===setting root directory for svn access===
* looks like you specify the root using the svnserve daemon
<pre>
colettace@iicbu2 /srv/svn/repositories/iicbu/conf
$ ps aux | grep svnserve
svn 2590 0.0 0.0 10320 760 ? Ss 16:11 0:00 /usr/bin/svnserve.orig -d --threads --root /srv/svn/repositories/
</pre>
 
==Server Configuration==
* If you need to integrate with existing legacy identity systems (LDAP, Active Directory, NTLM, X.509, etc.), you must use either the Apache-based server or svnserve configured with SASL.
* If you've decided to use either Apache or stock svnserve, create a single svn user on your system and run the server process as that user. Be sure to make the repository directory wholly owned by the svn user as well. From a security point of view, this keeps the repository data nicely siloed and protected by operating system filesystem permissions, changeable by only the Subversion server process itself.
* [http://www.svnforum.org/2017/viewtopic.php?t=281 init.d script for fedora/redhat]
==Repository Hooks==
# On a repository that you've already set up, navigate on command line to /path/to/repos/hooks/ and there will be template files there for each event type.
# just remove the .tmpl extension and svn will run that.
* post-commit
==svnlook==
* svnlook date /path/to/repos/
2,466

edits

Navigation menu