hgbook
diff es/hook.tex @ 442:606295a87ff2
translated a bit more of hook.tex
author | jerojasro@abu.no-ip.org |
---|---|
date | Mon Dec 08 12:55:51 2008 -0500 (2008-12-08) |
parents | 4e0684e824e1 |
children | 5a0401ba9faa |
line diff
1.1 --- a/es/hook.tex Mon Dec 08 11:16:54 2008 -0500 1.2 +++ b/es/hook.tex Mon Dec 08 12:55:51 2008 -0500 1.3 @@ -258,82 +258,89 @@ 1.4 \section{Tutorial corto de uso de ganchos} 1.5 \label{sec:hook:simple} 1.6 1.7 -It is easy to write a Mercurial hook. Let's start with a hook that 1.8 -runs when you finish a \hgcmd{commit}, and simply prints the hash of 1.9 -the changeset you just created. The hook is called \hook{commit}. 1.10 +Escribir un gancho para Mercurial es fácil. Empecemos con un gancho 1.11 +que se ejecute cuando usted termine un \hgcmd{commit}, y simplemente 1.12 +muestre el hash del conjunto de cambios que usted acaba de crear. El 1.13 +gancho se llamará \hook{commit}. 1.14 1.15 \begin{figure}[ht] 1.16 \interaction{hook.simple.init} 1.17 - \caption{A simple hook that runs when a changeset is committed} 1.18 + \caption{Un gancho simple que se ejecuta al hacer la consignación de 1.19 + un conjunto de cambios} 1.20 \label{ex:hook:init} 1.21 \end{figure} 1.22 1.23 -All hooks follow the pattern in example~\ref{ex:hook:init}. You add 1.24 -an entry to the \rcsection{hooks} section of your \hgrc. On the left 1.25 -is the name of the event to trigger on; on the right is the action to 1.26 -take. As you can see, you can run an arbitrary shell command in a 1.27 -hook. Mercurial passes extra information to the hook using 1.28 -environment variables (look for \envar{HG\_NODE} in the example). 1.29 - 1.30 -\subsection{Performing multiple actions per event} 1.31 - 1.32 -Quite often, you will want to define more than one hook for a 1.33 -particular kind of event, as shown in example~\ref{ex:hook:ext}. 1.34 -Mercurial lets you do this by adding an \emph{extension} to the end of 1.35 -a hook's name. You extend a hook's name by giving the name of the 1.36 -hook, followed by a full stop (the ``\texttt{.}'' character), followed 1.37 -by some more text of your choosing. For example, Mercurial will run 1.38 -both \texttt{commit.foo} and \texttt{commit.bar} when the 1.39 -\texttt{commit} event occurs. 1.40 +Todos los ganchos siguen el patrón del ejemplo~\ref{ex:hook:init}. 1.41 +Usted puede añadir una entrada a la sección \rcsection{hooks} de su 1.42 +fichero \hgrc. A la izquierda está el nombre del evento respecto al 1.43 +cual dispararse; a la derecha está la acción a llevar a cabo. Como 1.44 +puede ver, es posible ejecutar cualquier orden de la línea de comandos 1.45 +en un gancho. Mercurial le pasa información extra al gancho usando 1.46 +variables de entorno (busque \envar{HG\_NODE} en el ejemplo). 1.47 + 1.48 +\subsection{Llevar a cabo varias acciones por evento} 1.49 + 1.50 +A menudo, usted querrá definir más de un gancho para un tipo de evento 1.51 +particular, como se muestra en el ejemplo~\ref{ex:hook:ext}. 1.52 +Mercurial le permite hacer esto añadiendo una \emph{extensión} al 1.53 +final del nombre de un gancho. Usted extiende el nombre del gancho 1.54 +%TODO Yuk, no me gusta ese "parada completa" 1.55 +poniendo el nombre del gancho, seguido por una parada completa (el 1.56 +caracter ``\texttt{.}''), seguido de algo más de texto de su elección. 1.57 +Por ejemplo, Mercurial ejecutará tanto \texttt{commit.foo} como 1.58 +\texttt{commit.bar} cuando ocurra el evento \texttt{commit}. 1.59 1.60 \begin{figure}[ht] 1.61 \interaction{hook.simple.ext} 1.62 - \caption{Defining a second \hook{commit} hook} 1.63 + \caption{Definición de un segundo gancho \hook{commit}} 1.64 \label{ex:hook:ext} 1.65 \end{figure} 1.66 1.67 -To give a well-defined order of execution when there are multiple 1.68 -hooks defined for an event, Mercurial sorts hooks by extension, and 1.69 -executes the hook commands in this sorted order. In the above 1.70 -example, it will execute \texttt{commit.bar} before 1.71 -\texttt{commit.foo}, and \texttt{commit} before both. 1.72 - 1.73 -It is a good idea to use a somewhat descriptive extension when you 1.74 -define a new hook. This will help you to remember what the hook was 1.75 -for. If the hook fails, you'll get an error message that contains the 1.76 -hook name and extension, so using a descriptive extension could give 1.77 -you an immediate hint as to why the hook failed (see 1.78 -section~\ref{sec:hook:perm} for an example). 1.79 - 1.80 -\subsection{Controlling whether an activity can proceed} 1.81 +Para dar un orden bien definido de ejecución cuando hay múltiples 1.82 +ganchos definidos para un evento, Mercurial ordena los ganchos de 1.83 +acuerdo a su extensión, y los ejecuta en dicho orden. En el ejemplo de 1.84 +arribam \texttt{commit.bar} se ejecutará antes que 1.85 +\texttt{commit.foo}, y \texttt{commit} se ejecutará antes de ambos. 1.86 + 1.87 +Es una buena idea usar una extensión descriptiva cuando usted define 1.88 +un gancho. Esto le ayudará a recordar para qué se usa el gancho. Si el 1.89 +gancho falla, usted recibirá un mensaje de error que contiene el 1.90 +nombre y la extensión del gancho, así que usar una extensión 1.91 +descriptiva le dará una pista inmediata de porqué el gancho falló (vea 1.92 +un ejemplo en la sección~\ref{sec:hook:perm}). 1.93 + 1.94 +\subsection{Controlar cuándo puede llevarse a cabo una actividad} 1.95 \label{sec:hook:perm} 1.96 1.97 -In our earlier examples, we used the \hook{commit} hook, which is 1.98 -run after a commit has completed. This is one of several Mercurial 1.99 -hooks that run after an activity finishes. Such hooks have no way of 1.100 -influencing the activity itself. 1.101 - 1.102 -Mercurial defines a number of events that occur before an activity 1.103 -starts; or after it starts, but before it finishes. Hooks that 1.104 -trigger on these events have the added ability to choose whether the 1.105 -activity can continue, or will abort. 1.106 - 1.107 -The \hook{pretxncommit} hook runs after a commit has all but 1.108 -completed. In other words, the metadata representing the changeset 1.109 -has been written out to disk, but the transaction has not yet been 1.110 -allowed to complete. The \hook{pretxncommit} hook has the ability to 1.111 -decide whether the transaction can complete, or must be rolled back. 1.112 - 1.113 -If the \hook{pretxncommit} hook exits with a status code of zero, the 1.114 -transaction is allowed to complete; the commit finishes; and the 1.115 -\hook{commit} hook is run. If the \hook{pretxncommit} hook exits with 1.116 -a non-zero status code, the transaction is rolled back; the metadata 1.117 -representing the changeset is erased; and the \hook{commit} hook is 1.118 -not run. 1.119 +En los ejemplos anteriores, usamos el gancho \hook{commit}, que es 1.120 +ejecutado después de que se ha completado una consignación. Este es 1.121 +uno de los varios ganchos que Mercurial ejecuta luego de que una 1.122 +actividad termina. Tales ganchos no tienen forma de influenciar la 1.123 +actividad como tal. 1.124 + 1.125 +Mercurial define un número de eventos que ocurren antes de que una 1.126 +actividad empiece; o luego de que empiece, pero antes de que termine. 1.127 +Los ganchos que se disparan con estos eventos tienen la capacidad 1.128 +adicional de elegir si la actividad puede continuar, o si su ejecución 1.129 +es abortada. 1.130 + 1.131 +El gancho \hook{pretxncommit} se ejecuta justo antes de que una 1.132 +consignación se ejecute. En otras palabras, los metadatos que 1.133 +representan el conjunto de cambios han sido escritos al disco, pero no 1.134 +se ha terminado la transacción. El gancho \hook{pretxncommit} tiene la 1.135 +capacidad de decidir si una transacción se completa, o debe 1.136 +deshacerse. 1.137 + 1.138 +Si el gancho \hook{pretxncommit} termina con un código de salida de 1.139 +cero, se permite que la transacción se complete; la consignación 1.140 +termina; y el gancho \hook{commit} es ejecutado. Si el gancho 1.141 +\hook{pretxncommit} termina con un código de salida diferente de cero, 1.142 +la transacción es revertida; los metadatos representando el conjunto 1.143 +de cambios son borrados; y el gancho \hook{commit} no es ejecutado. 1.144 1.145 \begin{figure}[ht] 1.146 \interaction{hook.simple.pretxncommit} 1.147 - \caption{Using the \hook{pretxncommit} hook to control commits} 1.148 + \caption{Uso del gancho \hook{pretxncommit} hook to control commits} 1.149 \label{ex:hook:pretxncommit} 1.150 \end{figure} 1.151