Mercurial > hgbook
annotate es/hgext.tex @ 550:f4904a9b4fdb
Started translating hgext
author | Igor TAmara <igor@tamarapatino.org> |
---|---|
date | Sat, 13 Dec 2008 23:55:07 -0500 |
parents | aeda195f54a6 |
children | 3cb3f9b418ea |
rev | line source |
---|---|
539
aeda195f54a6
Finally finished translating collab and taking mq and hgext
Igor TAmara <igor@tamarapatino.org>
parents:
435
diff
changeset
|
1 \chapter{Añadir funcionalidad con extensiones} |
435 | 2 \label{chap:hgext} |
3 | |
550
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
4 A pesar de que el corazón de Mercurial es muy completo desde el punto |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
5 de vista de funcionalidad, carece de características rimbombantes |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
6 deliberadamente. Esta aproximación de preservar la simplicidad |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
7 mantiene el programa sencillo tanto para mantenedores como para |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
8 usuarios. |
435 | 9 |
550
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
10 Si embargo Mercurial no le cierra las posibilidades a un conjunto |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
11 inflexible de órdenes: usted puede añadir características como |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
12 \emph{extensiones} (aveces llamadas \emph{añadidos}\ndt{plugins}). Ya |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
13 hemos discutido algunas de estas extensiones en capítulos anteriores: |
435 | 14 \begin{itemize} |
550
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
15 \item La sección~\ref{sec:tour-merge:fetch} cubre la extensión |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
16 \hgext{fetch}; que combina jalar cambios y fusionarlos con los |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
17 cambios locales en una sola orden: \hgxcmd{fetch}{fetch}. |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
18 \item En el capítulo~\ref{chap:hook}, cubrimos muchas extensiones que |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
19 son útiles en funcionalidades relacionadas con ganchos: Los |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
20 \hgext{acl} añaden listas de control de acceso; \hgext{bugzilla} |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
21 añade integración con el sistema de seguimiento de fallos Bugzilla; y |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
22 \hgext{notify} envía notificaciones por correo de nuevos cambios. |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
23 \item La extensión de administración de parches MQ es tan invaluable |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
24 que amerita dos capítulos y un apéndice por sí misma. |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
25 El capítulo~\ref{chap:mq} cubre lo básico; el |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
26 capítulo~\ref{chap:mq-collab} discute temas avanzados; y el |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
27 apéndice~\ref{chap:mqref} muestra en detalle cada orden. |
435 | 28 \end{itemize} |
29 | |
550
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
30 En este capítulo cubriremos algunas extensiones adicionales |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
31 disponibles para Mercurial, y daremos un vistazo a la maquinaria que |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
32 necesita conocer en caso de que desee escribir una extensión. |
435 | 33 \begin{itemize} |
550
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
34 \item En la sección~\ref{sec:hgext:inotify}, discutiremos la |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
35 posibilidad de mejorar el desempeño \emph{en gran medida} con la extensión |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
36 \hgext{inotify}. |
435 | 37 \end{itemize} |
38 | |
550
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
39 \section{Mejorar el desempeño con la extensión \hgext{inotify}} |
435 | 40 \label{sec:hgext:inotify} |
41 | |
550
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
42 ¿Desea lograr que las operaciones más comunmente usadas de Mercurial se |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
43 ejecuten centenas de veces más rápido? ¡A leer! |
435 | 44 |
550
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
45 Mercurial tiene gran desempeño bajo circunstancias normales. Por |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
46 ejemplo, cuando ejecuta la orden \hgcmd{status}, Mercurial tiene que |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
47 revisar casi todos los ficheros y directorios en su repositorio de |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
48 forma que pueda desplegar el estado de los ficheros. Muchas otras |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
49 órdenes tienen que hacer tal trabajo tras bambalinas; por ejemplo la |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
50 orden \hgcmd{diff} usa la maquinaria de estado para evitar hacer |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
51 operaciones de comparación costosas en ficheros que obviamente no han |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
52 cambiado. |
435 | 53 |
550
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
54 Dado que obtener el estado de los ficheros es crucial para obtener |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
55 buen desempeño, los autores de Mercurial han optimizado este código en |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
56 la medida de lo posible. Sin embargo, no puede obviarse el hecho de |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
57 que cuando ejecuta \hgcmd{status}, Mercurial tendrá que hacer por lo |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
58 menos una costosa llamada al sistema por cada archivo administrado |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
59 para determinar si ha cambiado desde la última vez que se consignó. |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
60 Para un repositorio suficientemente grande, puede tardar bastante |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
61 tiempo. |
435 | 62 |
550
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
63 Para mostrar en números la magnitud de este efect, creé un repositorio |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
64 que contenía 150.000 archivos administrador. Tardó diez segundos para |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
65 ejecutar \hgcmd{status}, a pesar de que \emph{ninguno} de los ficheros |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
66 había sido modificado. |
435 | 67 |
550
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
68 Muchos sistemas operativos modernos contienen una facilidad de |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
69 notificación de archivos. Si un programa se registra con un servicio |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
70 apropiado, el sistema operativo le notificará siempre que un fichero |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
71 de interés haya sido creado, modificado o borrado. En sistemas Linux, |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
72 el componente del núcleo que lo hace se llama \texttt{inotify}. |
435 | 73 |
550
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
74 La extensión \hgext{inotify} habla con el componente \texttt{inotify} |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
75 del núcleo para optimizar las órdenes de \hgcmd{status}. La extensión |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
76 tiene dos componentes. Un daemonio está en el fondo recibiendo |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
77 notificaciones del subsistema \texttt{inotify}. También escucha |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
78 conexiones de una orden regular de Mercurial. La extensión modifica |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
79 el comportamiento de Mercurial de tal forma que, en lugar de revisar |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
80 el sistema de ficheros, le pregunta al daemonio. Dado que el daemonio |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
81 tiene información perfecta acerca del estado del repositorio, puede |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
82 responder instantáneamente con el resultado, evitando la necesidad de |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
83 revisar cada directorio y fichero del repositorio. |
435 | 84 |
550
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
85 Retomando los diez segundos que medí al ejecutar la orden |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
86 \hgcmd{status} de Mercurial sobre un repositorio de 150.000 |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
87 ficheros. Con la extensión \hgext{inotify} habilitada, el tiempo se |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
88 disipó a 0.1~seconds, un factor \emph{cien veces} más rápido. |
435 | 89 |
550
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
90 Antes de continuar, tenga en cuenta algunos detalles: |
435 | 91 \begin{itemize} |
550
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
92 \item La extensión \hgext{inotify} es específica de Linux. Porque se |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
93 enlaza directamente con el subsistema \texttt{inotify} del núcleo |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
94 Linux, no funciona en otros sistemas operativos. |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
95 \item Debería funcionar en cualquier distribución Linux a partir de |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
96 comienzos del 2005. Las distribuciones más antiguas deben tener un |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
97 kernel sin \texttt{inotify}, o una versión de \texttt{glibc} que no |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
98 tiene necesariamente el soporte para la interfaz. |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
99 \item No todos los sistemas de ficheros pueden usarse con la extensión |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
100 \hgext{inotify}. Los sistemas de ficheros tales como NFS no lo |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
101 soportan, por ejemplo, si está corriendo Mercurial en vaios |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
102 sistemas, montados todos sobre el mismo sistema de ficheros en red. |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
103 El sistema \texttt{inotify} del kernel no tiene forma de saber |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
104 acerca de los cambios hechos en otro sistema. La mayoría de |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
105 sistemas de ficheros locales (p.e.~ext3, XFS, ReiserFS) deberían |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
106 funcionar bien. |
435 | 107 \end{itemize} |
108 | |
550
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
109 Hacia mayo de 2007 la extensión \hgext{inotify} no venía de forma |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
110 predeterminada en Mercurial\ndt{Desde el 2008 para kernels 2.6 viene |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
111 en Mercurial, pero no está activada de forma predeterminada}, y es |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
112 un poco más compleja de activar que otras extensiones. Pero la mejora |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
113 en el desempeño bien vale la pena! |
435 | 114 |
550
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
115 La extensión venía en dos partes: un conjunto de parches al código |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
116 fuente de Mercurial, y una librería de interfaces de Python hacia el |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
117 subsistema \texttt{inotify}. |
435 | 118 \begin{note} |
550
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
119 Hay \emph{dos} librerías de enlace de Python hacia \texttt{inotify}. |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
120 Una de ellas se llama \texttt{pyinotify}, y en algunas |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
121 distribuciones de Linux se encuentra como \texttt{python-inotify}. |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
122 Esta es la que \emph{no} necesita, puesto que tiene muchos fallos, |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
123 y es ineficiente para ser práctica. |
435 | 124 \end{note} |
550
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
125 Para comenzar, es mejor tener una copia de Mercurial funcional |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
126 instalada: |
435 | 127 \begin{note} |
550
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
128 Si sigue las instrucciones a continuación, estará |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
129 \emph{reemplazando} y sobreescribiendo cualquier instalación previa |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
130 de Mercurial que pudiera tener, con el código de Mercurial ``más |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
131 reciente y peligrosa''. No diga que no se le advirtio! |
435 | 132 \end{note} |
133 \begin{enumerate} | |
550
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
134 \item Clone el repositorio de interfaz entre Python e |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
135 \texttt{inotify}. Ármelo e instálelo: |
435 | 136 \begin{codesample4} |
137 hg clone http://hg.kublai.com/python/inotify | |
138 cd inotify | |
139 python setup.py build --force | |
140 sudo python setup.py install --skip-build | |
141 \end{codesample4} | |
550
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
142 \item Clone el repositorio \dirname{crew} de Mercurial. Clone el |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
143 repositorio de parches de \hgext{inotify} de forma tal que las colas |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
144 de Mercurial puedan aplicar los parches sobre el repositorio \dirname{crew}. |
435 | 145 \begin{codesample4} |
146 hg clone http://hg.intevation.org/mercurial/crew | |
147 hg clone crew inotify | |
148 hg clone http://hg.kublai.com/mercurial/patches/inotify inotify/.hg/patches | |
149 \end{codesample4} | |
550
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
150 \item Asegúrese de instalar la extensión Colas de Mercurial |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
151 \hgext{mq} y que estén habilitadas. Si nunca ha usado MQ, lea la |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
152 sección~\ref{sec:mq:start} para poder comenzar rápidamente. |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
153 \item Vaya al repositorio de \dirname{inotify} y aplique todos los |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
154 parches de \hgext{inotify} con la opción \hgxopt{mq}{qpush}{-a} de |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
155 la orden \hgxcmd{mq}{qpush}. |
435 | 156 \begin{codesample4} |
157 cd inotify | |
158 hg qpush -a | |
159 \end{codesample4} | |
550
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
160 Si obtiene un mensaje de error de \hgxcmd{mq}{qpush}, no debería |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
161 continuar. Mejor pida ayuda. |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
162 \item Arme e instale la versión parchada de Mercurial. |
435 | 163 \begin{codesample4} |
164 python setup.py build --force | |
165 sudo python setup.py install --skip-build | |
166 \end{codesample4} | |
167 \end{enumerate} | |
550
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
168 Una vez que haya armado una versión funcional parchada de Mercurial, |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
169 todo lo que necesita es habilitar la extensión \hgext{inotify} |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
170 colocando una entrada en su \hgrc. |
435 | 171 \begin{codesample2} |
172 [extensions] | |
173 inotify = | |
174 \end{codesample2} | |
550
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
175 Cuando la extensión \hgext{inotify} esté habilitada, Mercurial |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
176 iniciará transparente y automáticamente el daemonio de estado la |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
177 primera vez que ejecute un comando que requiera estado del |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
178 repositorio. Ejecuta un daemoniot de estado por repositorio. |
435 | 179 |
550
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
180 El daemonio de estado se inicia silenciosamente y se ejecuta en el |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
181 fondo. Si mira a la lista de procesos en ejecución después de |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
182 habilitar la extensión \hgext{inotify} y ejecuta unos pocos comandos |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
183 en diferentes repositorios, verá que hay algunos procesos de |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
184 \texttt{hg} por ahí, esperando actualizaciones del kernel y |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
185 solicitudes de Mercurial. |
435 | 186 |
550
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
187 La primera vez que ejecuta un comando de Mercurial en un repositorio |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
188 cuando tiene la extensión \hgext{inotify} habilitada, correrá casi con |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
189 el mismo desempeño que una orden usual de Mercurial. Esto es debido a |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
190 que el estado del daemonio necesita aplicar una búsqueda normal sobre |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
191 el estado para poder tener una línea de partida frente a la cual |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
192 aplicar posteriormente actualizaciones del núcleo. De todas formas, |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
193 \emph{todo} comando posterior que haga cualquier clase de revisión del |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
194 estado debería ser notablemente más rápido en repositorios con incluso |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
195 un tamaño modesto. Aún mejor, a medida que su repositorio sea más |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
196 grande, mejor desempeño verá. El daemonio \hgext{inotify} hace |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
197 operaciones de estado de forma casi instantánea en repositorios de |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
198 todos los tamaños! |
435 | 199 |
550
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
200 Si lo desea, puede iniciar manualmente un daemonio de estado con la orden |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
201 \hgxcmd{inotify}{inserve}. Esto le da un control un poco más fino |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
202 acerca de cómo debería ejecutarse el daemonio. Esta orden solamente |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
203 estará disponible cuando haya habilitado la extensión \hgext{inotify}. |
435 | 204 |
550
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
205 Cuando esté usando la extensión \hgext{inotify}, |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
206 \emph{no debería ver diferencia} en el comportamiento de Mercurial, |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
207 con la única excepción de que los comandos relacionados con el estado |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
208 deberían ejectuarse mucho más rápido que como solían hacerlo. Debería |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
209 esperar específicamente que las órdenes no deberían ofrecer salidas |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
210 distintas; ni ofrecer resultados diferentes. Si alguna de estas |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
211 situaciones ocurre, por favor reporte el fallo. |
435 | 212 |
550
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
213 \section{Soporte flexible de diff con la extensión \hgext{extdiff}} |
435 | 214 \label{sec:hgext:extdiff} |
215 | |
550
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
216 La orden predeterminada \hgcmd{diff} de Mercurial despliega diffs en |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
217 texto plano unificadas. |
435 | 218 \interaction{extdiff.diff} |
550
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
219 Si dese emplear una herramienta externa para desplegar las |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
220 modificaciones, querrá usar la extensión \hgext{extdiff}. Esta le |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
221 permitirá usar por ejemplo una herramienta gráfica de diff. |
435 | 222 |
550
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
223 La extensión \hgext{extdiff} viene con Mercurial, y es fácil |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
224 configurarl. En la sección \rcsection{extensions} de su \hgrc, |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
225 basta con añadir una entrada de una línea para habilitar la extensión. |
435 | 226 \begin{codesample2} |
227 [extensions] | |
228 extdiff = | |
229 \end{codesample2} | |
550
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
230 Esto introduce una orden llamada \hgxcmd{extdiff}{extdiff}, que de |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
231 forma predeterminada usa su orden del sistema \command{diff} para |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
232 generar un diff unificado de la misma forma que lo hace el comando |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
233 predeterminado \hgcmd{diff}. |
435 | 234 \interaction{extdiff.extdiff} |
550
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
235 El resultado no será exactamente el mismo que con la orden interna |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
236 \hgcmd{diff}, puesto que la salida de \command{diff} varía de un |
f4904a9b4fdb
Started translating hgext
Igor TAmara <igor@tamarapatino.org>
parents:
539
diff
changeset
|
237 sistema a otro, incluso pasando las mismas opciones. |
435 | 238 |
239 As the ``\texttt{making snapshot}'' lines of output above imply, the | |
240 \hgxcmd{extdiff}{extdiff} command works by creating two snapshots of | |
241 your source tree. The first snapshot is of the source revision; the | |
242 second, of the target revision or working directory. The | |
243 \hgxcmd{extdiff}{extdiff} command generates these snapshots in a | |
244 temporary directory, passes the name of each directory to an external | |
245 diff viewer, then deletes the temporary directory. For efficiency, it | |
246 only snapshots the directories and files that have changed between the | |
247 two revisions. | |
248 | |
249 Snapshot directory names have the same base name as your repository. | |
250 If your repository path is \dirname{/quux/bar/foo}, then \dirname{foo} | |
251 will be the name of each snapshot directory. Each snapshot directory | |
252 name has its changeset ID appended, if appropriate. If a snapshot is | |
253 of revision \texttt{a631aca1083f}, the directory will be named | |
254 \dirname{foo.a631aca1083f}. A snapshot of the working directory won't | |
255 have a changeset ID appended, so it would just be \dirname{foo} in | |
256 this example. To see what this looks like in practice, look again at | |
257 the \hgxcmd{extdiff}{extdiff} example above. Notice that the diff has | |
258 the snapshot directory names embedded in its header. | |
259 | |
260 The \hgxcmd{extdiff}{extdiff} command accepts two important options. | |
261 The \hgxopt{extdiff}{extdiff}{-p} option lets you choose a program to | |
262 view differences with, instead of \command{diff}. With the | |
263 \hgxopt{extdiff}{extdiff}{-o} option, you can change the options that | |
264 \hgxcmd{extdiff}{extdiff} passes to the program (by default, these | |
265 options are ``\texttt{-Npru}'', which only make sense if you're | |
266 running \command{diff}). In other respects, the | |
267 \hgxcmd{extdiff}{extdiff} command acts similarly to the built-in | |
268 \hgcmd{diff} command: you use the same option names, syntax, and | |
269 arguments to specify the revisions you want, the files you want, and | |
270 so on. | |
271 | |
272 As an example, here's how to run the normal system \command{diff} | |
273 command, getting it to generate context diffs (using the | |
274 \cmdopt{diff}{-c} option) instead of unified diffs, and five lines of | |
275 context instead of the default three (passing \texttt{5} as the | |
276 argument to the \cmdopt{diff}{-C} option). | |
277 \interaction{extdiff.extdiff-ctx} | |
278 | |
279 Launching a visual diff tool is just as easy. Here's how to launch | |
280 the \command{kdiff3} viewer. | |
281 \begin{codesample2} | |
282 hg extdiff -p kdiff3 -o '' | |
283 \end{codesample2} | |
284 | |
285 If your diff viewing command can't deal with directories, you can | |
286 easily work around this with a little scripting. For an example of | |
287 such scripting in action with the \hgext{mq} extension and the | |
288 \command{interdiff} command, see | |
289 section~\ref{mq-collab:tips:interdiff}. | |
290 | |
291 \subsection{Defining command aliases} | |
292 | |
293 It can be cumbersome to remember the options to both the | |
294 \hgxcmd{extdiff}{extdiff} command and the diff viewer you want to use, | |
295 so the \hgext{extdiff} extension lets you define \emph{new} commands | |
296 that will invoke your diff viewer with exactly the right options. | |
297 | |
298 All you need to do is edit your \hgrc, and add a section named | |
299 \rcsection{extdiff}. Inside this section, you can define multiple | |
300 commands. Here's how to add a \texttt{kdiff3} command. Once you've | |
301 defined this, you can type ``\texttt{hg kdiff3}'' and the | |
302 \hgext{extdiff} extension will run \command{kdiff3} for you. | |
303 \begin{codesample2} | |
304 [extdiff] | |
305 cmd.kdiff3 = | |
306 \end{codesample2} | |
307 If you leave the right hand side of the definition empty, as above, | |
308 the \hgext{extdiff} extension uses the name of the command you defined | |
309 as the name of the external program to run. But these names don't | |
310 have to be the same. Here, we define a command named ``\texttt{hg | |
311 wibble}'', which runs \command{kdiff3}. | |
312 \begin{codesample2} | |
313 [extdiff] | |
314 cmd.wibble = kdiff3 | |
315 \end{codesample2} | |
316 | |
317 You can also specify the default options that you want to invoke your | |
318 diff viewing program with. The prefix to use is ``\texttt{opts.}'', | |
319 followed by the name of the command to which the options apply. This | |
320 example defines a ``\texttt{hg vimdiff}'' command that runs the | |
321 \command{vim} editor's \texttt{DirDiff} extension. | |
322 \begin{codesample2} | |
323 [extdiff] | |
324 cmd.vimdiff = vim | |
325 opts.vimdiff = -f '+next' '+execute "DirDiff" argv(0) argv(1)' | |
326 \end{codesample2} | |
327 | |
328 \section{Cherrypicking changes with the \hgext{transplant} extension} | |
329 \label{sec:hgext:transplant} | |
330 | |
331 Need to have a long chat with Brendan about this. | |
332 | |
333 \section{Send changes via email with the \hgext{patchbomb} extension} | |
334 \label{sec:hgext:patchbomb} | |
335 | |
336 Many projects have a culture of ``change review'', in which people | |
337 send their modifications to a mailing list for others to read and | |
338 comment on before they commit the final version to a shared | |
339 repository. Some projects have people who act as gatekeepers; they | |
340 apply changes from other people to a repository to which those others | |
341 don't have access. | |
342 | |
343 Mercurial makes it easy to send changes over email for review or | |
344 application, via its \hgext{patchbomb} extension. The extension is so | |
345 namd because changes are formatted as patches, and it's usual to send | |
346 one changeset per email message. Sending a long series of changes by | |
347 email is thus much like ``bombing'' the recipient's inbox, hence | |
348 ``patchbomb''. | |
349 | |
350 As usual, the basic configuration of the \hgext{patchbomb} extension | |
351 takes just one or two lines in your \hgrc. | |
352 \begin{codesample2} | |
353 [extensions] | |
354 patchbomb = | |
355 \end{codesample2} | |
356 Once you've enabled the extension, you will have a new command | |
357 available, named \hgxcmd{patchbomb}{email}. | |
358 | |
359 The safest and best way to invoke the \hgxcmd{patchbomb}{email} | |
360 command is to \emph{always} run it first with the | |
361 \hgxopt{patchbomb}{email}{-n} option. This will show you what the | |
362 command \emph{would} send, without actually sending anything. Once | |
363 you've had a quick glance over the changes and verified that you are | |
364 sending the right ones, you can rerun the same command, with the | |
365 \hgxopt{patchbomb}{email}{-n} option removed. | |
366 | |
367 The \hgxcmd{patchbomb}{email} command accepts the same kind of | |
368 revision syntax as every other Mercurial command. For example, this | |
369 command will send every revision between 7 and \texttt{tip}, | |
370 inclusive. | |
371 \begin{codesample2} | |
372 hg email -n 7:tip | |
373 \end{codesample2} | |
374 You can also specify a \emph{repository} to compare with. If you | |
375 provide a repository but no revisions, the \hgxcmd{patchbomb}{email} | |
376 command will send all revisions in the local repository that are not | |
377 present in the remote repository. If you additionally specify | |
378 revisions or a branch name (the latter using the | |
379 \hgxopt{patchbomb}{email}{-b} option), this will constrain the | |
380 revisions sent. | |
381 | |
382 It's perfectly safe to run the \hgxcmd{patchbomb}{email} command | |
383 without the names of the people you want to send to: if you do this, | |
384 it will just prompt you for those values interactively. (If you're | |
385 using a Linux or Unix-like system, you should have enhanced | |
386 \texttt{readline}-style editing capabilities when entering those | |
387 headers, too, which is useful.) | |
388 | |
389 When you are sending just one revision, the \hgxcmd{patchbomb}{email} | |
390 command will by default use the first line of the changeset | |
391 description as the subject of the single email message it sends. | |
392 | |
393 If you send multiple revisions, the \hgxcmd{patchbomb}{email} command | |
394 will usually send one message per changeset. It will preface the | |
395 series with an introductory message, in which you should describe the | |
396 purpose of the series of changes you're sending. | |
397 | |
398 \subsection{Changing the behaviour of patchbombs} | |
399 | |
400 Not every project has exactly the same conventions for sending changes | |
401 in email; the \hgext{patchbomb} extension tries to accommodate a | |
402 number of variations through command line options. | |
403 \begin{itemize} | |
404 \item You can write a subject for the introductory message on the | |
405 command line using the \hgxopt{patchbomb}{email}{-s} option. This | |
406 takes one argument, the text of the subject to use. | |
407 \item To change the email address from which the messages originate, | |
408 use the \hgxopt{patchbomb}{email}{-f} option. This takes one | |
409 argument, the email address to use. | |
410 \item The default behaviour is to send unified diffs (see | |
411 section~\ref{sec:mq:patch} for a description of the format), one per | |
412 message. You can send a binary bundle instead with the | |
413 \hgxopt{patchbomb}{email}{-b} option. | |
414 \item Unified diffs are normally prefaced with a metadata header. You | |
415 can omit this, and send unadorned diffs, with the | |
416 \hgxopt{patchbomb}{email}{--plain} option. | |
417 \item Diffs are normally sent ``inline'', in the same body part as the | |
418 description of a patch. This makes it easiest for the largest | |
419 number of readers to quote and respond to parts of a diff, as some | |
420 mail clients will only quote the first MIME body part in a message. | |
421 If you'd prefer to send the description and the diff in separate | |
422 body parts, use the \hgxopt{patchbomb}{email}{-a} option. | |
423 \item Instead of sending mail messages, you can write them to an | |
424 \texttt{mbox}-format mail folder using the | |
425 \hgxopt{patchbomb}{email}{-m} option. That option takes one | |
426 argument, the name of the file to write to. | |
427 \item If you would like to add a \command{diffstat}-format summary to | |
428 each patch, and one to the introductory message, use the | |
429 \hgxopt{patchbomb}{email}{-d} option. The \command{diffstat} | |
430 command displays a table containing the name of each file patched, | |
431 the number of lines affected, and a histogram showing how much each | |
432 file is modified. This gives readers a qualitative glance at how | |
433 complex a patch is. | |
434 \end{itemize} | |
435 | |
436 %%% Local Variables: | |
437 %%% mode: latex | |
438 %%% TeX-master: "00book" | |
439 %%% End: |