Subversion(SVN): diferenças entre revisões

Fonte: Wikiversidade
Conteúdo apagado Conteúdo adicionado
Sem resumo de edição
Linha 70: Linha 70:
Aliases for svn remove are "svn delete" and "svn rm".
Aliases for svn remove are "svn delete" and "svn rm".
If more than one file needs to be removed, you need to perfom the svn remove operation for each file one after another. (You can't remove several files from the repository at the same time in one line.)
If more than one file needs to be removed, you need to perfom the svn remove operation for each file one after another. (You can't remove several files from the repository at the same time in one line.)

===criando um Novo Projeto===
You'd do this if you want to put your program, stored only on your machine at the moment, onto the svn repository.

The program folder on your harddrive, called "my_program" for instance, may contain:
* all the directories (e.g. src, lib, bin) and
* loose files (e.g. build.xml and *.bat, *.sh scripts).

If you want to put this project folder into the repository, inside http://svn.greenstone.org/other-projects/trunk/
then you would type the following in your x-term:
<pre>cd my_program
svn import -m "my message" . http://svn.greenstone.org/other-projects/trunk/my_program
</pre>
That will put your folder and its contents into the svn repository inside a similarly named folder.
Now, we need to check out our own svn-managed copy:
Move up out of the local my_program directory and make a back-up copy of original program folder, just in case:
<pre>3. cd ..
4. mv my_program my_program.bak
</pre>
Finally, checkout the a copy of the program from the svn repository, that will be stored on your machine in my_program:
<pre>5. svn co http://svn.greenstone.org/other-projects/trunk/my_program</pre>
Your program folder is just as before, except that it's now managed with svn.



===Comandos Utéis===
===Comandos Utéis===

Revisão das 06h06min de 6 de abril de 2015

Introdução

Esta sessão dedica-se a uma introdução do SVN, incluindo sua instalação e comandos básicos. O Apache subversion que é a abreviação para svn , é um software de versionamento revisão de controle de sistema disponibilizado como uma licença open source . Subervision foi criado pela colaabNet em 2000 , mas agora está sendo desenvolvido pela Apache software Foundation

Comandos Básicos

Checkout de Projetos

# Ambos comandos podem ser utilizados para realizar o checkout. Troque o "url" pela url desejada
svn checkout url
svn co url
# Realiza o checkout para a pasta "svntutorial" no atual diretório
 svn checkout url/main/trunk/svntutorial

Atualizar/Reverter SVN

  • To update the local file(s) with just the changes made in the repository, do an "svn update":
> svn update <filename1> <filename2> ... <filenameN>
  • To overwrite local file(s) with the one in the repository, do an "svn revert"--you would do this if you want to go back to the version of the file in the repository (you will lose all changes you had made since the last commit):
> svn revert <filename1> ... <filenameN>

You can update an entire directory (and subdirectories) by moving into that directory and typing:

> svn update

svn diff

Note that svn diff does not connect to the repository! It compares your file against the file you had downloaded, not the file as it exists at the moment in the svn repository.

To find out what changes you've made to a greenstone source file:

> cd <folder containing source file>
	> svn diff <filename>
e.g.
	> svn diff util.pm

Realizando Commits

Perform an svn diff it to look over the changes made since you last updated the file. Then svn update the file, perform the svn diff on the updated file, then svn commit it with a message:

> svn diff <filename>

Will show you the changes you've made since you last did an svn update on the file.

> svn update <filename>

It will merge changes made to the file in the repository with the changes you have on your machine. Your own changes take precedence and these are preserved. However, conflicts may arise if any of the lines that have been modified on your machine have been changed in the repository since you last checked it out/svn-updated it.

> svn diff <filename>

This diff now shows up the differences between your current file and what's there now in the repository. Check that only the new code you have added is the sum total of the differences.

> svn commit - m "message" <filename>

Where the message string is one that explains what changes have been made, why you are committing the file or what purpose a new file serves.

To perform these svn operations on more more than 1 file in one go, separate them by spaces:

> svn diff <filename> <filename2> <filenameN>
> svn update <filename> <filename2> <filenameN>
> svn diff <filename> <filename2> <filenameN>
> svn commit - m "message" <filename> <filename2> <filenameN>

Adicionando novo arquivo ao repositório

How to add a file (not for creating new folders in the svn repository):

svn add <filename>
svn commit -m "This new file will do something useful" <filename>

You can add more than one file at a time:

svn add <filename1> <filename2> <filenameN>
svn commit -m "These new files work together to add some extra functionality" <filename1> <filename2> <filenameN>

Deletando Arquivo do Repositório

To remove a file from the repository, you need to give it the url of the file in the repository:

svn remove -m "I deleted this file for a reason" http://svn.greenstone.org/....../thefile.ext

Aliases for svn remove are "svn delete" and "svn rm". If more than one file needs to be removed, you need to perfom the svn remove operation for each file one after another. (You can't remove several files from the repository at the same time in one line.)

criando um Novo Projeto

You'd do this if you want to put your program, stored only on your machine at the moment, onto the svn repository.

The program folder on your harddrive, called "my_program" for instance, may contain:

  • all the directories (e.g. src, lib, bin) and
  • loose files (e.g. build.xml and *.bat, *.sh scripts).

If you want to put this project folder into the repository, inside http://svn.greenstone.org/other-projects/trunk/ then you would type the following in your x-term:

cd my_program
svn import -m "my message" . http://svn.greenstone.org/other-projects/trunk/my_program

That will put your folder and its contents into the svn repository inside a similarly named folder. Now, we need to check out our own svn-managed copy: Move up out of the local my_program directory and make a back-up copy of original program folder, just in case:

3. cd .. 
4. mv my_program my_program.bak

Finally, checkout the a copy of the program from the svn repository, that will be stored on your machine in my_program:

5. svn co http://svn.greenstone.org/other-projects/trunk/my_program

Your program folder is just as before, except that it's now managed with svn.


Comandos Utéis

> svn info
> svn switch
> svn status

If you do an "svn status" in a folder, it recursively lists all the Modified (M), Deleted (D) and Added (A) files. It will also show up files that are in conflict (C) and those about which svn does not know (?). To see what modifications were made to individual files marked with an M, you'd do an "svn diff":

> svn diff <filename>
> svn help
> svn help [item]
	eg. svn help status

The last gives instructions on how to use an svn command. For example:

> svn help commit

Will tell you that to commit changes, you do "svn commit [path] --message "<reasoning>"

Guia de Instalação do SVN(WebSVN)

Passo 1 - Abra terminal

Passo 2 - Digite:

apt-get update
sudo apt-get install websvn subversion libapache2-svn

Passo 3 - Websvn perguntará se deseja configura-lo agora. Escolha a oção “No” , ele será configurado depois.

Passo 4 - Normalmente o apache mod é habilitado por default, mas assegure-se executando os seguintes comandos:

a2enmod dav
a2enmod dav_svn

Passo 4 - abra o arquivo com editor de sua preferência: /etc/apache2/mods-enable/dav_svn.conf

Passo 5 - Descomente as seguinte linhas :

<Location /svn> #linha 13
Dav svn >>  #linha 16
SVNParentPath /var/lib/svn
<Limit except GET PROFIND OPTIONS REPORT> #linha 52
      Require valid-user   #linha 53
</LimitExcept> #linha 54
</Location> #linha 56
AuthType Basic
AuthName “Subervsion Repository”
AuthUserFile /etc/apache2/dav_svn.password

Passo 6 - Crie um diretório para os repositórios svn : sudo mkdir /var/lib/svn

Passo 7 - Crie um repositório svn para testar: sudo svnadmin create /var/lib/svn/mysvnrepo sudo svnadmin create /var/lib/svn/mysvnrepo2

Passo 8 - execute esse comando para dar permissão de leitura e escrita para um usuário web no seguinte: chown -R www-data:www-data /var/lib/svn/mysvnrepo

Passo 9 - Reinicie o apache : sudo service apache2 restart

Passo 10 - add svn users sudo htpasswd -cm /etc/apache2/dav_svn.passwd ( para o primeiro usuário )

sudo htpasswd -m /etc/apache2/dav_svn.passwd username

Passo 11- configure websvn: sudo dpkg-reconfigure websvn

FAQ

Mensagem "htpasswd comand not found" ?

Caso apareça a mensagem htpasswd comand not found , possivelmente é porque alguns módulos do apache não foram instalados. Para solucionar execute o seguinte comando:

apt-get install apache2-utils