hgbook
diff es/hook.tex @ 475:22184eb4c965
finished the translation of the section "information for writers of hooks"
updated project status
updated project status
author | Javier Rojas <jerojasro@devnull.li> |
---|---|
date | Wed Dec 31 11:31:04 2008 -0500 (2008-12-31) |
parents | 9438521abfc4 |
children | 1f9ef8b3ab79 |
line diff
1.1 --- a/es/hook.tex Wed Dec 31 10:18:25 2008 -0500 1.2 +++ b/es/hook.tex Wed Dec 31 11:31:04 2008 -0500 1.3 @@ -1066,122 +1066,130 @@ 1.4 a \texttt{false}. Hasta que usted haga eso, simplemente se imprimirá 1.5 el mensaje que se \emph{enviaría}. 1.6 1.7 -\section{Information for writers of hooks} 1.8 +\section{Información para escritores de ganchos} 1.9 \label{sec:hook:ref} 1.10 1.11 -\subsection{In-process hook execution} 1.12 - 1.13 -An in-process hook is called with arguments of the following form: 1.14 +\subsection{Ejecución de ganchos internos} 1.15 + 1.16 +Un gancho interno es llamado con argumentos de la siguiente forma: 1.17 \begin{codesample2} 1.18 def myhook(ui, repo, **kwargs): 1.19 pass 1.20 \end{codesample2} 1.21 -The \texttt{ui} parameter is a \pymodclass{mercurial.ui}{ui} object. 1.22 -The \texttt{repo} parameter is a 1.23 -\pymodclass{mercurial.localrepo}{localrepository} object. The 1.24 -names and values of the \texttt{**kwargs} parameters depend on the 1.25 -hook being invoked, with the following common features: 1.26 -\begin{itemize} 1.27 -\item If a parameter is named \texttt{node} or 1.28 - \texttt{parent\emph{N}}, it will contain a hexadecimal changeset ID. 1.29 - The empty string is used to represent ``null changeset ID'' instead 1.30 - of a string of zeroes. 1.31 -\item If a parameter is named \texttt{url}, it will contain the URL of 1.32 - a remote repository, if that can be determined. 1.33 -\item Boolean-valued parameters are represented as Python 1.34 - \texttt{bool} objects. 1.35 -\end{itemize} 1.36 - 1.37 -An in-process hook is called without a change to the process's working 1.38 -directory (unlike external hooks, which are run in the root of the 1.39 -repository). It must not change the process's working directory, or 1.40 -it will cause any calls it makes into the Mercurial API to fail. 1.41 - 1.42 -If a hook returns a boolean ``false'' value, it is considered to have 1.43 -succeeded. If it returns a boolean ``true'' value or raises an 1.44 -exception, it is considered to have failed. A useful way to think of 1.45 -the calling convention is ``tell me if you fail''. 1.46 - 1.47 -Note that changeset IDs are passed into Python hooks as hexadecimal 1.48 -strings, not the binary hashes that Mercurial's APIs normally use. To 1.49 -convert a hash from hex to binary, use the 1.50 -\pymodfunc{mercurial.node}{bin} function. 1.51 - 1.52 -\subsection{External hook execution} 1.53 - 1.54 -An external hook is passed to the shell of the user running Mercurial. 1.55 -Features of that shell, such as variable substitution and command 1.56 -redirection, are available. The hook is run in the root directory of 1.57 -the repository (unlike in-process hooks, which are run in the same 1.58 -directory that Mercurial was run in). 1.59 - 1.60 -Hook parameters are passed to the hook as environment variables. Each 1.61 -environment variable's name is converted in upper case and prefixed 1.62 -with the string ``\texttt{HG\_}''. For example, if the name of a 1.63 -parameter is ``\texttt{node}'', the name of the environment variable 1.64 -representing that parameter will be ``\texttt{HG\_NODE}''. 1.65 - 1.66 -A boolean parameter is represented as the string ``\texttt{1}'' for 1.67 -``true'', ``\texttt{0}'' for ``false''. If an environment variable is 1.68 -named \envar{HG\_NODE}, \envar{HG\_PARENT1} or \envar{HG\_PARENT2}, it 1.69 -contains a changeset ID represented as a hexadecimal string. The 1.70 -empty string is used to represent ``null changeset ID'' instead of a 1.71 -string of zeroes. If an environment variable is named 1.72 -\envar{HG\_URL}, it will contain the URL of a remote repository, if 1.73 -that can be determined. 1.74 - 1.75 -If a hook exits with a status of zero, it is considered to have 1.76 -succeeded. If it exits with a non-zero status, it is considered to 1.77 -have failed. 1.78 - 1.79 -\subsection{Finding out where changesets come from} 1.80 - 1.81 -A hook that involves the transfer of changesets between a local 1.82 -repository and another may be able to find out information about the 1.83 -``far side''. Mercurial knows \emph{how} changes are being 1.84 -transferred, and in many cases \emph{where} they are being transferred 1.85 -to or from. 1.86 - 1.87 -\subsubsection{Sources of changesets} 1.88 +El parámetro \texttt{ui} es un objeto \pymodclass{mercurial.ui}{ui}. 1.89 +El parámetro \texttt{repo} es un objeto 1.90 +\pymodclass{mercurial.localrepo}{localrepository}. Los nombres y 1.91 +valores de los parámetros en \texttt{**kwargs} dependen del gancho que 1.92 +se invoque, con las siguientes características en común: 1.93 +\begin{itemize} 1.94 +\item Si hay un parámetro llamado \texttt{node} o 1.95 + \texttt{parent\emph{N}}, contendrá un ID hexadecimal de un conjunto 1.96 + de cambios. La cadena vacía es usada para representar un 1.97 + ``ID de conjunto de cambios nulo'' en vez de una cadena de ceros. 1.98 +\item Si hay un parámetro llamado \texttt{url}, contendrá la URL de un 1.99 + repositorio remoto, si puede ser determinada. 1.100 +\item Los parámetros booleanos son representados como objetos 1.101 + \texttt{bool} de Python. 1.102 +\end{itemize} 1.103 + 1.104 +Un gancho interno es ejecutado sin cambiar el directorio de trabajo 1.105 +del proceso (a diferencia de los ganchos externos, que son ejecutados 1.106 +desde la raíz del repositorio). El gancho no debe cambiar el 1.107 +directorio de trabajo del proceso, porque esto haría que falle 1.108 +cualquier llamada que se haga a la API de Mercurial. 1.109 + 1.110 +Si un gancho retorna el valor booleano ``false''\footnote{Falso.}, se 1.111 +considera que éste tuvo éxito. Si retorna 1.112 +``true''\footnote{Verdadero.} o genera una excepción, se considera que 1.113 +ha fallado. Una manera útil de pensar en esta convención de llamado es 1.114 +``dígame si usted falló''. 1.115 + 1.116 +Note que los IDs de conjuntos de cambios son pasados a los ganchos de 1.117 +Python como cadenas hexadecimales, no como los hashes binarios que la 1.118 +API de Mercurial usa normalmente. Para convertir un hash de 1.119 +hexadecimal a binario, use la función \pymodfunc{mercurial.node}{bin}. 1.120 + 1.121 +\subsection{Ejecución de ganchos externos} 1.122 + 1.123 +Un gancho externo es pasado al intérprete de comandos del usuario bajo 1.124 +el cual se ejecuta Mercurial. Las características del intérprete, como 1.125 +sustitución de variables y redirección de comandos, están disponibles. 1.126 +El gancho es ejecutado desde el directorio raíz del repositorio 1.127 +(a diferencia de los ganchos internos, que se ejecutan desde el mismo 1.128 +directorio en que Mercurial fue ejecutado). 1.129 + 1.130 +Los parámetros para el gancho se pasan como variables de entorno. El 1.131 +nombre de cada variable de entorno se pasa a mayúsculas y se le añade 1.132 +el prefijo ``\texttt{HG\_}''. Por ejemplo, si el nombre de un 1.133 +parámetro es ``\texttt{node}'', el nombre de la variable de entorno 1.134 +que almacena el parámetro se llamará ``\texttt{HG\_NODE}''. 1.135 + 1.136 +Un parámetro booleano se representa con la cadena ``\texttt{1}'' para 1.137 +``true'', ``\texttt{0}'' para ``false''. Si una variable se llama 1.138 +\envar{HG\_NODE}, \envar{HG\_PARENT1} o \envar{HG\_PARENT2}, 1.139 +contendrá un ID de conjunto de cambios representado como una cadena 1.140 +hexadecimal. La cadena vacía es usada para representar un ``ID de 1.141 +conjunto de cambios nulo'' en vez de una cadena de ceros. Si una 1.142 +variable de entorno se llama \envar{HG\_URL}, contendrá la URL de un 1.143 +repositorio remoto, si puede ser determinada. 1.144 + 1.145 +Si un gancho termina con un código de salida de cero, se considera que 1.146 +tuvo éxito. Si termina con un código de salida diferente de cero, se 1.147 +considera que falló. 1.148 + 1.149 +\subsection{Averiguar de dónde vienen los conjuntos de cambios} 1.150 +%TODO los trae la cigüeña. De París. Y quedan debajo de una col. 1.151 + 1.152 +Un gancho que involucra la transferencia de conjuntos de cambios entre 1.153 +un repositorio local y otro puede ser capaz de averiguar información 1.154 +acerca de ``el otro lado''. Mercurial sabe \emph{cómo} son 1.155 +transferidos los conjuntos de cambios, y en muchos casos también desde 1.156 +o hacia donde están siendo transferidos. 1.157 + 1.158 +\subsubsection{Fuentes de conjuntos de cambios} 1.159 \label{sec:hook:sources} 1.160 1.161 -Mercurial will tell a hook what means are, or were, used to transfer 1.162 -changesets between repositories. This is provided by Mercurial in a 1.163 -Python parameter named \texttt{source}, or an environment variable named 1.164 -\envar{HG\_SOURCE}. 1.165 - 1.166 -\begin{itemize} 1.167 -\item[\texttt{serve}] Changesets are transferred to or from a remote 1.168 - repository over http or ssh. 1.169 -\item[\texttt{pull}] Changesets are being transferred via a pull from 1.170 - one repository into another. 1.171 -\item[\texttt{push}] Changesets are being transferred via a push from 1.172 - one repository into another. 1.173 -\item[\texttt{bundle}] Changesets are being transferred to or from a 1.174 - bundle. 1.175 -\end{itemize} 1.176 - 1.177 -\subsubsection{Where changes are going---remote repository URLs} 1.178 +Mercurial le indicará a un gancho cuáles son, o fueron, los medios 1.179 +usados para transferir los conjuntos de cambios entre repositorios. 1.180 +Esta información es provista por Mercurial en un parámetro Python 1.181 +llamado \texttt{source}\footnote{Fuente.}, o una variable de entorno 1.182 +llamada \envar{HG\_SOURCE}. 1.183 + 1.184 +\begin{itemize} 1.185 +\item[\texttt{serve}] Los conjuntos de cambios son transferidos desde 1.186 + o hacia un repositorio remoto a través de http o ssh. 1.187 +\item[\texttt{pull}] Los conjuntos de cambios son transferidos vía una 1.188 + operación de jalado de un repositorio a otro. 1.189 +\item[\texttt{push}] Los conjuntos de cambios son transferidos vía un 1.190 + empuje de un repositorio a otro. 1.191 +\item[\texttt{bundle}] Los conjuntos de cambios son transferidos desde 1.192 + %TODO bundle 1.193 + o hacia un bundle. 1.194 +\end{itemize} 1.195 + 1.196 +\subsubsection{A dónde van los cambios---URLs de repositorios remotos} 1.197 \label{sec:hook:url} 1.198 - 1.199 -When possible, Mercurial will tell a hook the location of the ``far 1.200 -side'' of an activity that transfers changeset data between 1.201 -repositories. This is provided by Mercurial in a Python parameter 1.202 -named \texttt{url}, or an environment variable named \envar{HG\_URL}. 1.203 - 1.204 -This information is not always known. If a hook is invoked in a 1.205 -repository that is being served via http or ssh, Mercurial cannot tell 1.206 -where the remote repository is, but it may know where the client is 1.207 -connecting from. In such cases, the URL will take one of the 1.208 -following forms: 1.209 -\begin{itemize} 1.210 -\item \texttt{remote:ssh:\emph{ip-address}}---remote ssh client, at 1.211 - the given IP address. 1.212 -\item \texttt{remote:http:\emph{ip-address}}---remote http client, at 1.213 - the given IP address. If the client is using SSL, this will be of 1.214 - the form \texttt{remote:https:\emph{ip-address}}. 1.215 -\item Empty---no information could be discovered about the remote 1.216 - client. 1.217 +%TODO al cielo? no, ésos son los perros 1.218 + 1.219 +Cuando es posible, Mercurial le indicará a los ganchos la ubicación de 1.220 +``el otro lado'' de una actividad que transfiera datos de conjuntos de 1.221 +cambios entre repositorios. Esto es provisto por Mercurial en un 1.222 +parámetro Python llamado \texttt{url}, o en una variable de entorno 1.223 +llamada \envar{HG\_URL}. 1.224 + 1.225 +No siempre esta información está disponible. Si un gancho es invocado 1.226 +un repositorio que es servido a través de http o ssh, Mercurial no 1.227 +puede averiguar dónde está el repositorio remoto, pero puede saber 1.228 +desde dónde se conecta el cliente. En esos casos, la URL tendrá una de 1.229 +las siguientes formas: 1.230 +\begin{itemize} 1.231 +\item \texttt{remote:ssh:\emph{ip-address}}---cliente ssh remoto, en 1.232 + la dirección IP dada. 1.233 +\item \texttt{remote:http:\emph{ip-address}}---cliente remoto http, en 1.234 + la dirección IP dada. Si el cliente está usando SSL, tendrá la forma 1.235 + \texttt{remote:https:\emph{ip-address}}. 1.236 +\item Vacío---no se pudo descubrir información acerca del cliente 1.237 + remoto. 1.238 \end{itemize} 1.239 1.240 \section{Hook reference}