Reference

comandi notevoli

 
# differenze tra due revisioni
svn diff -r BASE:PREV file
svn diff -rPREV
 
# contacts the repository and adds information about things that are out of date
svn status --show-updates -v
 
# aggiungi tutti i files non sotto versione
svn status | grep "^?" | awk -F "      " '{print $2}' | tr "\n" "\0" | xargs -0 svn add
 
# elimina tutti i files non sotto versione
svn status --no-ignore | grep '^\?' | sed 's/^\?      //'
svn status --no-ignore | grep '^\?' | sed 's/^\?      //'  | xargs rm -rf
 
for FILE in $(svn status | grep ?); do svn add $FILE; done
 
find /var/www/projectname/ -type d -name .svn -exec rm -rf {} \;
 
# ultime modifiche committate nel repository
svn log --limit 10
 
# visionare una versione specifica di un file
svn cat -r 2 config.ini > config.r2.ini

analizzare le modifiche di un repo

# modifiche effettuate in un a versione specifica
svn log --verbose -r 502
# modifiche effettuate da una versione all'altra
svn diff --summarize -r502:501

analizzare le modifiche di un file

# tutte i commit che comprendono di un file specifico
svn log application/models/Entity/User.php
# solo i numeri di versione in cui c'è un cambiamento
svn log -q application/models/Entity/User.php | grep '^r' | cut -f1 -d' '
 
# nome utente per ogni riga modificata del file
svn blame application/models/Entity/User.php
 
# estrae una versione specifica di un file
svn cat -r 2 rules.ini
 
# mostra modifiche su un file specifico da una versione specifica
svn diff -r 500 rules.ini
 
# visualizza le modifiche, rispetto una versione precedente specifica, con meld
svn diff --diff-cmd meld -r 500 thefile.php

script analisi storia di un file

svnhistory elements.py | more
#!/bin/bash
# Bendin on Stack Overflow: http://stackoverflow.com/questions/282802
#   Outputs the full history of a given file as a sequence of
#   logentry/diff pairs.
function history_of_file() {
    url=$1 # current url of file
    svn log -q $url | grep -E -e "^r[[:digit:]]+" -o | cut -c2- | sort -nr | {
        while read r
    do
            echo
            svn log -r$r $url@HEAD
            svn diff -c$r $url@HEAD
            echo
    done
    }
}
history_of_file $1

Repository Administration, SCM

Tag crea un tag della situazione iniziale e di ogni altro stato stabile dell'applicazione

Merge di una branch sul trunk

  • Posizionarsi su una folder collegata alla trunk
  • Dare il comando merge impostando FROM trunk con numero di revisione attuale del trunk e selezionare come TO il percorso del branch.
  • Effettuare, per sicurezza, un diff prima e poi un Dry run.
  • Eseguire, infine, il merge

Switch Collega la folder corrente al ramo del repository indicato apportando, alla folder, gli update relativi al ramo collegato

External nella cartella lib,

svn propget svn:externals
CI -r88 svn://myserver/CI/trunk/sf

Ignore svn manual on ignore files

svn propset svn:ignore logs .
svn propedit svn:ignore path/to/dir

which will open your text-editor of choice, then type '*' to ignore everything inside it, and save+quit this will include the directory itself in svn, but ignore all the files inside it, to ignore the directory, use the path of the parent, and then type the name of the directory in the file. After saving, run an update ('svn up'), and then check in the appropriate path.

ignora tutte le sottocartelle o sub folder, utile con dati generati da cache o programma va dato dalla cartella contnitore

svn propset svn:ignore --depth=immediates mytemp .

Variables

when checked in the server replaced $Id:$ with the current revision number. I also found this reference.

<div id="svnrevision">svn revision: $Id:$</div>
 
There is also $Date:$, $Rev:$, $Revision:$

Post Comit Hooks Determine the author of the commit. svnlook author /var/svn/myproject/

Determine what has changed in the last commit. svnlook changed /var/svn/myproject/

Determine the log message of the last commit. svnlook log /var/svn/myproject/

cp /var/svn/myproject/hooks/post-commit.tmpl /var/svn/myproject/hooks/post-commit Make sure the shebang(#!/bin/sh) is there on the first line of the post-commit file.

When a commit is made, this script, post-commit is called and two parameters are passed to it.

The path to this repository The number of the revision just committed

Comment out everything else if the file. After editing, the post-commit file should like like this

#!/bin/sh
REPOS="$1"
REV="$2"
/usr/bin/php /var/svn/myproject/hooks/commit-email.php $REPOS $REV
#!/usr/bin/php
<?php
# place PHP script at /var/svn/myproject/hooks/commit-email.php as specified in the /var/svn/myproject/hooks/post-commit file.
# todo: use some loggig to track errors

// The repository and the revision number are passed as arguments
$repository = isset($argv[1]) ? $argv[1] : '';
$revision = isset($argv[2]) ? $argv[2] : '';

// Lookup author, commit message and what has changed using svnlook
$author exec('svnlook author ' $repository);
$changed exec('svnlook changed ' $repository);
$log exec('svnlook log ' $repository);

// Grab the diff of the commit
$diff '';
$fp popen('svnlook diff ' $repository"r");
while(!
feof($fp)) {
  
$diff .= fread($fp1024);
  
flush();
}
pclose($fp);

$body "Hi,
$author has just committed revision $revision in $repository and said $log.

The following files have changed :

$changed

The changelog is given below:

$diff";

$to 'test@gmail.com';
$subject "$repository subversion commit summary";
$headers 'From: your-admin-test@gmail.com' "\r\n" .
    
'Reply-To: your-admin-test@gmail.com' "\r\n" .
    
'X-Mailer: PHP/' phpversion();
mail($to$subject$body$headers) || die("impossibile inviare email");
?>

pacchetto "subversion-tools"

  • svn-backup-dumps: Incremental dumpfile-based backup script
  • svn-bisect: Bisect revisions to find a regression
  • svn-clean: Remove unversioned files from a working copy
  • svn-fast-backup: rsync-based backup script for FSFS repositories
  • svn-hot-backup: Backup script, primarily for BDB repositories
  • svn_apply_autoprops: Apply property settings from .subversion/config file to an existing repository
  • svn_load_dirs: Sophisticated replacement for 'svn import'
  • svn2cl: Generate GNU-style changelog from repository history
  • svnmerge: Maintain merge history between two related branches
  • several example hook scripts: commit-access-control, commit-email, log-police, mailer, svnperms

resolve conflict

svn resolve --accept theirs-full test.txt

opzioni disponibili:

  • base: the file that you checked out before you made your latest edits
  • working: choose the version of the file as it currently stands in your working copy.
  • mine-full: Resolve all conflicted files with copies of the files as they stood immediately before you ran svn update.
  • theirs-full: Resolve all conflicted files with copies of the files that were fetched from the server when you ran svn update

salvare username password 1) It depends on the protocol you're using: svn+ssh, the svn client can't save your password - the ssh client prompts you for it. If you're using the svnserve protocol or HTTP(S), then the svn client is handling your password and can save it. 2) try clearing your .subversion folder in your home directory and try to commit again. It should prompt you for your password and then ask you if you would like to save the password

la soluzione più banale è usare i flag da linea di comando

svn commit --username <usr> --password <pass>  -m "messag"

impostazioni nel file servers(richieste e settate automaticamente dal client):

nano ~/.subversion/servers
store-passwords = yes

deprecated: the [auth] section in this file has been deprecated

# ensure permissions are no public or group access
chmod 600 ~/.subversion/config
nano ~/.subversion/config
store-passwords = yes