Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen Revision Vorhergehende Überarbeitung Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
becki:linux:svn_tips [2009-07-03 11:11] becki |
becki:linux:svn_tips [2015-11-04 14:32] (aktuell) becki |
||
---|---|---|---|
Zeile 2: | Zeile 2: | ||
===== Links == | ===== Links == | ||
- | - [[svnbook>|Svnbook]] | + | [[svnbook>1.5/|Svnbook]] - [[http://www.linux-magazin.de/heft_abo/ausgaben/2003/06/nachfolgemodell|SVN Intro]] (german) - [[CVS Tips]] - [[Mercurial Tips]] |
- | - [[http://www.linux-magazin.de/heft_abo/ausgaben/2003/06/nachfolgemodell|SVN Intro]] (german) | + | |
- | - [[CVS Tips]] | + | |
- | - [[HQ Tips]] | + | |
===== Apache Server Configuration == | ===== Apache Server Configuration == | ||
- | * Add the following to /etc/httpd/httpd.conf and restart Apache:<code> | + | * Uncomment or add the following to /etc/httpd/httpd.conf and restart Apache:<code> |
+ | LoadModule auth_digest_module lib/httpd/modules/mod_auth_digest.so | ||
+ | LoadModule dav_module lib/httpd/modules/mod_dav.so | ||
LoadModule dav_svn_module lib/httpd/modules/mod_dav_svn.so | LoadModule dav_svn_module lib/httpd/modules/mod_dav_svn.so | ||
LoadModule authz_svn_module lib/httpd/modules/mod_authz_svn.so | LoadModule authz_svn_module lib/httpd/modules/mod_authz_svn.so | ||
Zeile 25: | Zeile 24: | ||
</code> | </code> | ||
* Create the directiory ''/home/svn'' | * Create the directiory ''/home/svn'' | ||
- | * Add one or more users with [[install_config_tips#protect_a_directory_with_digest_authentication|htdigest]] | + | * Add one or more users with [[apache_httpd#protect_a_directory_with_digest_authentication|htdigest]] |
* Type ''svnadmin create /home/svn/test'' to create a repository called ''test'' | * Type ''svnadmin create /home/svn/test'' to create a repository called ''test'' | ||
* Type ''chown -R apache:apache /home/svn/*'' | * Type ''chown -R apache:apache /home/svn/*'' | ||
Zeile 31: | Zeile 30: | ||
===== svnserve Server Configuration == | ===== svnserve Server Configuration == | ||
+ | |||
+ | <note>This is not necessary if Apache Server (see above) is used!</note> | ||
+ | |||
==== Required == | ==== Required == | ||
- | Server OS is [[install_config_tips|Slackware Linux]] 11.0. Infos are collected from the [[svnbook>|svnbook]] and [[http://faleiros.eti.br/?q=svn|this site]]. The easiest alternative for running a svn server is used, i.e. ''svnserve'' as daemon. No apache, no SSH is used: | + | Server OS is [[install_config_tips|Slackware Linux]] 11.0. Infos are collected from the [[svnbook>1.5/|svnbook]] and [[http://faleiros.eti.br/?q=svn|this site]]. The easiest alternative for running a svn server is used, i.e. ''svnserve'' as daemon. No apache, no SSH is used: |
<code bash> | <code bash> | ||
Zeile 48: | Zeile 50: | ||
</code> | </code> | ||
- | Note: The svnserve process ist started as a separate user ''svn'' as [[svnbook>svn.serverconfig.choosing.html#svn.serverconfig.choosing.recommendations|recommended]]. This increases security, but seems to prevent local access via ''%%file:///home/svn/...%%'' urls. | + | Note: The svnserve process ist started as a separate user ''svn'' as [[svnbook>1.4/svn.serverconfig.choosing.html#svn.serverconfig.choosing.recommendations|recommended]]. This increases security, but seems to prevent local access via ''%%file:///home/svn/...%%'' urls. |
To start svnserve at boot time, append this to /etc/rc.d/rc.local: | To start svnserve at boot time, append this to /etc/rc.d/rc.local: | ||
su svn -c "/usr/bin/svnserve -d -r /home/svn" | su svn -c "/usr/bin/svnserve -d -r /home/svn" | ||
- | To give users access to the repository, edit /home/svn/conf/svnserv.conf and /home/svn/conf/passwd see [[svnbook>svn.serverconfig.svnserve.html#svn.serverconfig.svnserve.auth|Built-in authentication and authorization]] | + | To give users access to the repository, edit /home/svn/conf/svnserv.conf and /home/svn/conf/passwd see [[svnbook>1.4/svn.serverconfig.svnserve.html#svn.serverconfig.svnserve.auth|Built-in authentication and authorization]] |
==== Browser Interface Configuration == | ==== Browser Interface Configuration == | ||
Zeile 70: | Zeile 72: | ||
> mkdir -p $PKG/usr/lib/python2.4/site-packages | > mkdir -p $PKG/usr/lib/python2.4/site-packages | ||
> echo "/usr/lib/svn-python" > $PKG/usr/lib/python2.4/site-packages/svn.pth | > echo "/usr/lib/svn-python" > $PKG/usr/lib/python2.4/site-packages/svn.pth | ||
- | > | + | > |
</code> | </code> | ||
Zeile 92: | Zeile 94: | ||
Add user ''nobody'' (Apache) to group ''svn'' in ''/etc/group'' to give Apache read permission for the svn repository. Then restart Apache and point your browser to http://server-hostname/cgi-bin/viewvc.cgi/. | Add user ''nobody'' (Apache) to group ''svn'' in ''/etc/group'' to give Apache read permission for the svn repository. Then restart Apache and point your browser to http://server-hostname/cgi-bin/viewvc.cgi/. | ||
+ | |||
+ | ===== Other Administration == | ||
+ | ==== Rename a Repostitory == | ||
+ | |||
+ | Just use normal ''mv'' as root. [[http://svnbook.red-bean.com/en/1.7/svn.reposadmin.maint.moving-and-removing.html|See also]] | ||
+ | |||
+ | ==== Locks == | ||
+ | |||
+ | View and remove locks: | ||
+ | svnadmin lslocks /local/path/to/repo | ||
+ | svnadmin rmlocks /local/path/to/repo | ||
+ | |||
+ | Clients can remove own and other locks as well. See below! | ||
+ | |||
+ | [[svnbook>1.7/svn.ref.html|more]] | ||
===== Client Configuration == | ===== Client Configuration == | ||
- | If you use the provieded command line svn client no config at all is necessary. This is also true if [[cygwin]] is used as environment. Username and password are stored automatically after first login, see [[svnbook>svn.serverconfig.netmodel.html#svn.serverconfig.netmodel.credcache|client credentials caching]]. | + | If you use the provieded command line svn client no config at all is necessary. This is also true if [[cygwin]] is used as environment. Username and password are stored automatically after first login, see [[svnbook>1.4/svn.serverconfig.netmodel.html#svn.serverconfig.netmodel.credcache|client credentials caching]]. |
===== Client Usage == | ===== Client Usage == | ||
Zeile 101: | Zeile 118: | ||
Commands refere to the SVN command line client which comes with SVN. Snytax for usage of SVN over HTTP is used. If the svnserve protocol is used, just replace ''%%http://%%'' with ''%%svn://%%''. | Commands refere to the SVN command line client which comes with SVN. Snytax for usage of SVN over HTTP is used. If the svnserve protocol is used, just replace ''%%http://%%'' with ''%%svn://%%''. | ||
- | [[svnbook>svn.ref.html|Subversion Complete Reference]] | + | [[svnbook>1.4/svn.ref.html|Subversion Complete Reference]] |
==== First Import == | ==== First Import == | ||
- | Create a project. 3 directories are [[svnbook>svn.branchmerge.maint.html|recommended]]: | + | Create a project. 3 directories are [[svnbook>1.4/svn.branchmerge.maint.html|recommended]]: |
becki@client:~/test$ tree testproj/ | becki@client:~/test$ tree testproj/ | ||
Zeile 115: | Zeile 132: | ||
The import command imports the ''testproj'' project to the root dir of the repostitory also as project ''testproj'' | The import command imports the ''testproj'' project to the root dir of the repostitory also as project ''testproj'' | ||
+ | |||
becki@client:~/test$ svn import testproj http://<servername>/<svnrootdir>/<reponame>/testproj | becki@client:~/test$ svn import testproj http://<servername>/<svnrootdir>/<reponame>/testproj | ||
Zeile 135: | Zeile 153: | ||
The status seems to be always against the current head revision number of the //local copy//, not of the head of the repository. Therefore it is advisable to run ''svn update'' before. | The status seems to be always against the current head revision number of the //local copy//, not of the head of the repository. Therefore it is advisable to run ''svn update'' before. | ||
- | See [[svnbook>svn.ref.svn.c.status.html]] | + | See [[svnbook>1.4/svn.ref.svn.c.status.html]] |
svn info | svn info | ||
Zeile 159: | Zeile 177: | ||
Brings the current dir into the state of revision of <refNumber> of the repository (and preserves local changes :?:). ''svn info'' reveals the revision of the current working dir. | Brings the current dir into the state of revision of <refNumber> of the repository (and preserves local changes :?:). ''svn info'' reveals the revision of the current working dir. | ||
+ | |||
+ | ==== Move Files and Dirs == | ||
+ | |||
+ | svn move <from> <to> | ||
+ | |||
+ | Works just like the shell ''mv'' command :-) See [[svnbook>1.4/svn.ref.svn.c.move.html]] | ||
+ | |||
+ | ==== Give up working copy == | ||
+ | |||
+ | According to http://svn.haxx.se/dev/archive-2002-08/1385.shtml there is no command like the ''release'' of CVS. Just delete the working copy locally. | ||
+ | |||
+ | ==== Branching == | ||
+ | === Intro == | ||
+ | |||
+ | A branch is created simply by [[svnbook>1.5/svn.branchmerge.using.html#svn.branchmerge.using.create|making a copy]] of the project. SVN knows only how to copy. Copies may have the [[svnbook>1.5/svn.branchmerge.using.html#svn.branchmerge.using.concepts|meaning]] of branches or tags. | ||
+ | |||
+ | It is recommended to do the copy on the server, not locally. The remote copy also includes the commit in one step. Eg: | ||
+ | |||
+ | svn cp http://url/project/trunk http://url/project/branches/foo -m "Creating a branch for working on feature foo" | ||
+ | svn checkout http://url/project/branches/foo | ||
+ | |||
+ | project | ||
+ | |-- branches | ||
+ | | `-- foo | ||
+ | |-- tags | ||
+ | `-- trunk | ||
+ | |||
+ | |||
+ | === Use Cases == | ||
+ | |||
+ | * Try out a new feature in a separate branch without disturbing the trunk | ||
+ | * Create a branch from an older revision to make a bug fix | ||
+ | * FIXME Create client-specific variants of the same main project eg. for special needs of customers | ||
+ | |||
+ | ==== Merging == | ||
+ | === Intro == | ||
+ | |||
+ | <note tip>Merging ([[svnbook>1.5/svn.branchmerge.advanced.html#svn.branchmerge.advanced.advancedsyntax|explanation]] / [[svnbook>1.5/svn.ref.svn.c.merge.html|manpage]]): Apply the changes between repository tree X and repository tree Y into the working directory. Any revision on any branch is a repository tree.</note> | ||
+ | |||
+ | * FIXME Verify: Merging is not symmetrical, i.e. if a line was added to a file between rev X and rev Y, than ''merge X Y'' will add that line to the file in the working dir and ''merge Y X'' will //remove// that line! | ||
+ | * Merging can not just happen between branches, but also between older revisions in the same branch | ||
+ | * Merging does not always need to cover the whole project, it can be restricted to subdirs or single files. See also [[svnbook>1.5/svn.branchmerge.basicmerging.html]] -> selectively “copy” changes | ||
+ | * Have a //clean// working directory before merging :!: | ||
+ | * It is also possible to specify only one repository tree source (e.g. the tunk) with the merge command. In this case, all modifications of the trunk since you first created your branch (which you work on) are applied to the working dir. Used e.g to [[svnbook>1.5/svn.branchmerge.basicmerging.html#svn.branchemerge.basicmerging.stayinsync|keep a branch in sync]]. | ||
+ | * For merging finishd branches which are to be discontinued and merged back into the trunk, the ''--reintegrate'' option is [[svnbook>1.5/svn.branchmerge.basicmerging.html#svn.branchemerge.basicmerging.stayinsync|necssary]] | ||
+ | * AFAIK it is not possible to easily keep two branches in sync (merge in both directions) like in [[mercurial_tips#merging|Mercurial]]. Basic merging in SVN is meant to frequently update branches from the trunk and finally reintegrate the branch into the trunk. To keep two branches in sync, advanced merging (with manual bookkeeping about what has already been merged) is necessary. | ||
+ | |||
+ | === Use Cases == | ||
+ | |||
+ | * Merge a new feature in a separate branch into the trunk | ||
+ | * Merge bug fixes of an older revision into the trunk | ||
+ | * FIXME Merge common parts of client-specific branches | ||
+ | * Undo committed Changes, see below | ||
+ | |||
==== Undoing Changes == | ==== Undoing Changes == | ||
=== Undoing lokal Changes == | === Undoing lokal Changes == | ||
- | See [[svnbook>svn.ref.svn.c.revert.html|revert]] | + | See [[svnbook>1.4/svn.ref.svn.c.revert.html|revert]] |
=== Undoing committed Changes == | === Undoing committed Changes == | ||
- | See [[svnbook>svn.branchmerge.commonuses.html]] -> Undoing Changes | + | svn merge [--dry-run] -r 627:480 http://url/project |
- | ==== Move Files and Dirs == | + | This command removes all changes which have been done between r480 and r627 //in the workin copy//. Afterwards a commit is necessary. |
- | svn move <from> <to> | + | See also [[svnbook>1.4/svn.branchmerge.commonuses.html]] -> Undoing Changes |
+ | |||
+ | === Commit Log Message Correction == | ||
+ | |||
+ | Example: | ||
+ | svnadmin setlog /path/to/repository --bypass-hooks logmessage.txt -r 25120 | ||
+ | |||
+ | See also: [[svnbook>1.5/svn.reposadmin.maint.html#svn.reposadmin.maint.setlog|Svnbook]] | ||
+ | |||
+ | ==== Locks == | ||
+ | |||
+ | View locks: | ||
+ | svn st -u | ||
+ | |||
+ | * O: Lock from someone else | ||
+ | * K: Own lock | ||
+ | |||
+ | Create and remove locks: | ||
+ | svn lock file | ||
+ | svn unlock file | ||
+ | |||
+ | [[svnbook>1.7/svn.advanced.locking.html|more]] -> from "Discovering Locks" on | ||
- | Work just like shell ''mv'' command :-) See [[svnbook>svn.ref.svn.c.move.html]] | ||
- | ==== Give up working copy == | ||
- | According to http://svn.haxx.se/dev/archive-2002-08/1385.shtml there is no command like the ''release'' of CVS. Just delete the working copy locally. | ||