Version control is the art of managing changes to information. It has long been a critical tool for programmers, who typically spend their time making small changes to software and then undoing those changes the next day. But the usefulness of version control software extends far beyond the bounds of the software development world. Anywhere you can find people using computers to manage information that changes often, there is room for version control.
Subversion is an open source version control system. Using Subversion, you can record the history of source files and documents. It manages files and directories over time. A tree of files is placed into a central repository. The repository is much like an ordinary file server, except that it remembers every change ever made to files and directories.
Para acceder a un repositorio de Subversion mediante el protocolo HTTP, debe instalar y configurar un servidor web. Apache2 ha demostrado funcionar bien con Subversion (para instalar y configurar Apache2, consulte la sub-sección HTTP de la sección de Apache2). Para acceder al repositorio de Subversion repository mediante el protocolo HTTPS, debe instalar y configurar un certificado digital en su servidor web Apache 2 (para ello, consulte la sub-sección HTTPS de la sección de Apache2).
Para instalar Subversion, ejecute la siguiente orden en la línea de órdenes de una terminal:
sudo apt-get install subversion libapache2-svn
Este paso asume que ya tiene instalados los paquetes mencionados en su sistema. Esta sección le explica cómo crear un repositorio de Subversion y acceder al proyecto.
Subversion repositories can be accessed (checked out) through many different methods --on local disk, or through various network protocols. A repository location, however, is always a URL. The table describes how different URL schemas map to the available access methods.
Tabla 4.1. Métodos de Acceso
Proyecto |
Método de Acceso |
---|---|
file:// |
acceso directo al repositorio (en disco local) |
http:// |
Access via WebDAV protocol to Subversion-aware Apache2 web server |
https:// |
Igual que http://, pero con cifrado SSL |
svn:// |
Acceso al servidor svnserve via el protocolo por defecto |
svn+ssh:// |
Lo mismo que svn://, pero a través de un tunel SSH |
In this section, we will see how to configure Subversion for all these access methods. Here, we cover the basics. For more advanced usage details, refer to the svn book.
This is the simplest of all access methods. It does not require any Subversion server process to be running. This access method is used to access Subversion from the same machine. The syntax of the command, entered at a terminal prompt, is as follows:
svn co file:///path/to/repos/project
o
svn co file://localhost/path/to/repos/project
Si no especifica el nombre del host, ha de usar tres barras (///) -- dos para el protocolo (file, en este caso) más la barra que indica la raíz de la ruta. Si especifica el nombre del host, debe usar dos barras (//).
Los permisos del repositorio dependen de los permisos del sistema de archivos. Si el usuario tiene permisos de lectura/escritura, puede hacer «checkout» y «commit» sobre el repositorio.
To access the Subversion repository via WebDAV protocol, you must configure your Apache 2 web server. You must add the following snippet in your /etc/apache2/apache2.conf
file:
<Location /svn> DAV svn SVNPath /path/to/repos AuthType Basic AuthName "El nombre de su repositorio" AuthUserFile /etc/subversion/passwd <LimitExcept GET PROPFIND OPTIONS REPORT> Require valid-user </LimitExcept> </Location>
Ahora, debe crear el fichero /etc/subversion/passwd
, el cual contiene los detalles de autenticación del usuario. Para añadir una entrada, p.e. para añadir un usuario, puede ejecutar esta orden en una terminal:
htpasswd2·/etc/subversion/passwd·user_name
Ésta orden le pedirá que introduzca su contraseña. Cuando lo haga, se añadirá el usuario. Entonces, para acceder al repositorio puede ejecutar esto:
svn co http://servername/svn
La contraseña se transmite como texto plano. Si le preocupa que puedan interceptar su contraseña, se le recomienda que use cifrado SSL. Para más detalles, consulte la siguiente sección.
Accessing Subversion repository via WebDAV protocol with SSL encryption (https://) is similar to http:// except that you must install and configure the digital certificate in your Apache2 web server.
Puede instalar un certificado digital emitido por una autoridad de certificación como Verisign. También puede instalar su propio certificado auto-firmado.
This step assumes you have installed and configured a digital certificate in your Apache 2 web server. Now, to access the Subversion repository, please refer to the above section! The access methods are exactly the same, except the protocol. You must use https:// to access the Subversion repository.
Once the Subversion repository is created, you can configure the
access control. You can edit the
/path/to/repos/project/conf/svnserve.conf
file to
configure the access control. For example, to set up
authentication, you can uncomment the following lines in the
configuration file:
# [general]↵ # password-db = passwd
After uncommenting the above lines, you can maintain the user
list in the passwd file. So, edit the file passwd
in the same directory and add the new user. The
syntax is as follows:
username·=·password
Para más detalles, por favor consulte el archivo.
Now, to access Subversion via the svn:// custom protocol, either from the same machine or a different machine, you can run svnserver using svnserve command. The syntax is as follows:
$ svnserve -d --foreground -r /path/to/repos # -d -- daemon mode # --foreground -- run in foreground (useful for debugging) # -r -- root of directory to serve For more usage details, please refer to: $ svnserve --help
Once you run this command, Subversion starts listening on default port (3690). To access the project repository, you must run the following command from a terminal prompt:
svn co svn://hostname/project project --username user_name
Based on server configuration, it prompts for password. Once you are authenticated, it checks out the code from Subversion repository. To synchronize the project repository with the local copy, you can run the update sub-command. The syntax of the command, entered at a terminal prompt, is as follows:
cd project_dir ; svn update
For more details about using each Subversion sub-command, you can refer to the manual. For example, to learn more about the co (checkout) command, please run the following command from a terminal prompt:
svn co help
The configuration and server process is same as in the svn:// method. For details, please refer to the above section. This step assumes you have followed the above step and started the Subversion server using svnserve command.
It is also assumed that the ssh server is running on that machine and that it is allowing incoming connections. To confirm, please try to login to that machine using ssh. If you can login, everything is perfect. If you cannot login, please address it before continuing further.
The svn+ssh:// protocol is used to access the Subversion repository using SSL encryption. The data transfer is encrypted using this method. To access the project repository (for example with a checkout), you must use the following command syntax:
svn·co·svn+ssh://hostname/var/svn/repos/project
You must use the full path (/path/to/repos/project) to access the Subversion repository using this access method.
Based on server configuration, it prompts for password. You must enter the password you use to login via ssh. Once you are authenticated, it checks out the code from the Subversion repository.
CVS es un sistema de control de versiones. Puede usarlo para grabar el historial de un fichero fuente.
At a terminal prompt, enter the following command to install cvs:
sudo apt-get install cvs
After you install cvs, you should install xinetd to start/stop the cvs server. At the prompt, enter the following command to install xinetd:
sudo apt-get install xinetd
Once you install cvs, the repository will be automatically initialized. By default, the repository resides under the /var/lib/cvs directory. You can change this path by running following command:
cvs -d /your/new/cvs/repo init
Once the initial repository is set up, you can configure
xinetd to start the CVS server.
You can copy the following lines to the
/etc/xinetd/cvspserver
file.
↵ service cvspserver↵ {↵ port = 2401↵ socket_type = stream↵ protocol = tcp↵ user = root↵ wait = no↵ type = UNLISTED↵ server = /usr/bin/cvs↵ server_args = -f --allow-root /var/lib/cvs pserver↵ disable = no↵ }↵
Be sure to edit the repository if you have changed the default repository (/var/lib/cvs) directory.
Once you have configured xinetd you can start the cvs server by running following command:
sudo /etc/init.d/xinetd start
Puede confirmar que el servidor CVS se está ejecutando introduciendo la siguiente orden:
sudo netstat -tap | grep cvs
Cuando ejecute este comando, deberá ver la siguiente línea o algo similar:
↵ tcp 0 0 *:cvspserver *:* LISTEN ↵
Desde aquí puede continuar añadiendo usuarios, nuevos proyectos, y manejando el servidor CVS.
CVS allows the user to add users independently of the underlying OS installation. Probably the easiest way is to use the Linux Users for CVS, although it has potential security issues. Please refer to the CVS manual for details.
Esta sección explica cómo añadir un nuevo proyecto al repositorio CVS. Cree el directorio y meta en él los documentos y códigos fuente necesarios. Después, ejecute la siguiente orden para añadir el proyecto al repositorio CVS:
cd su/proyecto cvs import -d :pserver:nombreusuario@nombrehost.com:/var/lib/cvs -m "Importando mi proyecto al repositorio CVS" . nuevo_proyecto start
Puede usar la variable de entorno CVSROOT para guardar el directorio raíz CVS. Una vez haya exportado la variable de entorno CVSROOT, podrá evitar usar la opción -d en las órdenes cvs de arriba.
La cadena nuevo_proyecto es una etiqueta de vendedor, y start es una etiqueta de publicación. No tienen importancia en este contexto, pero como CVS los requiere, deben estar presentes.
Cuando añada un nuevo proyecto, el usuario CVS que utilice deberá tener acceso de escritura al repositorio CVS (/var/lib/cvs). De forma predeterminada, el grupo src tiene acceso de escritura al repositorio CVS. Por tanto, puede añadir el usuario a este grupo, y así él podrá añadir y gestionar proyectos en el repositorio CVS.