Mercurial > hgbook
annotate es/tour-basic.tex @ 467:1d31f4902e62
translated up to section 1.6 (included)
author | Javier Rojas <jerojasro@devnull.li> |
---|---|
date | Sun, 26 Oct 2008 12:20:09 -0500 |
parents | 6c5ec67f47f9 |
children | 0801d625fabe |
rev | line source |
---|---|
442 | 1 \chapter{Una gira de Mercurial: lo básico} |
2 \label{chap:tour-basic} | |
3 | |
4 \section{Instalar Mercurial en su sistema} | |
5 \label{sec:tour:install} | |
6 Hay paquetes binarios precompilados de Mercurial disponibles para cada | |
7 sistema operativo popular. Esto hace fácil empezar a usar Mercurial | |
8 en su computador inmediatamente. | |
9 | |
10 \subsection{Linux} | |
11 | |
12 Dado que cada distribución de Linux tiene sus propias herramientas de | |
13 manejo de paquetes, políticas, y ritmos de desarrollo, es difícil dar | |
14 un conjunto exhaustivo de instrucciones sobre cómo instalar el paquete | |
15 de Mercurial. La versión de Mercurial que usted tenga a disposición | |
16 puede variar dependiendo de qué tan activa sea la persona que mantiene | |
17 el paquete para su distribución. | |
18 | |
19 Para mantener las cosas simples, me enfocaré en instalar Mercurial | |
20 desde la línea de comandos en las distribuciones de Linux más | |
21 populares. La mayoría de estas distribuciones proveen administradores | |
22 de paquetes gráficos que le permitirán instalar Mercurial con un solo | |
23 clic; el nombre de paquete a buscar es \texttt{mercurial}. | |
24 | |
25 \begin{itemize} | |
26 \item[Debian] | |
27 \begin{codesample4} | |
28 apt-get install mercurial | |
29 \end{codesample4} | |
30 | |
31 \item[Fedora Core] | |
32 \begin{codesample4} | |
33 yum install mercurial | |
34 \end{codesample4} | |
35 | |
36 \item[Gentoo] | |
37 \begin{codesample4} | |
38 emerge mercurial | |
39 \end{codesample4} | |
40 | |
41 \item[OpenSUSE] | |
42 \begin{codesample4} | |
43 yum install mercurial | |
44 \end{codesample4} | |
45 | |
46 \item[Ubuntu] El paquete de Mercurial de Ubuntu está basado en el de | |
47 Debian. Para instalarlo, ejecute el siguiente comando. | |
48 \begin{codesample4} | |
49 apt-get install mercurial | |
50 \end{codesample4} | |
51 El paquete de Mercurial para Ubuntu tiende a atrasarse con respecto | |
52 a la versión de Debian por un margen de tiempo considerable | |
53 (al momento de escribir esto, 7 meses), lo que en algunos casos | |
54 significará que usted puede encontrarse con problemas que ya habrán | |
55 sido resueltos en el paquete de Debian. | |
56 \end{itemize} | |
57 | |
58 \subsection{Solaris} | |
59 | |
60 SunFreeWare, en \url{http://www.sunfreeware.com}, es una buena fuente | |
61 para un gran número de paquetes compilados para Solaris para las | |
62 arquitecturas Intel y Sparc de 32 y 64 bits, incluyendo versiones | |
63 actuales de Mercurial. | |
64 | |
65 \subsection{Mac OS X} | |
66 | |
67 Lee Cantey publica un instalador de Mercurial para Mac OS~X en | |
68 \url{http://mercurial.berkwood.com}. Este paquete funciona en tanto | |
69 en Macs basados en Intel como basados en PowerPC. Antes de que pueda | |
70 usarlo, usted debe instalar una versión compatible de Universal | |
71 MacPython~\cite{web:macpython}. Esto es fácil de hacer; simplemente | |
72 siga las instrucciones de el sitio de Lee. | |
73 | |
74 También es posible instalar Mercurial usando Fink o MacPorts, dos | |
75 administradores de paquetes gratuitos y populares para Mac OS X. Si | |
76 usted tiene Fink, use \command{sudo apt-get install mercurial-py25}. | |
77 Si usa MacPorts, \command{sudo port install mercurial}. | |
78 | |
79 \subsection{Windows} | |
80 | |
81 Lee Cantey publica un instalador de Mercurial para Windows en | |
82 \url{http://mercurial.berkwood.com}. Este paquete no tiene | |
83 % TODO traducción de it just works. Agreed? | |
84 dependencias externas; ``simplemente funciona''. | |
85 | |
86 \begin{note} | |
87 La versión de Windows de Mercurial no convierte automáticamente | |
88 los fines de línea entre estilos Windows y Unix. Si usted desea | |
89 compartir trabajo con usuarios de Unix, deberá hacer un trabajo | |
90 adicional de configuración. XXX Terminar esto. | |
91 \end{note} | |
92 | |
93 \section{Arrancando} | |
94 | |
95 Para empezar, usaremos el comando \hgcmd{version} para revisar si | |
96 Mercurial está instalado adecuadamente. La información de la versión | |
97 que es impresa no es tan importante; lo que nos importa es si imprime | |
98 algo en absoluto. | |
99 | |
100 \interaction{tour.version} | |
101 | |
102 % TODO builtin-> integrado? | |
103 \subsection{Ayuda integrada} | |
104 | |
105 Mercurial provee un sistema de ayuda integrada. Esto es invaluable | |
106 para ésas ocasiones en la que usted está atorado tratando de recordar | |
107 cómo ejecutar un comando. Si está completamente atorado, simplemente | |
108 ejecute \hgcmd{help}; esto imprimirá una breve lista de comandos, | |
109 junto con una descripción de qué hace cada uno. Si usted solicita | |
110 ayuda sobre un comando específico (como abajo), se imprime información | |
111 más detallada. | |
112 \interaction{tour.help} | |
113 Para un nivel más impresionante de detalle (que usted no va a | |
114 necesitar usualmente) ejecute \hgcmdargs{help}{\hggopt{-v}}. La opción | |
115 \hggopt{-v} es la abreviación para \hggopt{--verbose}, y le indica a | |
116 Mercurial que imprima más información de lo que haría usualmente. | |
117 | |
451
9f460a706292
translated a few sections from tour-basic.tex
jerojasro@localhost
parents:
442
diff
changeset
|
118 \section{Trabajar con un repositorio} |
442 | 119 |
451
9f460a706292
translated a few sections from tour-basic.tex
jerojasro@localhost
parents:
442
diff
changeset
|
120 En Mercurial, todo sucede dentro de un \emph{repositorio}. El |
461
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
121 repositorio para un proyecto contiene todos los ficheros que |
451
9f460a706292
translated a few sections from tour-basic.tex
jerojasro@localhost
parents:
442
diff
changeset
|
122 ``pertenecen a'' ése proyecto, junto con un registro histórico de los |
461
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
123 ficheros de ese proyecto. |
442 | 124 |
451
9f460a706292
translated a few sections from tour-basic.tex
jerojasro@localhost
parents:
442
diff
changeset
|
125 No hay nada particularmente mágico acerca de un repositorio; es |
461
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
126 simplemente un árbol de directorios en su sistema de ficheros que |
451
9f460a706292
translated a few sections from tour-basic.tex
jerojasro@localhost
parents:
442
diff
changeset
|
127 Mercurial trata como especial. Usted puede renombrar o borrar un |
9f460a706292
translated a few sections from tour-basic.tex
jerojasro@localhost
parents:
442
diff
changeset
|
128 repositorio en el momento que lo desee, usando bien sea la línea de |
9f460a706292
translated a few sections from tour-basic.tex
jerojasro@localhost
parents:
442
diff
changeset
|
129 comandos o su explorador de ficheros. |
442 | 130 |
451
9f460a706292
translated a few sections from tour-basic.tex
jerojasro@localhost
parents:
442
diff
changeset
|
131 \subsection{Hacer una copia local de un repositorio} |
442 | 132 |
451
9f460a706292
translated a few sections from tour-basic.tex
jerojasro@localhost
parents:
442
diff
changeset
|
133 \emph{Copiar} un repositorio es sólo ligeramente especial. Aunque |
461
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
134 usted podría usar un programa normal de copia de ficheros para hacer |
451
9f460a706292
translated a few sections from tour-basic.tex
jerojasro@localhost
parents:
442
diff
changeset
|
135 una copia del repositorio, es mejor usar el comando integrado que |
9f460a706292
translated a few sections from tour-basic.tex
jerojasro@localhost
parents:
442
diff
changeset
|
136 Mercurial ofrece. Este comando se llama \hgcmd{clone}\ndt{Del término |
9f460a706292
translated a few sections from tour-basic.tex
jerojasro@localhost
parents:
442
diff
changeset
|
137 ``clonar'' en inglés.}, porque crea una copia idéntica de un |
9f460a706292
translated a few sections from tour-basic.tex
jerojasro@localhost
parents:
442
diff
changeset
|
138 repositorio existente. |
442 | 139 \interaction{tour.clone} |
451
9f460a706292
translated a few sections from tour-basic.tex
jerojasro@localhost
parents:
442
diff
changeset
|
140 Si nuestro clonado tiene éxito, deberíamos tener un directorio local |
461
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
141 llamado \dirname{hello}. Este directorio contendrá algunos ficheros. |
442 | 142 \interaction{tour.ls} |
461
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
143 Estos ficheros tienen el mismo contenido e historial en nuestro |
451
9f460a706292
translated a few sections from tour-basic.tex
jerojasro@localhost
parents:
442
diff
changeset
|
144 repositorio y en el repositorio que clonamos. |
442 | 145 |
451
9f460a706292
translated a few sections from tour-basic.tex
jerojasro@localhost
parents:
442
diff
changeset
|
146 Cada repositorio Mercurial está completo, es autocontenido e |
461
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
147 independiente. Contiene su propia copia de los ficheros y la historia |
451
9f460a706292
translated a few sections from tour-basic.tex
jerojasro@localhost
parents:
442
diff
changeset
|
148 de un proyecto. Un repositorio clonado recuerda la ubicación de la que |
9f460a706292
translated a few sections from tour-basic.tex
jerojasro@localhost
parents:
442
diff
changeset
|
149 fue clonado, pero no se comunica con ese repositorio, ni con ningún |
9f460a706292
translated a few sections from tour-basic.tex
jerojasro@localhost
parents:
442
diff
changeset
|
150 otro, a menos que usted le indique que lo haga. |
9f460a706292
translated a few sections from tour-basic.tex
jerojasro@localhost
parents:
442
diff
changeset
|
151 |
9f460a706292
translated a few sections from tour-basic.tex
jerojasro@localhost
parents:
442
diff
changeset
|
152 Lo que esto significa por ahora es que somos libres de experimentar |
454 | 153 con nuestro repositorio, con la tranquilidad de saber que es una |
154 % TODO figure out what to say instead of sandbox | |
155 ``caja de arena'' privada que no afectará a nadie más. | |
442 | 156 |
454 | 157 \subsection{Qué hay en un repositorio?} |
442 | 158 |
454 | 159 Cuando miramos en detalle dentro de un repositorio, podemos ver que |
160 contiene un directorio llamado \dirname{.hg}. Aquí es donde Mercurial | |
161 mantiene todos los metadatos del repositorio. | |
442 | 162 \interaction{tour.ls-a} |
163 | |
454 | 164 Los contenidos del directorio \dirname{.hg} y sus subdirectorios son |
165 exclusivos de Mercurial. Usted es libre de hacer lo que desee con | |
461
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
166 cualquier otro fichero o directorio en el repositorio. |
442 | 167 |
456
dae36f024e14
some paragraphs translated, added a couple of rules-of-thumb for translation of terms
Javier Rojas <jerojasro@devnull.li>
parents:
454
diff
changeset
|
168 Para introducir algo de terminología, el directorio \dirname{.hg} es |
461
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
169 el repositorio ``real'', y todos los ficheros y directorios que |
456
dae36f024e14
some paragraphs translated, added a couple of rules-of-thumb for translation of terms
Javier Rojas <jerojasro@devnull.li>
parents:
454
diff
changeset
|
170 coexisten con él están en el \emph{directorio de trabajo}. Una forma |
dae36f024e14
some paragraphs translated, added a couple of rules-of-thumb for translation of terms
Javier Rojas <jerojasro@devnull.li>
parents:
454
diff
changeset
|
171 sencilla de recordar esta distinción es que el \emph{repositorio} |
dae36f024e14
some paragraphs translated, added a couple of rules-of-thumb for translation of terms
Javier Rojas <jerojasro@devnull.li>
parents:
454
diff
changeset
|
172 % TODO unificar con Igor, si historia o historial |
dae36f024e14
some paragraphs translated, added a couple of rules-of-thumb for translation of terms
Javier Rojas <jerojasro@devnull.li>
parents:
454
diff
changeset
|
173 contiene el \emph{historial} de su proyecto, mientras que el |
dae36f024e14
some paragraphs translated, added a couple of rules-of-thumb for translation of terms
Javier Rojas <jerojasro@devnull.li>
parents:
454
diff
changeset
|
174 \emph{directorio de trabajo} contiene una \emph{instantánea} de su |
dae36f024e14
some paragraphs translated, added a couple of rules-of-thumb for translation of terms
Javier Rojas <jerojasro@devnull.li>
parents:
454
diff
changeset
|
175 proyecto en un punto particular del historial. |
442 | 176 |
456
dae36f024e14
some paragraphs translated, added a couple of rules-of-thumb for translation of terms
Javier Rojas <jerojasro@devnull.li>
parents:
454
diff
changeset
|
177 \section{Vistazo rápido al historial} |
442 | 178 |
456
dae36f024e14
some paragraphs translated, added a couple of rules-of-thumb for translation of terms
Javier Rojas <jerojasro@devnull.li>
parents:
454
diff
changeset
|
179 Una de las primeras cosas que se desea hacer con un repositorio nuevo, |
dae36f024e14
some paragraphs translated, added a couple of rules-of-thumb for translation of terms
Javier Rojas <jerojasro@devnull.li>
parents:
454
diff
changeset
|
180 poco conocido, es conocer su historial. el comando \hgcmd{log} nos |
dae36f024e14
some paragraphs translated, added a couple of rules-of-thumb for translation of terms
Javier Rojas <jerojasro@devnull.li>
parents:
454
diff
changeset
|
181 permite ver el mismo. |
442 | 182 \interaction{tour.log} |
457
15a6b61335aa
translated a couple of paragraphs, and updated the table of works in progress
Javier Rojas <jerojasro@devnull.li>
parents:
456
diff
changeset
|
183 Por defecto este programa imprime un párrafo breve por cada cambio al |
15a6b61335aa
translated a couple of paragraphs, and updated the table of works in progress
Javier Rojas <jerojasro@devnull.li>
parents:
456
diff
changeset
|
184 proyecto que haya sido grabado. Dentro de la terminología de |
15a6b61335aa
translated a couple of paragraphs, and updated the table of works in progress
Javier Rojas <jerojasro@devnull.li>
parents:
456
diff
changeset
|
185 Mercurial, cada uno de estos eventos es llamado \emph{conjuntos de |
15a6b61335aa
translated a couple of paragraphs, and updated the table of works in progress
Javier Rojas <jerojasro@devnull.li>
parents:
456
diff
changeset
|
186 cambios}, porque pueden contener un registro de cambios a varios |
461
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
187 ficheros. |
442 | 188 |
457
15a6b61335aa
translated a couple of paragraphs, and updated the table of works in progress
Javier Rojas <jerojasro@devnull.li>
parents:
456
diff
changeset
|
189 Los campos de la salida de \hgcmd{log} son los siguientes. |
442 | 190 \begin{itemize} |
457
15a6b61335aa
translated a couple of paragraphs, and updated the table of works in progress
Javier Rojas <jerojasro@devnull.li>
parents:
456
diff
changeset
|
191 \item[\texttt{changeset}]\hspace{-0.5em}\ndt{Conjunto de cambios.} Este campo |
15a6b61335aa
translated a couple of paragraphs, and updated the table of works in progress
Javier Rojas <jerojasro@devnull.li>
parents:
456
diff
changeset
|
192 tiene un número, seguido por un |
15a6b61335aa
translated a couple of paragraphs, and updated the table of works in progress
Javier Rojas <jerojasro@devnull.li>
parents:
456
diff
changeset
|
193 % TODO digo mejor seguido por un dos puntos ? string => |
15a6b61335aa
translated a couple of paragraphs, and updated the table of works in progress
Javier Rojas <jerojasro@devnull.li>
parents:
456
diff
changeset
|
194 % cadena? |
15a6b61335aa
translated a couple of paragraphs, and updated the table of works in progress
Javier Rojas <jerojasro@devnull.li>
parents:
456
diff
changeset
|
195 \texttt{:}, seguido por una cadena hexadecimal. Ambos son |
15a6b61335aa
translated a couple of paragraphs, and updated the table of works in progress
Javier Rojas <jerojasro@devnull.li>
parents:
456
diff
changeset
|
196 \emph{identificadores} para el conjunto de cambios. Hay dos |
15a6b61335aa
translated a couple of paragraphs, and updated the table of works in progress
Javier Rojas <jerojasro@devnull.li>
parents:
456
diff
changeset
|
197 identificadores porque el número es más corto y más fácil de |
15a6b61335aa
translated a couple of paragraphs, and updated the table of works in progress
Javier Rojas <jerojasro@devnull.li>
parents:
456
diff
changeset
|
198 recordar que la cadena hexadecimal. |
15a6b61335aa
translated a couple of paragraphs, and updated the table of works in progress
Javier Rojas <jerojasro@devnull.li>
parents:
456
diff
changeset
|
199 |
15a6b61335aa
translated a couple of paragraphs, and updated the table of works in progress
Javier Rojas <jerojasro@devnull.li>
parents:
456
diff
changeset
|
200 \item[\texttt{user}]\hspace{-0.5em}\ndt{Usuario.} La identidad de la |
15a6b61335aa
translated a couple of paragraphs, and updated the table of works in progress
Javier Rojas <jerojasro@devnull.li>
parents:
456
diff
changeset
|
201 persona que creó el conjunto de cambios. Este es un campo en el |
15a6b61335aa
translated a couple of paragraphs, and updated the table of works in progress
Javier Rojas <jerojasro@devnull.li>
parents:
456
diff
changeset
|
202 que se puede almacenar cualquier valor, pero en la mayoría de los |
15a6b61335aa
translated a couple of paragraphs, and updated the table of works in progress
Javier Rojas <jerojasro@devnull.li>
parents:
456
diff
changeset
|
203 casos contiene el nombre de una persona y su dirección de correo |
15a6b61335aa
translated a couple of paragraphs, and updated the table of works in progress
Javier Rojas <jerojasro@devnull.li>
parents:
456
diff
changeset
|
204 electrónico. |
15a6b61335aa
translated a couple of paragraphs, and updated the table of works in progress
Javier Rojas <jerojasro@devnull.li>
parents:
456
diff
changeset
|
205 |
461
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
206 \item[\texttt{date}]\hspace{-0.5em}\ndt{Fecha.} La fecha y hora en la |
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
207 que el conjunto de cambios fue creado, y la zona horaria en la que |
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
208 fue creado. (La fecha y hora son locales a dicha zona horaria; |
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
209 ambos muestran la fecha y hora para la persona que creó el |
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
210 changeset). |
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
211 |
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
212 \item[\texttt{summary}]\hspace{-0.5em}\ndt{Sumario.} |
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
213 La primera línea del texto que usó la persona que creó el conjunto |
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
214 de cambios para describir el mismo. |
442 | 215 \end{itemize} |
461
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
216 El texto impreso por \hgcmd{log} es sólo un sumario; omite una gran |
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
217 cantidad de detalles. |
442 | 218 |
461
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
219 La figura~\ref{fig:tour-basic:history} es una representación |
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
220 gráfica del historial del repositorio \dirname{hello}, para hacer más |
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
221 fácil ver en qué dirección está ``fluyendo'' el historial. Volveremos |
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
222 a esto varias veces en este capítulo y en los siguientes. |
442 | 223 |
224 \begin{figure}[ht] | |
225 \centering | |
226 \grafix{tour-history} | |
461
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
227 \caption{Historial gráfico de el repositorio \dirname{hello}} |
442 | 228 \label{fig:tour-basic:history} |
229 \end{figure} | |
230 | |
461
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
231 \subsection{Conjuntos de cambios, revisiones, y comunicándose con |
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
232 otras personas} |
442 | 233 |
461
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
234 %TODO sloppy => desordenado ? TODO hablar del inglés? o de español? |
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
235 Ya que el inglés es un lenguaje notablemente desordenado, y el área de |
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
236 ciencias de la computación tiene una notable historia de confusión de |
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
237 % TODO insertar ? al revés. no sé cómo en un teclado de estos. |
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
238 términos (porqué usar sólo un término cuando cuatro pueden servir?), |
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
239 el control de revisiones tiene una variedad de frases y palabras que |
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
240 tienen el mismo significado. Si usted habla acerca del historial de |
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
241 Mercurial con alguien, encontrará que la expresión ``conjunto de |
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
242 cambios'' es abreviada a menudo como ``cambio'' o (por escrito) |
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
243 ``cset''\ndt{Abreviatura para la expresión ``changeset'' en inglés.}, |
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
244 y algunas veces un se hace referencia a un conjunto de cambios como |
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
245 una ``revisión'' o ``rev''\ndt{De nuevo, como abreviación para el |
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
246 término en inglés para ``revisión'' (``revision'').}. |
442 | 247 |
461
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
248 Si bien no es relevante qué \emph{palabra} use usted para referirse al |
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
249 concepto ``conjunto de cambios'', el \emph{identificador} que usted |
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
250 use para referise a ``un \emph{conjunto de cambios} particular'' es |
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
251 muy importante. Recuerde que el campo \texttt{changeset} en la salida |
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
252 de \hgcmd{log} identifica un conjunto de cambios usando tanto un |
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
253 número como una cadena hexadecimal. |
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
254 |
442 | 255 \begin{itemize} |
461
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
256 \item El número de revisión \emph{sólo es válido dentro del |
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
257 repositorio}. |
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
258 \item Por otro lado, la cadena hexadecimal es el |
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
259 \emph{identificador permanente e inmutable} que siempre |
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
260 identificará ése conjunto de cambios en \emph{todas} las |
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
261 copias del repositorio. |
442 | 262 \end{itemize} |
461
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
263 La diferencia es importante. Si usted le envía a alguien un correo |
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
264 electrónico hablando acerca de la ``revisión~33'', hay una |
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
265 probabilidad alta de que la revisión~33 de esa persona \emph{no sea la |
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
266 misma suya}. Esto sucede porque el número de revisión depende de el |
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
267 orden en que llegan los cambios al repositorio, y no hay ninguna |
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
268 garantía de que los mismos cambios llegarán en el mismo orden en |
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
269 diferentes repositorios. Tres cambios dados $a,b,c$ pueden aparecer en |
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
270 un repositorio como $0,1,2$, mientras que en otro aparecen como |
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
271 $1,0,2$. |
442 | 272 |
461
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
273 Mercurial usa los números de revisión simplemente como una abreviación |
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
274 conveniente. Si usted necesita hablar con alguien acerca de un |
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
275 conjunto de cambios, o llevar el registro de un conjunto de cambios |
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
276 por alguna otra razón (por ejemplo, en un reporte de fallo), use el |
90b67ac5862b
translated up to section 1.4.1
Javier Rojas <jerojasro@devnull.li>
parents:
457
diff
changeset
|
277 identificador hexadecimal. |
442 | 278 |
462 | 279 \subsection{Ver revisiones específicas} |
280 | |
281 Para reducir la salida de \hgcmd{log} a una sola revisión, use la | |
282 opción \hgopt{log}{-r} (o \hgopt{log}{--rev}). Puede usar un número | |
283 de revisión o un identificador hexadecimal de conjunto de cambios, y | |
284 puede pasar tantas revisiones como desee. | |
442 | 285 |
462 | 286 \interaction{tour.log-r} |
442 | 287 |
462 | 288 Si desea ver el historial de varias revisiones sin tener que mencionar |
289 cada una de ellas, puede usar la \emph{notación de rango}; esto le | |
290 permite expresar el concepto ``quiero ver todas las revisiones entre | |
291 $a$ y $b$, inclusive''. | |
442 | 292 \interaction{tour.log.range} |
462 | 293 Mercurial también respeta el orden en que usted especifica las |
294 revisiones, así que \hgcmdargs{log}{-r 2:4} muestra $2,3,4$ mientras | |
295 que \hgcmdargs{log}{-r 4:2} muestra $4,3,2$. | |
442 | 296 |
462 | 297 \subsection{Información más detallada} |
298 Aunque la información presentada por \hgcmd{log} es útil si usted sabe | |
299 de antemano qué está buscando, puede que necesite ver una descripción | |
300 completa de el cambio, o una lista de los ficheros que cambiaron, si | |
301 está tratando de averiguar si un conjunto de cambios dado es el que | |
302 usted está buscando. La opción \hggopt{-v} (or \hggopt{--verbose}) del | |
303 comando \hgcmd{log} le da este nivel extra de detalle. | |
442 | 304 \interaction{tour.log-v} |
305 | |
462 | 306 Si desea ver tanto la descripción como el contenido de un cambio, |
307 añada la opción \hgopt{log}{-p} (o \hgopt{log}{--patch}). Esto muestra | |
308 % TODO qué hacemos con diff unificado? convervarlo, por ser la | |
309 % acepción usual? | |
310 el contenido de un cambio como un \emph{diff unificado} (si usted | |
311 nunca ha visto un diff unificado antes, vea la | |
312 sección~\ref{sec:mq:patch} para un vistazo global). | |
442 | 313 \interaction{tour.log-vp} |
314 | |
463
932c10e8c225
now, this has section 1.5 finished. Last commit had 1.4. Typo in commit message
Javier Rojas <jerojasro@devnull.li>
parents:
462
diff
changeset
|
315 \section{Todo acerca de las opciones para comandos} |
442 | 316 |
463
932c10e8c225
now, this has section 1.5 finished. Last commit had 1.4. Typo in commit message
Javier Rojas <jerojasro@devnull.li>
parents:
462
diff
changeset
|
317 Tomemos un breve descanso de la tarea de explorar los comandos de |
464
5c676825e7a1
corrected typo and grammar error
Javier Rojas <jerojasro@devnull.li>
parents:
463
diff
changeset
|
318 Mercurial para hablar de un patrón en la manera en que trabajan; será |
463
932c10e8c225
now, this has section 1.5 finished. Last commit had 1.4. Typo in commit message
Javier Rojas <jerojasro@devnull.li>
parents:
462
diff
changeset
|
319 útil tener esto en mente a medida que avanza nuestra gira. |
442 | 320 |
464
5c676825e7a1
corrected typo and grammar error
Javier Rojas <jerojasro@devnull.li>
parents:
463
diff
changeset
|
321 Mercurial tiene un enfoque directo y consistente en el manejo de las |
463
932c10e8c225
now, this has section 1.5 finished. Last commit had 1.4. Typo in commit message
Javier Rojas <jerojasro@devnull.li>
parents:
462
diff
changeset
|
322 opciones que usted le puede pasar a los comandos. Se siguen las |
932c10e8c225
now, this has section 1.5 finished. Last commit had 1.4. Typo in commit message
Javier Rojas <jerojasro@devnull.li>
parents:
462
diff
changeset
|
323 convenciones para opciones que son comunes en sistemas Linux y Unix |
932c10e8c225
now, this has section 1.5 finished. Last commit had 1.4. Typo in commit message
Javier Rojas <jerojasro@devnull.li>
parents:
462
diff
changeset
|
324 modernos. |
442 | 325 \begin{itemize} |
463
932c10e8c225
now, this has section 1.5 finished. Last commit had 1.4. Typo in commit message
Javier Rojas <jerojasro@devnull.li>
parents:
462
diff
changeset
|
326 \item Cada opción tiene un nombre largo. Por ejemplo, el comando |
932c10e8c225
now, this has section 1.5 finished. Last commit had 1.4. Typo in commit message
Javier Rojas <jerojasro@devnull.li>
parents:
462
diff
changeset
|
327 \hgcmd{log} acepta la opción \hgopt{log}{--rev}, como ya hemos |
932c10e8c225
now, this has section 1.5 finished. Last commit had 1.4. Typo in commit message
Javier Rojas <jerojasro@devnull.li>
parents:
462
diff
changeset
|
328 visto. |
932c10e8c225
now, this has section 1.5 finished. Last commit had 1.4. Typo in commit message
Javier Rojas <jerojasro@devnull.li>
parents:
462
diff
changeset
|
329 \item Muchas opciones tienen también un nombre corto. En vez de |
932c10e8c225
now, this has section 1.5 finished. Last commit had 1.4. Typo in commit message
Javier Rojas <jerojasro@devnull.li>
parents:
462
diff
changeset
|
330 \hgopt{log}{--rev}, podemos usar \hgopt{log}{-r}. (El motivo para |
932c10e8c225
now, this has section 1.5 finished. Last commit had 1.4. Typo in commit message
Javier Rojas <jerojasro@devnull.li>
parents:
462
diff
changeset
|
331 que algunas opciones no tengan nombres cortos es que dichas |
932c10e8c225
now, this has section 1.5 finished. Last commit had 1.4. Typo in commit message
Javier Rojas <jerojasro@devnull.li>
parents:
462
diff
changeset
|
332 opciones se usan rara vez.) |
932c10e8c225
now, this has section 1.5 finished. Last commit had 1.4. Typo in commit message
Javier Rojas <jerojasro@devnull.li>
parents:
462
diff
changeset
|
333 \item Las opciones largas empiezan con dos guiones (p.ej.~\hgopt{log}{--rev}), |
932c10e8c225
now, this has section 1.5 finished. Last commit had 1.4. Typo in commit message
Javier Rojas <jerojasro@devnull.li>
parents:
462
diff
changeset
|
334 mientras que las opciones cortas empiezan con uno (e.g.~\hgopt{log}{-r}). |
932c10e8c225
now, this has section 1.5 finished. Last commit had 1.4. Typo in commit message
Javier Rojas <jerojasro@devnull.li>
parents:
462
diff
changeset
|
335 \item El nombre y uso de las opciones es consistente en todos los |
932c10e8c225
now, this has section 1.5 finished. Last commit had 1.4. Typo in commit message
Javier Rojas <jerojasro@devnull.li>
parents:
462
diff
changeset
|
336 comandos. Por ejemplo, cada comando que le permite pasar un ID de |
932c10e8c225
now, this has section 1.5 finished. Last commit had 1.4. Typo in commit message
Javier Rojas <jerojasro@devnull.li>
parents:
462
diff
changeset
|
337 conjunto de cambios o un número de revisión acepta tanto la opción |
932c10e8c225
now, this has section 1.5 finished. Last commit had 1.4. Typo in commit message
Javier Rojas <jerojasro@devnull.li>
parents:
462
diff
changeset
|
338 \hgopt{log}{-r} como la \hgopt{log}{--rev}. |
442 | 339 \end{itemize} |
463
932c10e8c225
now, this has section 1.5 finished. Last commit had 1.4. Typo in commit message
Javier Rojas <jerojasro@devnull.li>
parents:
462
diff
changeset
|
340 En los ejemplos en este libro, uso las opciones cortas en vez de las |
932c10e8c225
now, this has section 1.5 finished. Last commit had 1.4. Typo in commit message
Javier Rojas <jerojasro@devnull.li>
parents:
462
diff
changeset
|
341 largas. Esto sólo muestra mis preferencias, así que no le dé |
932c10e8c225
now, this has section 1.5 finished. Last commit had 1.4. Typo in commit message
Javier Rojas <jerojasro@devnull.li>
parents:
462
diff
changeset
|
342 significado especial a eso. |
442 | 343 |
463
932c10e8c225
now, this has section 1.5 finished. Last commit had 1.4. Typo in commit message
Javier Rojas <jerojasro@devnull.li>
parents:
462
diff
changeset
|
344 Muchos de los comandos que generan salida de algún tipo mostrarán más |
932c10e8c225
now, this has section 1.5 finished. Last commit had 1.4. Typo in commit message
Javier Rojas <jerojasro@devnull.li>
parents:
462
diff
changeset
|
345 salida cuando se les pase la opción \hggopt{-v} (o |
932c10e8c225
now, this has section 1.5 finished. Last commit had 1.4. Typo in commit message
Javier Rojas <jerojasro@devnull.li>
parents:
462
diff
changeset
|
346 \hggopt{--verbose}\ndt{Prolijo.}), y menos cuando se les pase la opción \hggopt{-q} |
932c10e8c225
now, this has section 1.5 finished. Last commit had 1.4. Typo in commit message
Javier Rojas <jerojasro@devnull.li>
parents:
462
diff
changeset
|
347 (o \hggopt{--quiet}\ndt{Silencioso.}). |
442 | 348 |
465
6c5ec67f47f9
translated a couple of paragraphs of section 1.6
Javier Rojas <jerojasro@devnull.li>
parents:
464
diff
changeset
|
349 \section{Hacer y repasar cambios} |
442 | 350 |
465
6c5ec67f47f9
translated a couple of paragraphs of section 1.6
Javier Rojas <jerojasro@devnull.li>
parents:
464
diff
changeset
|
351 Ahora que tenemos una comprensión adecuada sobre cómo revisar el |
6c5ec67f47f9
translated a couple of paragraphs of section 1.6
Javier Rojas <jerojasro@devnull.li>
parents:
464
diff
changeset
|
352 historial en Mercurial, hagamos algunos cambios y veamos cómo |
6c5ec67f47f9
translated a couple of paragraphs of section 1.6
Javier Rojas <jerojasro@devnull.li>
parents:
464
diff
changeset
|
353 examinarlos. |
442 | 354 |
465
6c5ec67f47f9
translated a couple of paragraphs of section 1.6
Javier Rojas <jerojasro@devnull.li>
parents:
464
diff
changeset
|
355 Lo primero que haremos será aislar nuestro experimento en un |
6c5ec67f47f9
translated a couple of paragraphs of section 1.6
Javier Rojas <jerojasro@devnull.li>
parents:
464
diff
changeset
|
356 repositorio propio. Usaremos el comando \hgcmd{clone}, pero no hace |
6c5ec67f47f9
translated a couple of paragraphs of section 1.6
Javier Rojas <jerojasro@devnull.li>
parents:
464
diff
changeset
|
357 falta clonar una copia de el repositorio remoto. Como ya contamos con |
6c5ec67f47f9
translated a couple of paragraphs of section 1.6
Javier Rojas <jerojasro@devnull.li>
parents:
464
diff
changeset
|
358 una copia local del mismo, podemos clonar esa. Esto es mucho más |
6c5ec67f47f9
translated a couple of paragraphs of section 1.6
Javier Rojas <jerojasro@devnull.li>
parents:
464
diff
changeset
|
359 rápido que clonar a través de la red, y en la mayoría de los casos |
6c5ec67f47f9
translated a couple of paragraphs of section 1.6
Javier Rojas <jerojasro@devnull.li>
parents:
464
diff
changeset
|
360 clonar un repositorio local usa menos espacio en disco también. |
442 | 361 \interaction{tour.reclone} |
467
1d31f4902e62
translated up to section 1.6 (included)
Javier Rojas <jerojasro@devnull.li>
parents:
465
diff
changeset
|
362 A manera de recomendación, es considerado buena práctica mantener una |
1d31f4902e62
translated up to section 1.6 (included)
Javier Rojas <jerojasro@devnull.li>
parents:
465
diff
changeset
|
363 copia ``prístina'' de un repositorio remoto a mano, del cual usted |
1d31f4902e62
translated up to section 1.6 (included)
Javier Rojas <jerojasro@devnull.li>
parents:
465
diff
changeset
|
364 puede hacer clones temporales para crear cajas de arena para cada |
1d31f4902e62
translated up to section 1.6 (included)
Javier Rojas <jerojasro@devnull.li>
parents:
465
diff
changeset
|
365 tarea en la que desee trabajar. Esto le permite trabajar en múltiples |
1d31f4902e62
translated up to section 1.6 (included)
Javier Rojas <jerojasro@devnull.li>
parents:
465
diff
changeset
|
366 tareas en paralelo, teniendo cada una de ellas aislada de las otras |
1d31f4902e62
translated up to section 1.6 (included)
Javier Rojas <jerojasro@devnull.li>
parents:
465
diff
changeset
|
367 hasta que estén completas y usted esté listo para integrar los cambios |
1d31f4902e62
translated up to section 1.6 (included)
Javier Rojas <jerojasro@devnull.li>
parents:
465
diff
changeset
|
368 de vuelta. Como los clones locales son tan baratos, clonar y destruir |
1d31f4902e62
translated up to section 1.6 (included)
Javier Rojas <jerojasro@devnull.li>
parents:
465
diff
changeset
|
369 repositorios no consume demasiados recursos, lo que facilita hacerlo |
1d31f4902e62
translated up to section 1.6 (included)
Javier Rojas <jerojasro@devnull.li>
parents:
465
diff
changeset
|
370 en cualquier momento. |
442 | 371 |
467
1d31f4902e62
translated up to section 1.6 (included)
Javier Rojas <jerojasro@devnull.li>
parents:
465
diff
changeset
|
372 En nuestro repositorio \dirname{my-hello}, hay un archivo |
1d31f4902e62
translated up to section 1.6 (included)
Javier Rojas <jerojasro@devnull.li>
parents:
465
diff
changeset
|
373 \filename{hello.c} que contiene el clásico programa ``hello, |
1d31f4902e62
translated up to section 1.6 (included)
Javier Rojas <jerojasro@devnull.li>
parents:
465
diff
changeset
|
374 world''\ndt{Hola, mundo.}. Usaremos el clásico y venerado comando |
1d31f4902e62
translated up to section 1.6 (included)
Javier Rojas <jerojasro@devnull.li>
parents:
465
diff
changeset
|
375 \command{sed} para editar este archivo y hacer que imprima una segunda |
1d31f4902e62
translated up to section 1.6 (included)
Javier Rojas <jerojasro@devnull.li>
parents:
465
diff
changeset
|
376 línea de salida. (Estoy usando el comando \command{sed} para hacer |
1d31f4902e62
translated up to section 1.6 (included)
Javier Rojas <jerojasro@devnull.li>
parents:
465
diff
changeset
|
377 esto sólo porque es fácil escribir un ejemplo automatizado con él. |
1d31f4902e62
translated up to section 1.6 (included)
Javier Rojas <jerojasro@devnull.li>
parents:
465
diff
changeset
|
378 Dado que usted no tiene esta restricción, probablemente no querrá usar |
1d31f4902e62
translated up to section 1.6 (included)
Javier Rojas <jerojasro@devnull.li>
parents:
465
diff
changeset
|
379 \command{sed}; use su editor de texto preferido para hacer lo mismo). |
442 | 380 \interaction{tour.sed} |
381 | |
467
1d31f4902e62
translated up to section 1.6 (included)
Javier Rojas <jerojasro@devnull.li>
parents:
465
diff
changeset
|
382 El comando \hgcmd{status} de Mercurial nos dice lo que Mercurial sabe |
1d31f4902e62
translated up to section 1.6 (included)
Javier Rojas <jerojasro@devnull.li>
parents:
465
diff
changeset
|
383 acerca de los archivos en el repositorio. |
442 | 384 \interaction{tour.status} |
467
1d31f4902e62
translated up to section 1.6 (included)
Javier Rojas <jerojasro@devnull.li>
parents:
465
diff
changeset
|
385 El comando \hgcmd{status} no imprime nada para algunos archivos, sólo |
1d31f4902e62
translated up to section 1.6 (included)
Javier Rojas <jerojasro@devnull.li>
parents:
465
diff
changeset
|
386 una línea empezando con ``\texttt{M}'' para el fichero |
1d31f4902e62
translated up to section 1.6 (included)
Javier Rojas <jerojasro@devnull.li>
parents:
465
diff
changeset
|
387 \filename{hello.c}. A menos que usted lo indique explícitamente, |
1d31f4902e62
translated up to section 1.6 (included)
Javier Rojas <jerojasro@devnull.li>
parents:
465
diff
changeset
|
388 \hgcmd{status} no imprimirá nada respecto a los archivos que no han |
1d31f4902e62
translated up to section 1.6 (included)
Javier Rojas <jerojasro@devnull.li>
parents:
465
diff
changeset
|
389 sido modificados. |
442 | 390 |
467
1d31f4902e62
translated up to section 1.6 (included)
Javier Rojas <jerojasro@devnull.li>
parents:
465
diff
changeset
|
391 La ``\texttt{M}'' indica que Mercurial se dio cuenta de que nosotros |
1d31f4902e62
translated up to section 1.6 (included)
Javier Rojas <jerojasro@devnull.li>
parents:
465
diff
changeset
|
392 modificamos \filename{hello.c}. No tuvimos que \emph{decirle} a |
1d31f4902e62
translated up to section 1.6 (included)
Javier Rojas <jerojasro@devnull.li>
parents:
465
diff
changeset
|
393 Mercurial que íbamos a modificar ese archivo antes de hacerlo, o que |
1d31f4902e62
translated up to section 1.6 (included)
Javier Rojas <jerojasro@devnull.li>
parents:
465
diff
changeset
|
394 lo modificamos una vez terminamos de hacerlo; él fue capaz de darse |
1d31f4902e62
translated up to section 1.6 (included)
Javier Rojas <jerojasro@devnull.li>
parents:
465
diff
changeset
|
395 cuenta de esto por sí mismo. |
442 | 396 |
467
1d31f4902e62
translated up to section 1.6 (included)
Javier Rojas <jerojasro@devnull.li>
parents:
465
diff
changeset
|
397 Es algo útil saber que hemos modificado el archivo \filename{hello.c}, |
1d31f4902e62
translated up to section 1.6 (included)
Javier Rojas <jerojasro@devnull.li>
parents:
465
diff
changeset
|
398 pero preferiríamos saber exactamente \emph{qué} cambios hicimos. |
1d31f4902e62
translated up to section 1.6 (included)
Javier Rojas <jerojasro@devnull.li>
parents:
465
diff
changeset
|
399 Para averiguar esto, usamos el comando \hgcmd{diff}. |
442 | 400 \interaction{tour.diff} |
401 | |
402 \section{Recording changes in a new changeset} | |
403 | |
404 We can modify files, build and test our changes, and use | |
405 \hgcmd{status} and \hgcmd{diff} to review our changes, until we're | |
406 satisfied with what we've done and arrive at a natural stopping point | |
407 where we want to record our work in a new changeset. | |
408 | |
409 The \hgcmd{commit} command lets us create a new changeset; we'll | |
410 usually refer to this as ``making a commit'' or ``committing''. | |
411 | |
412 \subsection{Setting up a username} | |
413 | |
414 When you try to run \hgcmd{commit} for the first time, it is not | |
415 guaranteed to succeed. Mercurial records your name and address with | |
416 each change that you commit, so that you and others will later be able | |
417 to tell who made each change. Mercurial tries to automatically figure | |
418 out a sensible username to commit the change with. It will attempt | |
419 each of the following methods, in order: | |
420 \begin{enumerate} | |
421 \item If you specify a \hgopt{commit}{-u} option to the \hgcmd{commit} | |
422 command on the command line, followed by a username, this is always | |
423 given the highest precedence. | |
424 \item If you have set the \envar{HGUSER} environment variable, this is | |
425 checked next. | |
426 \item If you create a file in your home directory called | |
427 \sfilename{.hgrc}, with a \rcitem{ui}{username} entry, that will be | |
428 used next. To see what the contents of this file should look like, | |
429 refer to section~\ref{sec:tour-basic:username} below. | |
430 \item If you have set the \envar{EMAIL} environment variable, this | |
431 will be used next. | |
432 \item Mercurial will query your system to find out your local user | |
433 name and host name, and construct a username from these components. | |
434 Since this often results in a username that is not very useful, it | |
435 will print a warning if it has to do this. | |
436 \end{enumerate} | |
437 If all of these mechanisms fail, Mercurial will fail, printing an | |
438 error message. In this case, it will not let you commit until you set | |
439 up a username. | |
440 | |
441 You should think of the \envar{HGUSER} environment variable and the | |
442 \hgopt{commit}{-u} option to the \hgcmd{commit} command as ways to | |
443 \emph{override} Mercurial's default selection of username. For normal | |
444 use, the simplest and most robust way to set a username for yourself | |
445 is by creating a \sfilename{.hgrc} file; see below for details. | |
446 | |
447 \subsubsection{Creating a Mercurial configuration file} | |
448 \label{sec:tour-basic:username} | |
449 | |
450 To set a user name, use your favourite editor to create a file called | |
451 \sfilename{.hgrc} in your home directory. Mercurial will use this | |
452 file to look up your personalised configuration settings. The initial | |
453 contents of your \sfilename{.hgrc} should look like this. | |
454 \begin{codesample2} | |
455 # This is a Mercurial configuration file. | |
456 [ui] | |
457 username = Firstname Lastname <email.address@domain.net> | |
458 \end{codesample2} | |
459 The ``\texttt{[ui]}'' line begins a \emph{section} of the config file, | |
460 so you can read the ``\texttt{username = ...}'' line as meaning ``set | |
461 the value of the \texttt{username} item in the \texttt{ui} section''. | |
462 A section continues until a new section begins, or the end of the | |
463 file. Mercurial ignores empty lines and treats any text from | |
464 ``\texttt{\#}'' to the end of a line as a comment. | |
465 | |
466 \subsubsection{Choosing a user name} | |
467 | |
468 You can use any text you like as the value of the \texttt{username} | |
469 config item, since this information is for reading by other people, | |
470 but for interpreting by Mercurial. The convention that most people | |
471 follow is to use their name and email address, as in the example | |
472 above. | |
473 | |
474 \begin{note} | |
475 Mercurial's built-in web server obfuscates email addresses, to make | |
476 it more difficult for the email harvesting tools that spammers use. | |
477 This reduces the likelihood that you'll start receiving more junk | |
478 email if you publish a Mercurial repository on the web. | |
479 \end{note} | |
480 | |
481 \subsection{Writing a commit message} | |
482 | |
483 When we commit a change, Mercurial drops us into a text editor, to | |
484 enter a message that will describe the modifications we've made in | |
485 this changeset. This is called the \emph{commit message}. It will be | |
486 a record for readers of what we did and why, and it will be printed by | |
487 \hgcmd{log} after we've finished committing. | |
488 \interaction{tour.commit} | |
489 | |
490 The editor that the \hgcmd{commit} command drops us into will contain | |
491 an empty line, followed by a number of lines starting with | |
492 ``\texttt{HG:}''. | |
493 \begin{codesample2} | |
494 \emph{empty line} | |
495 HG: changed hello.c | |
496 \end{codesample2} | |
497 Mercurial ignores the lines that start with ``\texttt{HG:}''; it uses | |
498 them only to tell us which files it's recording changes to. Modifying | |
499 or deleting these lines has no effect. | |
500 | |
501 \subsection{Writing a good commit message} | |
502 | |
503 Since \hgcmd{log} only prints the first line of a commit message by | |
504 default, it's best to write a commit message whose first line stands | |
505 alone. Here's a real example of a commit message that \emph{doesn't} | |
506 follow this guideline, and hence has a summary that is not readable. | |
507 \begin{codesample2} | |
508 changeset: 73:584af0e231be | |
509 user: Censored Person <censored.person@example.org> | |
510 date: Tue Sep 26 21:37:07 2006 -0700 | |
511 summary: include buildmeister/commondefs. Add an exports and install | |
512 \end{codesample2} | |
513 | |
514 As far as the remainder of the contents of the commit message are | |
515 concerned, there are no hard-and-fast rules. Mercurial itself doesn't | |
516 interpret or care about the contents of the commit message, though | |
517 your project may have policies that dictate a certain kind of | |
518 formatting. | |
519 | |
520 My personal preference is for short, but informative, commit messages | |
521 that tell me something that I can't figure out with a quick glance at | |
522 the output of \hgcmdargs{log}{--patch}. | |
523 | |
524 \subsection{Aborting a commit} | |
525 | |
526 If you decide that you don't want to commit while in the middle of | |
527 editing a commit message, simply exit from your editor without saving | |
528 the file that it's editing. This will cause nothing to happen to | |
529 either the repository or the working directory. | |
530 | |
531 If we run the \hgcmd{commit} command without any arguments, it records | |
532 all of the changes we've made, as reported by \hgcmd{status} and | |
533 \hgcmd{diff}. | |
534 | |
535 \subsection{Admiring our new handiwork} | |
536 | |
537 Once we've finished the commit, we can use the \hgcmd{tip} command to | |
538 display the changeset we just created. This command produces output | |
539 that is identical to \hgcmd{log}, but it only displays the newest | |
540 revision in the repository. | |
541 \interaction{tour.tip} | |
542 We refer to the newest revision in the repository as the tip revision, | |
543 or simply the tip. | |
544 | |
545 \section{Sharing changes} | |
546 | |
547 We mentioned earlier that repositories in Mercurial are | |
548 self-contained. This means that the changeset we just created exists | |
549 only in our \dirname{my-hello} repository. Let's look at a few ways | |
550 that we can propagate this change into other repositories. | |
551 | |
552 \subsection{Pulling changes from another repository} | |
553 \label{sec:tour:pull} | |
554 | |
555 To get started, let's clone our original \dirname{hello} repository, | |
556 which does not contain the change we just committed. We'll call our | |
557 temporary repository \dirname{hello-pull}. | |
558 \interaction{tour.clone-pull} | |
559 | |
560 We'll use the \hgcmd{pull} command to bring changes from | |
561 \dirname{my-hello} into \dirname{hello-pull}. However, blindly | |
562 pulling unknown changes into a repository is a somewhat scary | |
563 prospect. Mercurial provides the \hgcmd{incoming} command to tell us | |
564 what changes the \hgcmd{pull} command \emph{would} pull into the | |
565 repository, without actually pulling the changes in. | |
566 \interaction{tour.incoming} | |
567 (Of course, someone could cause more changesets to appear in the | |
568 repository that we ran \hgcmd{incoming} in, before we get a chance to | |
569 \hgcmd{pull} the changes, so that we could end up pulling changes that we | |
570 didn't expect.) | |
571 | |
572 Bringing changes into a repository is a simple matter of running the | |
573 \hgcmd{pull} command, and telling it which repository to pull from. | |
574 \interaction{tour.pull} | |
575 As you can see from the before-and-after output of \hgcmd{tip}, we | |
576 have successfully pulled changes into our repository. There remains | |
577 one step before we can see these changes in the working directory. | |
578 | |
579 \subsection{Updating the working directory} | |
580 | |
581 We have so far glossed over the relationship between a repository and | |
582 its working directory. The \hgcmd{pull} command that we ran in | |
583 section~\ref{sec:tour:pull} brought changes into the repository, but | |
584 if we check, there's no sign of those changes in the working | |
585 directory. This is because \hgcmd{pull} does not (by default) touch | |
586 the working directory. Instead, we use the \hgcmd{update} command to | |
587 do this. | |
588 \interaction{tour.update} | |
589 | |
590 It might seem a bit strange that \hgcmd{pull} doesn't update the | |
591 working directory automatically. There's actually a good reason for | |
592 this: you can use \hgcmd{update} to update the working directory to | |
593 the state it was in at \emph{any revision} in the history of the | |
594 repository. If you had the working directory updated to an old | |
595 revision---to hunt down the origin of a bug, say---and ran a | |
596 \hgcmd{pull} which automatically updated the working directory to a | |
597 new revision, you might not be terribly happy. | |
598 | |
599 However, since pull-then-update is such a common thing to do, | |
600 Mercurial lets you combine the two by passing the \hgopt{pull}{-u} | |
601 option to \hgcmd{pull}. | |
602 \begin{codesample2} | |
603 hg pull -u | |
604 \end{codesample2} | |
605 If you look back at the output of \hgcmd{pull} in | |
606 section~\ref{sec:tour:pull} when we ran it without \hgopt{pull}{-u}, | |
607 you can see that it printed a helpful reminder that we'd have to take | |
608 an explicit step to update the working directory: | |
609 \begin{codesample2} | |
610 (run 'hg update' to get a working copy) | |
611 \end{codesample2} | |
612 | |
613 To find out what revision the working directory is at, use the | |
614 \hgcmd{parents} command. | |
615 \interaction{tour.parents} | |
616 If you look back at figure~\ref{fig:tour-basic:history}, you'll see | |
617 arrows connecting each changeset. The node that the arrow leads | |
618 \emph{from} in each case is a parent, and the node that the arrow | |
619 leads \emph{to} is its child. The working directory has a parent in | |
620 just the same way; this is the changeset that the working directory | |
621 currently contains. | |
622 | |
623 To update the working directory to a particular revision, give a | |
624 revision number or changeset~ID to the \hgcmd{update} command. | |
625 \interaction{tour.older} | |
626 If you omit an explicit revision, \hgcmd{update} will update to the | |
627 tip revision, as shown by the second call to \hgcmd{update} in the | |
628 example above. | |
629 | |
630 \subsection{Pushing changes to another repository} | |
631 | |
632 Mercurial lets us push changes to another repository, from the | |
633 repository we're currently visiting. As with the example of | |
634 \hgcmd{pull} above, we'll create a temporary repository to push our | |
635 changes into. | |
636 \interaction{tour.clone-push} | |
637 The \hgcmd{outgoing} command tells us what changes would be pushed | |
638 into another repository. | |
639 \interaction{tour.outgoing} | |
640 And the \hgcmd{push} command does the actual push. | |
641 \interaction{tour.push} | |
642 As with \hgcmd{pull}, the \hgcmd{push} command does not update the | |
643 working directory in the repository that it's pushing changes into. | |
644 (Unlike \hgcmd{pull}, \hgcmd{push} does not provide a \texttt{-u} | |
645 option that updates the other repository's working directory.) | |
646 | |
647 What happens if we try to pull or push changes and the receiving | |
648 repository already has those changes? Nothing too exciting. | |
649 \interaction{tour.push.nothing} | |
650 | |
651 \subsection{Sharing changes over a network} | |
652 | |
653 The commands we have covered in the previous few sections are not | |
654 limited to working with local repositories. Each works in exactly the | |
655 same fashion over a network connection; simply pass in a URL instead | |
656 of a local path. | |
657 \interaction{tour.outgoing.net} | |
658 In this example, we can see what changes we could push to the remote | |
659 repository, but the repository is understandably not set up to let | |
660 anonymous users push to it. | |
661 \interaction{tour.push.net} | |
662 | |
663 %%% Local Variables: | |
664 %%% mode: latex | |
665 %%% TeX-master: "00book" | |
666 %%% End: |