hgbook

view es/tour-basic.tex @ 355:5e325122bea5

translated 2 paragraphs
author jerojasro@localhost
date Tue Oct 21 21:53:39 2008 -0500 (2008-10-21)
parents 9f460a706292
children dae36f024e14
line source
1 \chapter{Una gira de Mercurial: lo básico}
2 \label{chap:tour-basic}
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.
10 \subsection{Linux}
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.
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}.
25 \begin{itemize}
26 \item[Debian]
27 \begin{codesample4}
28 apt-get install mercurial
29 \end{codesample4}
31 \item[Fedora Core]
32 \begin{codesample4}
33 yum install mercurial
34 \end{codesample4}
36 \item[Gentoo]
37 \begin{codesample4}
38 emerge mercurial
39 \end{codesample4}
41 \item[OpenSUSE]
42 \begin{codesample4}
43 yum install mercurial
44 \end{codesample4}
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}
58 \subsection{Solaris}
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.
65 \subsection{Mac OS X}
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.
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}.
79 \subsection{Windows}
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''.
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}
93 \section{Arrancando}
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.
100 \interaction{tour.version}
102 % TODO builtin-> integrado?
103 \subsection{Ayuda integrada}
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.
118 \section{Trabajar con un repositorio}
120 En Mercurial, todo sucede dentro de un \emph{repositorio}. El
121 repositorio para un proyecto contiene todos los archivos que
122 ``pertenecen a'' ése proyecto, junto con un registro histórico de los
123 archivos de ese proyecto.
125 No hay nada particularmente mágico acerca de un repositorio; es
126 simplemente un árbol de directorios en su sistema de archivos que
127 Mercurial trata como especial. Usted puede renombrar o borrar un
128 repositorio en el momento que lo desee, usando bien sea la línea de
129 comandos o su explorador de ficheros.
131 \subsection{Hacer una copia local de un repositorio}
133 \emph{Copiar} un repositorio es sólo ligeramente especial. Aunque
134 usted podría usar un programa normal de copia de archivos para hacer
135 una copia del repositorio, es mejor usar el comando integrado que
136 Mercurial ofrece. Este comando se llama \hgcmd{clone}\ndt{Del término
137 ``clonar'' en inglés.}, porque crea una copia idéntica de un
138 repositorio existente.
139 \interaction{tour.clone}
140 Si nuestro clonado tiene éxito, deberíamos tener un directorio local
141 llamado \dirname{hello}. Este directorio contendrá algunos archivos.
142 \interaction{tour.ls}
143 Estos archivos tienen el mismo contenido e historial en nuestro
144 repositorio y en el repositorio que clonamos.
146 Cada repositorio Mercurial está completo, es autocontenido e
147 independiente. Contiene su propia copia de los archivos y la historia
148 de un proyecto. Un repositorio clonado recuerda la ubicación de la que
149 fue clonado, pero no se comunica con ese repositorio, ni con ningún
150 otro, a menos que usted le indique que lo haga.
152 Lo que esto significa por ahora es que somos libres de experimentar
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.
157 \subsection{Qué hay en un repositorio?}
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.
162 \interaction{tour.ls-a}
164 Los contenidos del directorio \dirname{.hg} y sus subdirectorios son
165 exclusivos de Mercurial. Usted es libre de hacer lo que desee con
166 cualquier otro archivo o directorio en el repositorio.
168 To introduce a little terminology, the \dirname{.hg} directory is the
169 ``real'' repository, and all of the files and directories that coexist
170 with it are said to live in the \emph{working directory}. An easy way
171 to remember the distinction is that the \emph{repository} contains the
172 \emph{history} of your project, while the \emph{working directory}
173 contains a \emph{snapshot} of your project at a particular point in
174 history.
176 \section{A tour through history}
178 One of the first things we might want to do with a new, unfamiliar
179 repository is understand its history. The \hgcmd{log} command gives
180 us a view of history.
181 \interaction{tour.log}
182 By default, this command prints a brief paragraph of output for each
183 change to the project that was recorded. In Mercurial terminology, we
184 call each of these recorded events a \emph{changeset}, because it can
185 contain a record of changes to several files.
187 The fields in a record of output from \hgcmd{log} are as follows.
188 \begin{itemize}
189 \item[\texttt{changeset}] This field has the format of a number,
190 followed by a colon, followed by a hexadecimal string. These are
191 \emph{identifiers} for the changeset. There are two identifiers
192 because the number is shorter and easier to type than the hex
193 string.
194 \item[\texttt{user}] The identity of the person who created the
195 changeset. This is a free-form field, but it most often contains a
196 person's name and email address.
197 \item[\texttt{date}] The date and time on which the changeset was
198 created, and the timezone in which it was created. (The date and
199 time are local to that timezone; they display what time and date it
200 was for the person who created the changeset.)
201 \item[\texttt{summary}] The first line of the text message that the
202 creator of the changeset entered to describe the changeset.
203 \end{itemize}
204 The default output printed by \hgcmd{log} is purely a summary; it is
205 missing a lot of detail.
207 Figure~\ref{fig:tour-basic:history} provides a graphical representation of
208 the history of the \dirname{hello} repository, to make it a little
209 easier to see which direction history is ``flowing'' in. We'll be
210 returning to this figure several times in this chapter and the chapter
211 that follows.
213 \begin{figure}[ht]
214 \centering
215 \grafix{tour-history}
216 \caption{Graphical history of the \dirname{hello} repository}
217 \label{fig:tour-basic:history}
218 \end{figure}
220 \subsection{Changesets, revisions, and talking to other
221 people}
223 As English is a notoriously sloppy language, and computer science has
224 a hallowed history of terminological confusion (why use one term when
225 four will do?), revision control has a variety of words and phrases
226 that mean the same thing. If you are talking about Mercurial history
227 with other people, you will find that the word ``changeset'' is often
228 compressed to ``change'' or (when written) ``cset'', and sometimes a
229 changeset is referred to as a ``revision'' or a ``rev''.
231 While it doesn't matter what \emph{word} you use to refer to the
232 concept of ``a~changeset'', the \emph{identifier} that you use to
233 refer to ``a~\emph{specific} changeset'' is of great importance.
234 Recall that the \texttt{changeset} field in the output from
235 \hgcmd{log} identifies a changeset using both a number and a
236 hexadecimal string.
237 \begin{itemize}
238 \item The revision number is \emph{only valid in that repository},
239 \item while the hex string is the \emph{permanent, unchanging
240 identifier} that will always identify that exact changeset in
241 \emph{every} copy of the repository.
242 \end{itemize}
243 This distinction is important. If you send someone an email talking
244 about ``revision~33'', there's a high likelihood that their
245 revision~33 will \emph{not be the same} as yours. The reason for this
246 is that a revision number depends on the order in which changes
247 arrived in a repository, and there is no guarantee that the same
248 changes will happen in the same order in different repositories.
249 Three changes $a,b,c$ can easily appear in one repository as $0,1,2$,
250 while in another as $1,0,2$.
252 Mercurial uses revision numbers purely as a convenient shorthand. If
253 you need to discuss a changeset with someone, or make a record of a
254 changeset for some other reason (for example, in a bug report), use
255 the hexadecimal identifier.
257 \subsection{Viewing specific revisions}
259 To narrow the output of \hgcmd{log} down to a single revision, use the
260 \hgopt{log}{-r} (or \hgopt{log}{--rev}) option. You can use either a
261 revision number or a long-form changeset identifier, and you can
262 provide as many revisions as you want. \interaction{tour.log-r}
264 If you want to see the history of several revisions without having to
265 list each one, you can use \emph{range notation}; this lets you
266 express the idea ``I want all revisions between $a$ and $b$,
267 inclusive''.
268 \interaction{tour.log.range}
269 Mercurial also honours the order in which you specify revisions, so
270 \hgcmdargs{log}{-r 2:4} prints $2,3,4$ while \hgcmdargs{log}{-r 4:2}
271 prints $4,3,2$.
273 \subsection{More detailed information}
275 While the summary information printed by \hgcmd{log} is useful if you
276 already know what you're looking for, you may need to see a complete
277 description of the change, or a list of the files changed, if you're
278 trying to decide whether a changeset is the one you're looking for.
279 The \hgcmd{log} command's \hggopt{-v} (or \hggopt{--verbose})
280 option gives you this extra detail.
281 \interaction{tour.log-v}
283 If you want to see both the description and content of a change, add
284 the \hgopt{log}{-p} (or \hgopt{log}{--patch}) option. This displays
285 the content of a change as a \emph{unified diff} (if you've never seen
286 a unified diff before, see section~\ref{sec:mq:patch} for an overview).
287 \interaction{tour.log-vp}
289 \section{All about command options}
291 Let's take a brief break from exploring Mercurial commands to discuss
292 a pattern in the way that they work; you may find this useful to keep
293 in mind as we continue our tour.
295 Mercurial has a consistent and straightforward approach to dealing
296 with the options that you can pass to commands. It follows the
297 conventions for options that are common to modern Linux and Unix
298 systems.
299 \begin{itemize}
300 \item Every option has a long name. For example, as we've already
301 seen, the \hgcmd{log} command accepts a \hgopt{log}{--rev} option.
302 \item Most options have short names, too. Instead of
303 \hgopt{log}{--rev}, we can use \hgopt{log}{-r}. (The reason that
304 some options don't have short names is that the options in question
305 are rarely used.)
306 \item Long options start with two dashes (e.g.~\hgopt{log}{--rev}),
307 while short options start with one (e.g.~\hgopt{log}{-r}).
308 \item Option naming and usage is consistent across commands. For
309 example, every command that lets you specify a changeset~ID or
310 revision number accepts both \hgopt{log}{-r} and \hgopt{log}{--rev}
311 arguments.
312 \end{itemize}
313 In the examples throughout this book, I use short options instead of
314 long. This just reflects my own preference, so don't read anything
315 significant into it.
317 Most commands that print output of some kind will print more output
318 when passed a \hggopt{-v} (or \hggopt{--verbose}) option, and less
319 when passed \hggopt{-q} (or \hggopt{--quiet}).
321 \section{Making and reviewing changes}
323 Now that we have a grasp of viewing history in Mercurial, let's take a
324 look at making some changes and examining them.
326 The first thing we'll do is isolate our experiment in a repository of
327 its own. We use the \hgcmd{clone} command, but we don't need to
328 clone a copy of the remote repository. Since we already have a copy
329 of it locally, we can just clone that instead. This is much faster
330 than cloning over the network, and cloning a local repository uses
331 less disk space in most cases, too.
332 \interaction{tour.reclone}
333 As an aside, it's often good practice to keep a ``pristine'' copy of a
334 remote repository around, which you can then make temporary clones of
335 to create sandboxes for each task you want to work on. This lets you
336 work on multiple tasks in parallel, each isolated from the others
337 until it's complete and you're ready to integrate it back. Because
338 local clones are so cheap, there's almost no overhead to cloning and
339 destroying repositories whenever you want.
341 In our \dirname{my-hello} repository, we have a file
342 \filename{hello.c} that contains the classic ``hello, world'' program.
343 Let's use the ancient and venerable \command{sed} command to edit this
344 file so that it prints a second line of output. (I'm only using
345 \command{sed} to do this because it's easy to write a scripted example
346 this way. Since you're not under the same constraint, you probably
347 won't want to use \command{sed}; simply use your preferred text editor to
348 do the same thing.)
349 \interaction{tour.sed}
351 Mercurial's \hgcmd{status} command will tell us what Mercurial knows
352 about the files in the repository.
353 \interaction{tour.status}
354 The \hgcmd{status} command prints no output for some files, but a line
355 starting with ``\texttt{M}'' for \filename{hello.c}. Unless you tell
356 it to, \hgcmd{status} will not print any output for files that have
357 not been modified.
359 The ``\texttt{M}'' indicates that Mercurial has noticed that we
360 modified \filename{hello.c}. We didn't need to \emph{inform}
361 Mercurial that we were going to modify the file before we started, or
362 that we had modified the file after we were done; it was able to
363 figure this out itself.
365 It's a little bit helpful to know that we've modified
366 \filename{hello.c}, but we might prefer to know exactly \emph{what}
367 changes we've made to it. To do this, we use the \hgcmd{diff}
368 command.
369 \interaction{tour.diff}
371 \section{Recording changes in a new changeset}
373 We can modify files, build and test our changes, and use
374 \hgcmd{status} and \hgcmd{diff} to review our changes, until we're
375 satisfied with what we've done and arrive at a natural stopping point
376 where we want to record our work in a new changeset.
378 The \hgcmd{commit} command lets us create a new changeset; we'll
379 usually refer to this as ``making a commit'' or ``committing''.
381 \subsection{Setting up a username}
383 When you try to run \hgcmd{commit} for the first time, it is not
384 guaranteed to succeed. Mercurial records your name and address with
385 each change that you commit, so that you and others will later be able
386 to tell who made each change. Mercurial tries to automatically figure
387 out a sensible username to commit the change with. It will attempt
388 each of the following methods, in order:
389 \begin{enumerate}
390 \item If you specify a \hgopt{commit}{-u} option to the \hgcmd{commit}
391 command on the command line, followed by a username, this is always
392 given the highest precedence.
393 \item If you have set the \envar{HGUSER} environment variable, this is
394 checked next.
395 \item If you create a file in your home directory called
396 \sfilename{.hgrc}, with a \rcitem{ui}{username} entry, that will be
397 used next. To see what the contents of this file should look like,
398 refer to section~\ref{sec:tour-basic:username} below.
399 \item If you have set the \envar{EMAIL} environment variable, this
400 will be used next.
401 \item Mercurial will query your system to find out your local user
402 name and host name, and construct a username from these components.
403 Since this often results in a username that is not very useful, it
404 will print a warning if it has to do this.
405 \end{enumerate}
406 If all of these mechanisms fail, Mercurial will fail, printing an
407 error message. In this case, it will not let you commit until you set
408 up a username.
410 You should think of the \envar{HGUSER} environment variable and the
411 \hgopt{commit}{-u} option to the \hgcmd{commit} command as ways to
412 \emph{override} Mercurial's default selection of username. For normal
413 use, the simplest and most robust way to set a username for yourself
414 is by creating a \sfilename{.hgrc} file; see below for details.
416 \subsubsection{Creating a Mercurial configuration file}
417 \label{sec:tour-basic:username}
419 To set a user name, use your favourite editor to create a file called
420 \sfilename{.hgrc} in your home directory. Mercurial will use this
421 file to look up your personalised configuration settings. The initial
422 contents of your \sfilename{.hgrc} should look like this.
423 \begin{codesample2}
424 # This is a Mercurial configuration file.
425 [ui]
426 username = Firstname Lastname <email.address@domain.net>
427 \end{codesample2}
428 The ``\texttt{[ui]}'' line begins a \emph{section} of the config file,
429 so you can read the ``\texttt{username = ...}'' line as meaning ``set
430 the value of the \texttt{username} item in the \texttt{ui} section''.
431 A section continues until a new section begins, or the end of the
432 file. Mercurial ignores empty lines and treats any text from
433 ``\texttt{\#}'' to the end of a line as a comment.
435 \subsubsection{Choosing a user name}
437 You can use any text you like as the value of the \texttt{username}
438 config item, since this information is for reading by other people,
439 but for interpreting by Mercurial. The convention that most people
440 follow is to use their name and email address, as in the example
441 above.
443 \begin{note}
444 Mercurial's built-in web server obfuscates email addresses, to make
445 it more difficult for the email harvesting tools that spammers use.
446 This reduces the likelihood that you'll start receiving more junk
447 email if you publish a Mercurial repository on the web.
448 \end{note}
450 \subsection{Writing a commit message}
452 When we commit a change, Mercurial drops us into a text editor, to
453 enter a message that will describe the modifications we've made in
454 this changeset. This is called the \emph{commit message}. It will be
455 a record for readers of what we did and why, and it will be printed by
456 \hgcmd{log} after we've finished committing.
457 \interaction{tour.commit}
459 The editor that the \hgcmd{commit} command drops us into will contain
460 an empty line, followed by a number of lines starting with
461 ``\texttt{HG:}''.
462 \begin{codesample2}
463 \emph{empty line}
464 HG: changed hello.c
465 \end{codesample2}
466 Mercurial ignores the lines that start with ``\texttt{HG:}''; it uses
467 them only to tell us which files it's recording changes to. Modifying
468 or deleting these lines has no effect.
470 \subsection{Writing a good commit message}
472 Since \hgcmd{log} only prints the first line of a commit message by
473 default, it's best to write a commit message whose first line stands
474 alone. Here's a real example of a commit message that \emph{doesn't}
475 follow this guideline, and hence has a summary that is not readable.
476 \begin{codesample2}
477 changeset: 73:584af0e231be
478 user: Censored Person <censored.person@example.org>
479 date: Tue Sep 26 21:37:07 2006 -0700
480 summary: include buildmeister/commondefs. Add an exports and install
481 \end{codesample2}
483 As far as the remainder of the contents of the commit message are
484 concerned, there are no hard-and-fast rules. Mercurial itself doesn't
485 interpret or care about the contents of the commit message, though
486 your project may have policies that dictate a certain kind of
487 formatting.
489 My personal preference is for short, but informative, commit messages
490 that tell me something that I can't figure out with a quick glance at
491 the output of \hgcmdargs{log}{--patch}.
493 \subsection{Aborting a commit}
495 If you decide that you don't want to commit while in the middle of
496 editing a commit message, simply exit from your editor without saving
497 the file that it's editing. This will cause nothing to happen to
498 either the repository or the working directory.
500 If we run the \hgcmd{commit} command without any arguments, it records
501 all of the changes we've made, as reported by \hgcmd{status} and
502 \hgcmd{diff}.
504 \subsection{Admiring our new handiwork}
506 Once we've finished the commit, we can use the \hgcmd{tip} command to
507 display the changeset we just created. This command produces output
508 that is identical to \hgcmd{log}, but it only displays the newest
509 revision in the repository.
510 \interaction{tour.tip}
511 We refer to the newest revision in the repository as the tip revision,
512 or simply the tip.
514 \section{Sharing changes}
516 We mentioned earlier that repositories in Mercurial are
517 self-contained. This means that the changeset we just created exists
518 only in our \dirname{my-hello} repository. Let's look at a few ways
519 that we can propagate this change into other repositories.
521 \subsection{Pulling changes from another repository}
522 \label{sec:tour:pull}
524 To get started, let's clone our original \dirname{hello} repository,
525 which does not contain the change we just committed. We'll call our
526 temporary repository \dirname{hello-pull}.
527 \interaction{tour.clone-pull}
529 We'll use the \hgcmd{pull} command to bring changes from
530 \dirname{my-hello} into \dirname{hello-pull}. However, blindly
531 pulling unknown changes into a repository is a somewhat scary
532 prospect. Mercurial provides the \hgcmd{incoming} command to tell us
533 what changes the \hgcmd{pull} command \emph{would} pull into the
534 repository, without actually pulling the changes in.
535 \interaction{tour.incoming}
536 (Of course, someone could cause more changesets to appear in the
537 repository that we ran \hgcmd{incoming} in, before we get a chance to
538 \hgcmd{pull} the changes, so that we could end up pulling changes that we
539 didn't expect.)
541 Bringing changes into a repository is a simple matter of running the
542 \hgcmd{pull} command, and telling it which repository to pull from.
543 \interaction{tour.pull}
544 As you can see from the before-and-after output of \hgcmd{tip}, we
545 have successfully pulled changes into our repository. There remains
546 one step before we can see these changes in the working directory.
548 \subsection{Updating the working directory}
550 We have so far glossed over the relationship between a repository and
551 its working directory. The \hgcmd{pull} command that we ran in
552 section~\ref{sec:tour:pull} brought changes into the repository, but
553 if we check, there's no sign of those changes in the working
554 directory. This is because \hgcmd{pull} does not (by default) touch
555 the working directory. Instead, we use the \hgcmd{update} command to
556 do this.
557 \interaction{tour.update}
559 It might seem a bit strange that \hgcmd{pull} doesn't update the
560 working directory automatically. There's actually a good reason for
561 this: you can use \hgcmd{update} to update the working directory to
562 the state it was in at \emph{any revision} in the history of the
563 repository. If you had the working directory updated to an old
564 revision---to hunt down the origin of a bug, say---and ran a
565 \hgcmd{pull} which automatically updated the working directory to a
566 new revision, you might not be terribly happy.
568 However, since pull-then-update is such a common thing to do,
569 Mercurial lets you combine the two by passing the \hgopt{pull}{-u}
570 option to \hgcmd{pull}.
571 \begin{codesample2}
572 hg pull -u
573 \end{codesample2}
574 If you look back at the output of \hgcmd{pull} in
575 section~\ref{sec:tour:pull} when we ran it without \hgopt{pull}{-u},
576 you can see that it printed a helpful reminder that we'd have to take
577 an explicit step to update the working directory:
578 \begin{codesample2}
579 (run 'hg update' to get a working copy)
580 \end{codesample2}
582 To find out what revision the working directory is at, use the
583 \hgcmd{parents} command.
584 \interaction{tour.parents}
585 If you look back at figure~\ref{fig:tour-basic:history}, you'll see
586 arrows connecting each changeset. The node that the arrow leads
587 \emph{from} in each case is a parent, and the node that the arrow
588 leads \emph{to} is its child. The working directory has a parent in
589 just the same way; this is the changeset that the working directory
590 currently contains.
592 To update the working directory to a particular revision, give a
593 revision number or changeset~ID to the \hgcmd{update} command.
594 \interaction{tour.older}
595 If you omit an explicit revision, \hgcmd{update} will update to the
596 tip revision, as shown by the second call to \hgcmd{update} in the
597 example above.
599 \subsection{Pushing changes to another repository}
601 Mercurial lets us push changes to another repository, from the
602 repository we're currently visiting. As with the example of
603 \hgcmd{pull} above, we'll create a temporary repository to push our
604 changes into.
605 \interaction{tour.clone-push}
606 The \hgcmd{outgoing} command tells us what changes would be pushed
607 into another repository.
608 \interaction{tour.outgoing}
609 And the \hgcmd{push} command does the actual push.
610 \interaction{tour.push}
611 As with \hgcmd{pull}, the \hgcmd{push} command does not update the
612 working directory in the repository that it's pushing changes into.
613 (Unlike \hgcmd{pull}, \hgcmd{push} does not provide a \texttt{-u}
614 option that updates the other repository's working directory.)
616 What happens if we try to pull or push changes and the receiving
617 repository already has those changes? Nothing too exciting.
618 \interaction{tour.push.nothing}
620 \subsection{Sharing changes over a network}
622 The commands we have covered in the previous few sections are not
623 limited to working with local repositories. Each works in exactly the
624 same fashion over a network connection; simply pass in a URL instead
625 of a local path.
626 \interaction{tour.outgoing.net}
627 In this example, we can see what changes we could push to the remote
628 repository, but the repository is understandably not set up to let
629 anonymous users push to it.
630 \interaction{tour.push.net}
632 %%% Local Variables:
633 %%% mode: latex
634 %%% TeX-master: "00book"
635 %%% End: