Subversion: Difference between revisions

From miki
Jump to navigation Jump to search
(Created page with '<source lang="bash"> svn co svn+ssh://ftp.noekeon.org/opt/www/daemenj/web/private/SVN/Keccak </source>')
 
 
(9 intermediate revisions by the same user not shown)
Line 1: Line 1:
== References ==
* http://subversion.apache.org/, home of Apache SubVersion
* [http://www.collab.net/community/subversion/articles/merge-info.html Subversion 1.5 Mergeinfo - Understanding the Internals]

== Configuration ==
<ul>
<li> '''Colored diff''' &mdash; Either define ''colordiff'' as <tt>diff-cmd</tt> in <tt>~/.subversion/config</tt>:</li>
<source lang="text">
diff-cmd = colordiff
</source>
However, to keep the internal svn diff tool, you need to define your own function & alias. This will also highlight diff header in green:
<source lang="bash">
function svnwrap()
{
if [ "$1" = "diff" ] ; then
"svn" "$@" | colordiff | less -FRX
else
"svn" "$@"
fi
}
alias svn=svnwrap
</source>
To page the output, use <code>| less -R</code>
</ul>

== Workflows ==
=== Create default folder layout ===
From [http://stackoverflow.com/questions/3859009/how-to-create-a-subversion-repository-with-standard-layout]:
<source lang=bash>
url=svn://somewhere
svn mkdir $url/$1/trunk $url/$1/branches $url/$1/tags -m "New project $1" --parents
</source>

Or on a repository that is already checked out:
<source lang=bash>
svn mkdir trunk branches tags
svn mv src trunk # Assuming we already have a dir 'src' that needs to be moved to trunk
svn commit -m "create default layout"
</source>

=== Branch integration ===
From [http://stackoverflow.com/questions/102472/subversion-branch-reintegration]:

* Create a new branch off the trunk
* Work on the branch
* Merge (reintegrate) the branch into trunk
<source lang=bash>
cd trunk
svn merge --reintegrate ^/branches/topic
svn commit
# Committed revision 555.
# # this revision is ^^^^ important
</source>
* From now on:
** Either delete the branch<br/><source lang=bash>
svn delete ^/branches/topic
</source>
** Or merge trunk back to the branch so that '''subsequent merges do not generate conflicts'''.<br/>This steps is necessary to tell svn that it should ignore the merged revision on the trunk at the next branch reintegration):
<source lang=bash>cd branches/topic
svn merge --record-only -c 555 ^trunk
svn commit
</source>

== Commands ==
=== status (st) ===
Show modified/new/... files in the working copy.
<source lang=bash>
svn status
</source>

=== propget (pg) ===
<source lang=bash>
svn propget svn:mergeinfo
</source>

=== info ===
<source lang=bash>
svn info .
svn info /dir/file
</source>

== HTTPS Client Certificates ==
References:
* [http://svn.cacert.org/CAcert/Sysadm/client-certificate-guide.pdf SVN Client Certificate Guide]
* [http://stylesen.org/subversion_client_authentication_using_pkcs_12_based_certificates_howto Subversion client authentication using PKCS#12 based certificates - howto]

Besides requiring a password, access to a svn repository through HTTPS may also require a client-side certificate. In that case, svn is smart enough to prompt for the location of the file containing the certificate and private key and for the password.

This can also be configured in the file <tt>~/.subversion/servers</tt>:

<source lang=bash>
[groups]
myserver = *.myserver.org

# This contains the settings for group "myserver".
# ! paths must be absolute !
# Client certificates are in format .p12 (same as .pfx), as generated by openssl pkcs12
[myserver]
#The file containing your client certificate
ssl-client-cert-file = /home/user/.subversion/clientcert.p12
#This gives a list of CA to use to authenticate the server certificate
ssl-authority-files = /absolute/path/to/cacert.pem,/absolute/path/to/root.pem

# Add the following to prevent SVN storing your passwords:
[auth]
store-passwords = no
store-auth-creds = no
</source>


'''Changing the client certificate password'''

See [[SSL]] for instructions on how to change the client certificate password.

== Server Admin ==
=== Delete latest revision from database ===
The trick is to create a dump of all revisions we want, and import them again with <code>svnadmin</code>.

For instance, say we 100 revision, and we want to delete the last one:
<source lang=bash>
svnadmin dump <path-to-repository> -r 0:99 > mydump.dump # Replace 99 as necessary
svnadmin create <new-repo-name>
< mydump.dump svnadmin load <new-repo-name>
</source>

== How-To ==
=== re-fetch a range of revisions ===
See [http://stackoverflow.com/questions/3143333/how-can-i-re-fetch-the-revisions-of-a-newly-specified-branch-with-git-svn]:

<source lang=bash>
# Re-fetch from revision 2010:
git svn reset -r 2010
git svn fetch
</source>

== Examples ==

* Checking out a project
<source lang="bash">
<source lang="bash">
svn co svn+ssh://ftp.noekeon.org/opt/www/daemenj/web/private/SVN/Keccak
svn co svn+ssh://ftp.noekeon.org/opt/www/daemenj/web/private/SVN/Keccak

Latest revision as of 09:15, 6 November 2014

References

Configuration

  • Colored diff — Either define colordiff as diff-cmd in ~/.subversion/config:
  • diff-cmd = colordiff
    

    However, to keep the internal svn diff tool, you need to define your own function & alias. This will also highlight diff header in green:

    function svnwrap()
    {
        if [ "$1" = "diff" ] ; then
    		"svn" "$@" | colordiff | less -FRX
    	else
    		"svn" "$@"
    	fi
    }
    alias svn=svnwrap
    

    To page the output, use | less -R

Workflows

Create default folder layout

From [1]:

url=svn://somewhere
svn mkdir $url/$1/trunk $url/$1/branches $url/$1/tags -m "New project $1" --parents

Or on a repository that is already checked out:

svn mkdir trunk branches tags
svn mv src trunk               # Assuming we already have a dir 'src' that needs to be moved to trunk
svn commit -m "create default layout"

Branch integration

From [2]:

  • Create a new branch off the trunk
  • Work on the branch
  • Merge (reintegrate) the branch into trunk
cd trunk
svn merge --reintegrate ^/branches/topic
svn commit
# Committed revision 555. 
# # this revision is ^^^^ important
  • From now on:
    • Either delete the branch
      svn delete ^/branches/topic
      
    • Or merge trunk back to the branch so that subsequent merges do not generate conflicts.
      This steps is necessary to tell svn that it should ignore the merged revision on the trunk at the next branch reintegration):
cd branches/topic
svn merge --record-only -c 555 ^trunk
svn commit

Commands

status (st)

Show modified/new/... files in the working copy.

svn status

propget (pg)

svn propget svn:mergeinfo

info

svn info .
svn info /dir/file

HTTPS Client Certificates

References:

Besides requiring a password, access to a svn repository through HTTPS may also require a client-side certificate. In that case, svn is smart enough to prompt for the location of the file containing the certificate and private key and for the password.

This can also be configured in the file ~/.subversion/servers:

[groups]
myserver = *.myserver.org

# This contains the settings for group "myserver". 
# ! paths must be absolute !
# Client certificates are in format .p12 (same as .pfx), as generated by openssl pkcs12
[myserver]
#The file containing your client certificate
ssl-client-cert-file = /home/user/.subversion/clientcert.p12
#This gives a list of CA to use to authenticate the server certificate
ssl-authority-files = /absolute/path/to/cacert.pem,/absolute/path/to/root.pem

# Add the following to prevent SVN storing your passwords:
[auth]
store-passwords = no
store-auth-creds = no


Changing the client certificate password

See SSL for instructions on how to change the client certificate password.

Server Admin

Delete latest revision from database

The trick is to create a dump of all revisions we want, and import them again with svnadmin.

For instance, say we 100 revision, and we want to delete the last one:

svnadmin dump <path-to-repository> -r 0:99 > mydump.dump                  # Replace 99 as necessary
svnadmin create <new-repo-name>
< mydump.dump svnadmin load <new-repo-name>

How-To

re-fetch a range of revisions

See [3]:

# Re-fetch from revision 2010:
git svn reset -r 2010
git svn fetch

Examples

  • Checking out a project
svn co svn+ssh://ftp.noekeon.org/opt/www/daemenj/web/private/SVN/Keccak