ejemplos de uso

Anuncio
Ejemplo práctico de configuración y uso del CVS
#############################################
# Ejemplo práctico de configuración y
#
# Uso del CVS (Concurrent Version System)
#
#
#
# Integración de Sistemas - Curso 2001-2002 #
# Facultad de Informática
#
# Manuel Álvarez Díaz ([email protected])
#
# 17-10-2001
#
#############################################
# El primer paso es configurar las variables de entorno
# del CVS como repositorio accesible localmente vía NFS
#(CVSROOT); y el editor por defecto (CVSEDITOR).
malvarez$ pwd
/home/i5/malvarez/cvshome
# Para saber localizar el repositorio en la instalación
# realizada, es necesario conocer el grupo secundario
# del usuario.
malvarez$ groups
dtic is0
# El repositorio se montará por NFS sobre /home/i5/CVS/is0,
# siendo is0 el grupo secundario al que pertenece el usuario.
malvarez$ cat .bash_profile
#######
# CVS #
#######
CVSEDITOR=/bin/vi
CVSROOT=/home/i5/CVS/is0
export CVSEDITOR CVSROOT
# Cargar variables de entorno
malvarez$ . .bash_profile
# El acceso al repositorio será restringido a los usuarios
# pertenecientes a un mismo grupo secundario (el primario
# es el mismo para todos). $CVSROOT debe tener permisos 770,
# y grupo is0.
malvarez$ find $CVSROOT –type d –exec chgrp is0 {} \;
malvarez$ find $CVSROOT –type d –exec chmod 770 {} \;
# Para que el usuario cree archivos/directorios con su
# grupo is0 (secundario) es necesario establecer setguid
# en $CVSROOT
malvarez$ find $CVSROOT –type d –exec chmod g+s {} \;
# Si no es posible, con $CVSROOT local es suficiente
# con adquirir la identidad del grupo secundario.
malvarez$ newgrp is0
malvarez$ groups
is0 dtic
#
#
#
#
#
#
NOTA: En nuestro caso no es necesario que los
archivos del repositorio se creen con el grupo is0,
puesto que todos los usuarios tienen el mismo
grupo primario; y usuarios de otros grupos no
pueden atravesar un $CVSROOT que no sea de su grupo
secundario.
Integración de Sistemas – 2001/2002
1
Ejemplo práctico de configuración y uso del CVS
# Inicialización del repositorio en $CVSROOT
malvarez$ cvs init
malvarez$ ls -l /home/i5/CVS/is0
total 4
drwxrwxr-x
3 malvarez is0
4096 Oct 15 21:20 CVSROOT
# Crear un archivo README.txt con contenido:
# ------------------------------------# Archivo para probar CVS
#
# ID = $Id$
# Autor = $Author$
# Versión = $Revision$
#
# Logs ...
# $Log$
malvarez$ vi README.txt
# Crear un directorio "test" y dentro otro archivo README.txt
# ------------------------------------# Otro archivo de prueba
#
# ID = $Id$
# Autor = $Author$
# Versión = $Revision$
#
# Logs ...
# $Log$
malvarez$ mkdir test
malvarez$ cd test
malvarez$ vi README.txt
malvarez$ pwd
/home/i5/malvarez/cvshome
# Crear un nuevo módulo en el repositorio que
# contenga los archivos y directorios creados
# vendor_tag: malvarez (marca del autor/vendedor de
#
la estructura de directorios importar.
# release_tag: v0_1 Marca de la primera versión de
#
todos los archivos, para poder ser
#
recuperada.
malvarez$ cvs import -m "Repositorio Prueba" prueba malvarez v0_1
N prueba/README.txt
cvs import: Importing /home/i5/CVS/is0/prueba/test
N prueba/test/README.txt
No conflicts created by this import
# Borrar los archivos creados y recuperarlos del
# repositorio (crearán los directorios CVS)
malvarez$ rm -rf *
malvarez$ cvs co -d prueba-v0_2 prueba
cvs checkout: Updating prueba-v0_2
U prueba-v0_2/README.txt
cvs checkout: Updating prueba-v0_2/test
U prueba-v0_2/test/README.txt
malvarez$ ls -l
total 4
drwxr-xr-x
4 malvarez is0
Integración de Sistemas – 2001/2002
4096 Oct 15 21:38 prueba-v0_2
2
Ejemplo práctico de configuración y uso del CVS
malvarez$ ls prueba-v0_2/
CVS README.txt test
malvarez$ ls prueba-v0_2/CVS/
Entries Repository Root
malvarez$ cat prueba-v0_2/CVS/Entries
/README.txt/1.1.1.1/Mon Oct 15 19:36:51 2001//
D/test////
malvarez$ cat prueba-v0_2/CVS/Repository
prueba
malvarez$ cat prueba-v0_2/CVS/Root
/home/i5/CVS/is0
# El contenido de los archivos con marcas reconocibles
# por CVS ha cambiado (ha realizado sustituciones)
# Editando el fichero del módulo de administración
# cvswrappers podría haberse evitado (-ko). Con ficheros
# binarios, que no pueden ser mezclados –kb.
malvarez$ cat prueba-v0_2/README.txt
Archivo para probar CVS
ID = $Id: README.txt,v 1.1.1.1 2001/10/15 19:48:13 malvarez Exp $
Autor = $Author: malvarez $
Versión = $Revision: 1.1.1.1 $
Logs ...
$Log: README.txt,v $
Revision 1.1.1.1 2001/10/15 19:48:13
Repositorio Prueba
malvarez
#############################################
# Ahora el usuario jraposo, también del grupo dtic, is0,
# va a proceder a realizar unas modificaciones en la
# información almacenada en el CVS.
#############################################
jraposo$ cd cvshome
jraposo$ cvs co prueba
cvs checkout: Updating prueba
U prueba/README.txt
cvs checkout: Updating prueba/test
U prueba/test/README.txt
jraposo$ cd prueba/
# Modificar la primera línea del fichero README
jraposo$ vi README.txt
# Creación de un fichero LEEME;
jraposo$ vi LEEME.txt
jraposo$ cvs add LEEME.txt
cvs add: scheduling file `LEEME.txt' for addition
cvs add: use 'cvs commit' to add this file permanently
# Borrado del fichero test/README.txt
jraposo$ rm test/README.txt
jraposo$ cvs remove test/README.txt
cvs remove: scheduling `test/README.txt' for removal
cvs remove: use 'cvs commit' to remove this file permanently
# Creación de un directorio test2 y un fichero README.txt
jraposo$ mkdir test2
Integración de Sistemas – 2001/2002
3
Ejemplo práctico de configuración y uso del CVS
jraposo$ vi test2/README.txt
jraposo$ cvs add test2
Directory /home/i5/CVS/is0/prueba/test2 added to the repository
jraposo$ cvs add test2/README.txt
cvs add: scheduling file `test2/README.txt' for addition
cvs add: use 'cvs commit' to add this file permanently
jraposo$ cvs commit .
cvs commit: Examining .
RCS file: /home/i5/CVS/is0/prueba/test2/README.txt,v
done
Checking in README.txt;
/home/i5/CVS/is0/prueba/test2/README.txt,v <-- README.txt
initial revision: 1.1
done
jraposo$ cd ..
jraposo$ cvs commit .
cvs commit: Examining .
cvs commit: Examining test
cvs commit: Examining test2
RCS file: /home/i5/CVS/is0/prueba/LEEME.txt,v
done
Checking in LEEME.txt;
/home/i5/CVS/is0/prueba/LEEME.txt,v <-- LEEME.txt
initial revision: 1.1
done
Checking in README.txt;
/home/i5/CVS/is0/prueba/README.txt,v <-- README.txt
new revision: 1.2; previous revision: 1.1
done
Removing test/README.txt;
/home/i5/CVS/is0/prueba/test/README.txt,v <-- README.txt
new revision: delete; previous revision: 1.1.1.1
done
# CVS abre un archivo con el editor por defecto
# mostrando los cambios a realizar, para pedir
# confirmación. Documenta los cambios realizados.
CVS: ---------------------------------------------------------------------CVS: Enter Log. Lines beginning with `CVS:' are removed automatically
CVS:
CVS: Committing in .
CVS:
CVS: Modified Files:
CVS:
README.txt
CVS: Added Files:
CVS:
LEEME.txt
CVS: ---------------------------------------------------------------------Cambios realizados ...
# El usuario malvarez realiza también cambios
# Modifica también la primera línea del fichero
# README.txt y crea un fichero LEE.ME.
malvarez$ vi README.txt
malvarez$ vi LEE.ME
malvarez$ cvs add LEE.ME
cvs add: scheduling file `LEE.ME' for addition
cvs add: use 'cvs commit' to add this file permanently
Integración de Sistemas – 2001/2002
4
Ejemplo práctico de configuración y uso del CVS
# Ahora comprueba si su copia local está actualizada.
malvarez$ cvs -n update -d -P
cvs update: Updating .
A LEE.ME
U LEEME.txt
RCS file: /home/i5/CVS/is0/prueba/README.txt,v
retrieving revision 1.1.1.1
retrieving revision 1.2
Merging differences between 1.1.1.1 and 1.2 into README.txt
rcsmerge: warning: conflicts during merge
cvs update: conflicts found in README.txt
C README.txt
cvs update: Updating test
cvs update: warning: test/README.txt is not (any longer) pertinent
cvs update: Updating test2
U test2/README.txt
# Y la actualiza (es necesario resolver un conflicto
# generado por la modificación de la misma línea del
# mismo archivo por dos usuarios).
cvs update: Updating .
A LEE.ME
U LEEME.txt
RCS file: /home/i5/CVS/is0/prueba/README.txt,v
retrieving revision 1.1.1.1
retrieving revision 1.2
Merging differences between 1.1.1.1 and 1.2 into README.txt
rcsmerge: warning: conflicts during merge
cvs update: conflicts found in README.txt
C README.txt
cvs update: Updating test
cvs update: warning: test/README.txt is not (any longer) pertinent
cvs update: Updating test2
U test2/README.txt
# A continuación se muestra el archivo objeto del
# conflicto. CVS marca el conflicto entre los
# símbolos <<<<< >>>>>. Primero muestra la versión
# del usuario local y después la que está en el
# repositorio. Es necesaria una mezcla manual.
malvarez$ vi README.txt
<<<<<<<
Archivo
=======
Archivo
>>>>>>>
README.txt
para probar CVS. cambios malvarez
Modificado para probar CVS
1.2
ID = $Id: README.txt,v 1.2 2001/10/15 20:02:10 jraposo Exp $
Autor = $Author: jraposo $
Versión = $Revision: 1.2 $
Logs ...
$Log: README.txt,v $
Revision 1.2 2001/10/15 20:02:10
jraposo
Cambios realizados ...
Revision 1.1.1.1 2001/10/15 19:48:13
Repositorio Prueba
Integración de Sistemas – 2001/2002
malvarez
5
Ejemplo práctico de configuración y uso del CVS
# Una vez se ha solucionado el conflicto, se actualiza
# el repositorio
malvarez$ cvs ci
CVS: ---------------------------------------------------------------------CVS: Enter Log. Lines beginning with `CVS:' are removed automatically
CVS:
CVS: Committing in .
CVS:
CVS: Modified Files:
CVS:
README.txt
CVS: Added Files:
CVS:
LEE.ME
CVS: ---------------------------------------------------------------------cvs commit: Examining .
cvs commit: Examining test2
RCS file: /home/i5/CVS/is0/prueba/LEE.ME,v
done
Checking in LEE.ME;
/home/i5/CVS/is0/prueba/LEE.ME,v <-- LEE.ME
initial revision: 1.1
done
Checking in README.txt;
/home/i5/CVS/is0/prueba/README.txt,v <-- README.txt
new revision: 1.3; previous revision: 1.2
done
# El usuario malvarez, después de los cambios realizados
# decide asignar a las últimas versiones de sus archivos
# locales una marca que los identifique y permita recuperarlos
# (v0_2).
malvarez$ cvs tag v0_2
cvs tag: Tagging .
T LEE.ME
T LEEME.txt
T README.txt
cvs tag: Tagging test2
T test2/README.txt
# Historial de módulos que han sido recuperados localmente.
malvarez$ cvs history -a -o
O 2001-10-15 19:49 +0000 jraposo prueba =prueba=
~/cvshome/*
O 2001-10-15 19:59 +0000 malvarez prueba =prueba-v0_2= ~/cvshome/*
# Estado de uno de los archivos modificados. Su
# revisión ha avanzado desde 1.1 hasta 1.3 (el
# usuario jraposo ha realizado un cambio y malvarez otro).
malvarez$ cvs status README.txt
===================================================================
File: README.txt
Status: Up-to-date
Working revision:
Repository revision:
Sticky Tag:
Sticky Date:
Sticky Options:
1.3
Mon Oct 15 20:12:23 2001
1.3
/home/i5/CVS/is0/prueba/README.txt,v
(none)
(none)
(none)
Integración de Sistemas – 2001/2002
6
Ejemplo práctico de configuración y uso del CVS
# Un nuevo caso práctico
#############################################
# La versión v0_2 es la actualmente en desarrollo
# Se encuentra un error en la versión v0_1
# Es necesario crear un branch para solucionar
# el error sobre la versión v0_1.
# Posteriormente se aplicará el parche a la
# versión v0_2.
#############################################
# Creación de un branch sobre el tag de la v0_1,
# para poder modificarla
malvarez$ cvs rtag -r v0_1 -b v0_1b1 prueba
cvs rtag: Tagging prueba
cvs rtag: Tagging prueba/test
cvs rtag: Tagging prueba/test2
# Se recupera el branch v0_1b1
malvarez$ cvs co -r v0_1b1 -d prueba-v0_1b1 prueba
cvs checkout: Updating pruebav-0_1b1
U prueba-v0_1b1/README.txt
cvs checkout: Updating prueba-v0_1b1/test
U prueba-v0_1b1/test/README.txt
cvs checkout: Updating prueba-v0_1b1/test2
malvarez$ cd prueba-v0_1b1/
# Se soluciona el error
malvarez$ vi README.txt
# Se pasa al repositorio
malvarez$ cvs ci
cvs commit: Examining .
cvs commit: Examining test
Checking in README.txt;
/home/i5/CVS/is0/prueba/README.txt,v <-- README.txt
new revision: 1.1.1.1.2.1; previous revision: 1.1.1.1
done
# Se parchea la versión v0_2 local
malvarez$ cd $HOME/cvshome/prueba-v0_2
malvarez$ cvs update -j v0_1b1
cvs update: Updating .
RCS file: /home/i5/CVS/is0/prueba/README.txt,v
retrieving revision 1.1
retrieving revision 1.1.1.1.2.1
Merging differences between 1.1 and 1.1.1.1.2.1 into README.txt
rcsmerge: warning: conflicts during merge
cvs update: Updating test2
# Solucionar conflictos
malvarez$ vi README.txt
# Actualizar el repositorio
malvarez$ cvs ci
cvs commit: Examining .
cvs commit: Examining test2
Checking in README.txt;
/home/i5/CVS/is0/prueba/README.txt,v <-new revision: 1.4; previous revision: 1.3
done
README.txt
# Se consolida de nuevo la versión v0_2
malvarez$ cvs tag -F v0_2
cvs tag: Tagging .
Integración de Sistemas – 2001/2002
7
Ejemplo práctico de configuración y uso del CVS
T README.txt
cvs tag: Tagging test2
# El usuario malvarez, una vez ha finalizado
su
# trabajo sobre el módulo prueba, elimina su copia
# local.
malvarez$ cvs release -d prueba-v0_2/
You have [0] altered files in this repository.
Are you sure you want to release (and delete) directory `prueba-v0_2/': yes
# Historial de módulos recuperados ...
malvarez$ cvs history -a -o
O 2001-10-15 20:20 +0000 jraposo [v0_2] prueba =prueba=
~/cvshome/*
O 2001-10-15 19:59 +0000 malvarez prueba =prueba-v0_2= ~/cvshome/*
O 2001-10-15 20:16 +0000 malvarez [v0_1b1] prueba =prueba-v0_1b1= ~/cvshome/*
#############################################
# NOTA:
#
#############################################
# Es recomendable utilizar el fichero de
#
# configuración de cvs (.cvsrc) con las
#
# opciones por defecto:
#
#
checkout -P
#
#
update -d -P
#
# Para que
#
#
-d update actualice directorios nuevos#
#
-P no bajen directorios vacíos
#
#############################################
Para más información: http://www.cvshome.org
Desde linux: info cvs
Integración de Sistemas – 2001/2002
8
Descargar