Mercurial > hgbook
comparison es/hook.tex @ 541:606295a87ff2
translated a bit more of hook.tex
author | jerojasro@abu.no-ip.org |
---|---|
date | Mon, 08 Dec 2008 12:55:51 -0500 |
parents | 4e0684e824e1 |
children | 5a0401ba9faa |
comparison
equal
deleted
inserted
replaced
540:4e0684e824e1 | 541:606295a87ff2 |
---|---|
256 cambios. | 256 cambios. |
257 | 257 |
258 \section{Tutorial corto de uso de ganchos} | 258 \section{Tutorial corto de uso de ganchos} |
259 \label{sec:hook:simple} | 259 \label{sec:hook:simple} |
260 | 260 |
261 It is easy to write a Mercurial hook. Let's start with a hook that | 261 Escribir un gancho para Mercurial es fácil. Empecemos con un gancho |
262 runs when you finish a \hgcmd{commit}, and simply prints the hash of | 262 que se ejecute cuando usted termine un \hgcmd{commit}, y simplemente |
263 the changeset you just created. The hook is called \hook{commit}. | 263 muestre el hash del conjunto de cambios que usted acaba de crear. El |
264 gancho se llamará \hook{commit}. | |
264 | 265 |
265 \begin{figure}[ht] | 266 \begin{figure}[ht] |
266 \interaction{hook.simple.init} | 267 \interaction{hook.simple.init} |
267 \caption{A simple hook that runs when a changeset is committed} | 268 \caption{Un gancho simple que se ejecuta al hacer la consignación de |
269 un conjunto de cambios} | |
268 \label{ex:hook:init} | 270 \label{ex:hook:init} |
269 \end{figure} | 271 \end{figure} |
270 | 272 |
271 All hooks follow the pattern in example~\ref{ex:hook:init}. You add | 273 Todos los ganchos siguen el patrón del ejemplo~\ref{ex:hook:init}. |
272 an entry to the \rcsection{hooks} section of your \hgrc. On the left | 274 Usted puede añadir una entrada a la sección \rcsection{hooks} de su |
273 is the name of the event to trigger on; on the right is the action to | 275 fichero \hgrc. A la izquierda está el nombre del evento respecto al |
274 take. As you can see, you can run an arbitrary shell command in a | 276 cual dispararse; a la derecha está la acción a llevar a cabo. Como |
275 hook. Mercurial passes extra information to the hook using | 277 puede ver, es posible ejecutar cualquier orden de la línea de comandos |
276 environment variables (look for \envar{HG\_NODE} in the example). | 278 en un gancho. Mercurial le pasa información extra al gancho usando |
277 | 279 variables de entorno (busque \envar{HG\_NODE} en el ejemplo). |
278 \subsection{Performing multiple actions per event} | 280 |
279 | 281 \subsection{Llevar a cabo varias acciones por evento} |
280 Quite often, you will want to define more than one hook for a | 282 |
281 particular kind of event, as shown in example~\ref{ex:hook:ext}. | 283 A menudo, usted querrá definir más de un gancho para un tipo de evento |
282 Mercurial lets you do this by adding an \emph{extension} to the end of | 284 particular, como se muestra en el ejemplo~\ref{ex:hook:ext}. |
283 a hook's name. You extend a hook's name by giving the name of the | 285 Mercurial le permite hacer esto añadiendo una \emph{extensión} al |
284 hook, followed by a full stop (the ``\texttt{.}'' character), followed | 286 final del nombre de un gancho. Usted extiende el nombre del gancho |
285 by some more text of your choosing. For example, Mercurial will run | 287 %TODO Yuk, no me gusta ese "parada completa" |
286 both \texttt{commit.foo} and \texttt{commit.bar} when the | 288 poniendo el nombre del gancho, seguido por una parada completa (el |
287 \texttt{commit} event occurs. | 289 caracter ``\texttt{.}''), seguido de algo más de texto de su elección. |
290 Por ejemplo, Mercurial ejecutará tanto \texttt{commit.foo} como | |
291 \texttt{commit.bar} cuando ocurra el evento \texttt{commit}. | |
288 | 292 |
289 \begin{figure}[ht] | 293 \begin{figure}[ht] |
290 \interaction{hook.simple.ext} | 294 \interaction{hook.simple.ext} |
291 \caption{Defining a second \hook{commit} hook} | 295 \caption{Definición de un segundo gancho \hook{commit}} |
292 \label{ex:hook:ext} | 296 \label{ex:hook:ext} |
293 \end{figure} | 297 \end{figure} |
294 | 298 |
295 To give a well-defined order of execution when there are multiple | 299 Para dar un orden bien definido de ejecución cuando hay múltiples |
296 hooks defined for an event, Mercurial sorts hooks by extension, and | 300 ganchos definidos para un evento, Mercurial ordena los ganchos de |
297 executes the hook commands in this sorted order. In the above | 301 acuerdo a su extensión, y los ejecuta en dicho orden. En el ejemplo de |
298 example, it will execute \texttt{commit.bar} before | 302 arribam \texttt{commit.bar} se ejecutará antes que |
299 \texttt{commit.foo}, and \texttt{commit} before both. | 303 \texttt{commit.foo}, y \texttt{commit} se ejecutará antes de ambos. |
300 | 304 |
301 It is a good idea to use a somewhat descriptive extension when you | 305 Es una buena idea usar una extensión descriptiva cuando usted define |
302 define a new hook. This will help you to remember what the hook was | 306 un gancho. Esto le ayudará a recordar para qué se usa el gancho. Si el |
303 for. If the hook fails, you'll get an error message that contains the | 307 gancho falla, usted recibirá un mensaje de error que contiene el |
304 hook name and extension, so using a descriptive extension could give | 308 nombre y la extensión del gancho, así que usar una extensión |
305 you an immediate hint as to why the hook failed (see | 309 descriptiva le dará una pista inmediata de porqué el gancho falló (vea |
306 section~\ref{sec:hook:perm} for an example). | 310 un ejemplo en la sección~\ref{sec:hook:perm}). |
307 | 311 |
308 \subsection{Controlling whether an activity can proceed} | 312 \subsection{Controlar cuándo puede llevarse a cabo una actividad} |
309 \label{sec:hook:perm} | 313 \label{sec:hook:perm} |
310 | 314 |
311 In our earlier examples, we used the \hook{commit} hook, which is | 315 En los ejemplos anteriores, usamos el gancho \hook{commit}, que es |
312 run after a commit has completed. This is one of several Mercurial | 316 ejecutado después de que se ha completado una consignación. Este es |
313 hooks that run after an activity finishes. Such hooks have no way of | 317 uno de los varios ganchos que Mercurial ejecuta luego de que una |
314 influencing the activity itself. | 318 actividad termina. Tales ganchos no tienen forma de influenciar la |
315 | 319 actividad como tal. |
316 Mercurial defines a number of events that occur before an activity | 320 |
317 starts; or after it starts, but before it finishes. Hooks that | 321 Mercurial define un número de eventos que ocurren antes de que una |
318 trigger on these events have the added ability to choose whether the | 322 actividad empiece; o luego de que empiece, pero antes de que termine. |
319 activity can continue, or will abort. | 323 Los ganchos que se disparan con estos eventos tienen la capacidad |
320 | 324 adicional de elegir si la actividad puede continuar, o si su ejecución |
321 The \hook{pretxncommit} hook runs after a commit has all but | 325 es abortada. |
322 completed. In other words, the metadata representing the changeset | 326 |
323 has been written out to disk, but the transaction has not yet been | 327 El gancho \hook{pretxncommit} se ejecuta justo antes de que una |
324 allowed to complete. The \hook{pretxncommit} hook has the ability to | 328 consignación se ejecute. En otras palabras, los metadatos que |
325 decide whether the transaction can complete, or must be rolled back. | 329 representan el conjunto de cambios han sido escritos al disco, pero no |
326 | 330 se ha terminado la transacción. El gancho \hook{pretxncommit} tiene la |
327 If the \hook{pretxncommit} hook exits with a status code of zero, the | 331 capacidad de decidir si una transacción se completa, o debe |
328 transaction is allowed to complete; the commit finishes; and the | 332 deshacerse. |
329 \hook{commit} hook is run. If the \hook{pretxncommit} hook exits with | 333 |
330 a non-zero status code, the transaction is rolled back; the metadata | 334 Si el gancho \hook{pretxncommit} termina con un código de salida de |
331 representing the changeset is erased; and the \hook{commit} hook is | 335 cero, se permite que la transacción se complete; la consignación |
332 not run. | 336 termina; y el gancho \hook{commit} es ejecutado. Si el gancho |
337 \hook{pretxncommit} termina con un código de salida diferente de cero, | |
338 la transacción es revertida; los metadatos representando el conjunto | |
339 de cambios son borrados; y el gancho \hook{commit} no es ejecutado. | |
333 | 340 |
334 \begin{figure}[ht] | 341 \begin{figure}[ht] |
335 \interaction{hook.simple.pretxncommit} | 342 \interaction{hook.simple.pretxncommit} |
336 \caption{Using the \hook{pretxncommit} hook to control commits} | 343 \caption{Uso del gancho \hook{pretxncommit} hook to control commits} |
337 \label{ex:hook:pretxncommit} | 344 \label{ex:hook:pretxncommit} |
338 \end{figure} | 345 \end{figure} |
339 | 346 |
340 The hook in example~\ref{ex:hook:pretxncommit} checks that a commit | 347 The hook in example~\ref{ex:hook:pretxncommit} checks that a commit |
341 comment contains a bug ID. If it does, the commit can complete. If | 348 comment contains a bug ID. If it does, the commit can complete. If |