annotate es/tour-basic.tex @ 472:48584345e451

Finishing daily.tex translation to spanish
author Igor TAmara <igor@tamarapatino.org>
date Sun, 26 Oct 2008 07:47:01 -0500
parents 15a6b61335aa
children 90b67ac5862b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
442
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
1 \chapter{Una gira de Mercurial: lo básico}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
2 \label{chap:tour-basic}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
3
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
4 \section{Instalar Mercurial en su sistema}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
5 \label{sec:tour:install}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
6 Hay paquetes binarios precompilados de Mercurial disponibles para cada
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
7 sistema operativo popular. Esto hace fácil empezar a usar Mercurial
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
8 en su computador inmediatamente.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
9
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
10 \subsection{Linux}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
11
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
12 Dado que cada distribución de Linux tiene sus propias herramientas de
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
13 manejo de paquetes, políticas, y ritmos de desarrollo, es difícil dar
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
14 un conjunto exhaustivo de instrucciones sobre cómo instalar el paquete
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
15 de Mercurial. La versión de Mercurial que usted tenga a disposición
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
16 puede variar dependiendo de qué tan activa sea la persona que mantiene
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
17 el paquete para su distribución.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
18
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
19 Para mantener las cosas simples, me enfocaré en instalar Mercurial
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
20 desde la línea de comandos en las distribuciones de Linux más
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
21 populares. La mayoría de estas distribuciones proveen administradores
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
22 de paquetes gráficos que le permitirán instalar Mercurial con un solo
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
23 clic; el nombre de paquete a buscar es \texttt{mercurial}.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
24
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
25 \begin{itemize}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
26 \item[Debian]
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
27 \begin{codesample4}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
28 apt-get install mercurial
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
29 \end{codesample4}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
30
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
31 \item[Fedora Core]
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
32 \begin{codesample4}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
33 yum install mercurial
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
34 \end{codesample4}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
35
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
36 \item[Gentoo]
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
37 \begin{codesample4}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
38 emerge mercurial
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
39 \end{codesample4}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
40
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
41 \item[OpenSUSE]
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
42 \begin{codesample4}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
43 yum install mercurial
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
44 \end{codesample4}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
45
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
46 \item[Ubuntu] El paquete de Mercurial de Ubuntu está basado en el de
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
47 Debian. Para instalarlo, ejecute el siguiente comando.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
48 \begin{codesample4}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
49 apt-get install mercurial
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
50 \end{codesample4}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
51 El paquete de Mercurial para Ubuntu tiende a atrasarse con respecto
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
52 a la versión de Debian por un margen de tiempo considerable
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
53 (al momento de escribir esto, 7 meses), lo que en algunos casos
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
54 significará que usted puede encontrarse con problemas que ya habrán
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
55 sido resueltos en el paquete de Debian.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
56 \end{itemize}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
57
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
58 \subsection{Solaris}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
59
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
60 SunFreeWare, en \url{http://www.sunfreeware.com}, es una buena fuente
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
61 para un gran número de paquetes compilados para Solaris para las
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
62 arquitecturas Intel y Sparc de 32 y 64 bits, incluyendo versiones
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
63 actuales de Mercurial.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
64
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
65 \subsection{Mac OS X}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
66
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
67 Lee Cantey publica un instalador de Mercurial para Mac OS~X en
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
68 \url{http://mercurial.berkwood.com}. Este paquete funciona en tanto
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
69 en Macs basados en Intel como basados en PowerPC. Antes de que pueda
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
70 usarlo, usted debe instalar una versión compatible de Universal
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
71 MacPython~\cite{web:macpython}. Esto es fácil de hacer; simplemente
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
72 siga las instrucciones de el sitio de Lee.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
73
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
74 También es posible instalar Mercurial usando Fink o MacPorts, dos
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
75 administradores de paquetes gratuitos y populares para Mac OS X. Si
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
76 usted tiene Fink, use \command{sudo apt-get install mercurial-py25}.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
77 Si usa MacPorts, \command{sudo port install mercurial}.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
78
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
79 \subsection{Windows}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
80
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
81 Lee Cantey publica un instalador de Mercurial para Windows en
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
82 \url{http://mercurial.berkwood.com}. Este paquete no tiene
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
83 % TODO traducción de it just works. Agreed?
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
84 dependencias externas; ``simplemente funciona''.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
85
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
86 \begin{note}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
87 La versión de Windows de Mercurial no convierte automáticamente
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
88 los fines de línea entre estilos Windows y Unix. Si usted desea
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
89 compartir trabajo con usuarios de Unix, deberá hacer un trabajo
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
90 adicional de configuración. XXX Terminar esto.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
91 \end{note}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
92
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
93 \section{Arrancando}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
94
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
95 Para empezar, usaremos el comando \hgcmd{version} para revisar si
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
96 Mercurial está instalado adecuadamente. La información de la versión
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
97 que es impresa no es tan importante; lo que nos importa es si imprime
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
98 algo en absoluto.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
99
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
100 \interaction{tour.version}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
101
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
102 % TODO builtin-> integrado?
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
103 \subsection{Ayuda integrada}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
104
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
105 Mercurial provee un sistema de ayuda integrada. Esto es invaluable
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
106 para ésas ocasiones en la que usted está atorado tratando de recordar
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
107 cómo ejecutar un comando. Si está completamente atorado, simplemente
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
108 ejecute \hgcmd{help}; esto imprimirá una breve lista de comandos,
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
109 junto con una descripción de qué hace cada uno. Si usted solicita
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
110 ayuda sobre un comando específico (como abajo), se imprime información
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
111 más detallada.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
112 \interaction{tour.help}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
113 Para un nivel más impresionante de detalle (que usted no va a
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
114 necesitar usualmente) ejecute \hgcmdargs{help}{\hggopt{-v}}. La opción
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
115 \hggopt{-v} es la abreviación para \hggopt{--verbose}, y le indica a
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
116 Mercurial que imprima más información de lo que haría usualmente.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
117
451
9f460a706292 translated a few sections from tour-basic.tex
jerojasro@localhost
parents: 442
diff changeset
118 \section{Trabajar con un repositorio}
442
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
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
9f460a706292 translated a few sections from tour-basic.tex
jerojasro@localhost
parents: 442
diff changeset
121 repositorio para un proyecto contiene todos los archivos que
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
9f460a706292 translated a few sections from tour-basic.tex
jerojasro@localhost
parents: 442
diff changeset
123 archivos de ese proyecto.
442
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
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
9f460a706292 translated a few sections from tour-basic.tex
jerojasro@localhost
parents: 442
diff changeset
126 simplemente un árbol de directorios en su sistema de archivos que
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
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
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
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
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
9f460a706292 translated a few sections from tour-basic.tex
jerojasro@localhost
parents: 442
diff changeset
134 usted podría usar un programa normal de copia de archivos para hacer
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
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
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
9f460a706292 translated a few sections from tour-basic.tex
jerojasro@localhost
parents: 442
diff changeset
141 llamado \dirname{hello}. Este directorio contendrá algunos archivos.
442
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
142 \interaction{tour.ls}
451
9f460a706292 translated a few sections from tour-basic.tex
jerojasro@localhost
parents: 442
diff changeset
143 Estos archivos tienen el mismo contenido e historial en nuestro
9f460a706292 translated a few sections from tour-basic.tex
jerojasro@localhost
parents: 442
diff changeset
144 repositorio y en el repositorio que clonamos.
442
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
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
9f460a706292 translated a few sections from tour-basic.tex
jerojasro@localhost
parents: 442
diff changeset
147 independiente. Contiene su propia copia de los archivos y la historia
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
5e325122bea5 translated 2 paragraphs
jerojasro@localhost
parents: 451
diff changeset
153 con nuestro repositorio, con la tranquilidad de saber que es una
5e325122bea5 translated 2 paragraphs
jerojasro@localhost
parents: 451
diff changeset
154 % TODO figure out what to say instead of sandbox
5e325122bea5 translated 2 paragraphs
jerojasro@localhost
parents: 451
diff changeset
155 ``caja de arena'' privada que no afectará a nadie más.
442
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
156
454
5e325122bea5 translated 2 paragraphs
jerojasro@localhost
parents: 451
diff changeset
157 \subsection{Qué hay en un repositorio?}
442
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
158
454
5e325122bea5 translated 2 paragraphs
jerojasro@localhost
parents: 451
diff changeset
159 Cuando miramos en detalle dentro de un repositorio, podemos ver que
5e325122bea5 translated 2 paragraphs
jerojasro@localhost
parents: 451
diff changeset
160 contiene un directorio llamado \dirname{.hg}. Aquí es donde Mercurial
5e325122bea5 translated 2 paragraphs
jerojasro@localhost
parents: 451
diff changeset
161 mantiene todos los metadatos del repositorio.
442
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
162 \interaction{tour.ls-a}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
163
454
5e325122bea5 translated 2 paragraphs
jerojasro@localhost
parents: 451
diff changeset
164 Los contenidos del directorio \dirname{.hg} y sus subdirectorios son
5e325122bea5 translated 2 paragraphs
jerojasro@localhost
parents: 451
diff changeset
165 exclusivos de Mercurial. Usted es libre de hacer lo que desee con
5e325122bea5 translated 2 paragraphs
jerojasro@localhost
parents: 451
diff changeset
166 cualquier otro archivo o directorio en el repositorio.
442
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
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
dae36f024e14 some paragraphs translated, added a couple of rules-of-thumb for translation of terms
Javier Rojas <jerojasro@devnull.li>
parents: 454
diff changeset
169 el repositorio ``real'', y todos los archivos y directorios que
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
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
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
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
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
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
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
15a6b61335aa translated a couple of paragraphs, and updated the table of works in progress
Javier Rojas <jerojasro@devnull.li>
parents: 456
diff changeset
187 archivos.
442
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
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
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
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
442
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
206 \item[\texttt{date}] The date and time on which the changeset was
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
207 created, and the timezone in which it was created. (The date and
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
208 time are local to that timezone; they display what time and date it
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
209 was for the person who created the changeset.)
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
210 \item[\texttt{summary}] The first line of the text message that the
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
211 creator of the changeset entered to describe the changeset.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
212 \end{itemize}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
213 The default output printed by \hgcmd{log} is purely a summary; it is
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
214 missing a lot of detail.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
215
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
216 Figure~\ref{fig:tour-basic:history} provides a graphical representation of
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
217 the history of the \dirname{hello} repository, to make it a little
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
218 easier to see which direction history is ``flowing'' in. We'll be
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
219 returning to this figure several times in this chapter and the chapter
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
220 that follows.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
221
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
222 \begin{figure}[ht]
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
223 \centering
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
224 \grafix{tour-history}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
225 \caption{Graphical history of the \dirname{hello} repository}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
226 \label{fig:tour-basic:history}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
227 \end{figure}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
228
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
229 \subsection{Changesets, revisions, and talking to other
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
230 people}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
231
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
232 As English is a notoriously sloppy language, and computer science has
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
233 a hallowed history of terminological confusion (why use one term when
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
234 four will do?), revision control has a variety of words and phrases
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
235 that mean the same thing. If you are talking about Mercurial history
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
236 with other people, you will find that the word ``changeset'' is often
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
237 compressed to ``change'' or (when written) ``cset'', and sometimes a
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
238 changeset is referred to as a ``revision'' or a ``rev''.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
239
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
240 While it doesn't matter what \emph{word} you use to refer to the
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
241 concept of ``a~changeset'', the \emph{identifier} that you use to
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
242 refer to ``a~\emph{specific} changeset'' is of great importance.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
243 Recall that the \texttt{changeset} field in the output from
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
244 \hgcmd{log} identifies a changeset using both a number and a
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
245 hexadecimal string.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
246 \begin{itemize}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
247 \item The revision number is \emph{only valid in that repository},
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
248 \item while the hex string is the \emph{permanent, unchanging
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
249 identifier} that will always identify that exact changeset in
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
250 \emph{every} copy of the repository.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
251 \end{itemize}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
252 This distinction is important. If you send someone an email talking
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
253 about ``revision~33'', there's a high likelihood that their
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
254 revision~33 will \emph{not be the same} as yours. The reason for this
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
255 is that a revision number depends on the order in which changes
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
256 arrived in a repository, and there is no guarantee that the same
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
257 changes will happen in the same order in different repositories.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
258 Three changes $a,b,c$ can easily appear in one repository as $0,1,2$,
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
259 while in another as $1,0,2$.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
260
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
261 Mercurial uses revision numbers purely as a convenient shorthand. If
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
262 you need to discuss a changeset with someone, or make a record of a
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
263 changeset for some other reason (for example, in a bug report), use
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
264 the hexadecimal identifier.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
265
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
266 \subsection{Viewing specific revisions}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
267
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
268 To narrow the output of \hgcmd{log} down to a single revision, use the
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
269 \hgopt{log}{-r} (or \hgopt{log}{--rev}) option. You can use either a
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
270 revision number or a long-form changeset identifier, and you can
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
271 provide as many revisions as you want. \interaction{tour.log-r}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
272
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
273 If you want to see the history of several revisions without having to
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
274 list each one, you can use \emph{range notation}; this lets you
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
275 express the idea ``I want all revisions between $a$ and $b$,
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
276 inclusive''.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
277 \interaction{tour.log.range}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
278 Mercurial also honours the order in which you specify revisions, so
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
279 \hgcmdargs{log}{-r 2:4} prints $2,3,4$ while \hgcmdargs{log}{-r 4:2}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
280 prints $4,3,2$.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
281
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
282 \subsection{More detailed information}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
283
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
284 While the summary information printed by \hgcmd{log} is useful if you
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
285 already know what you're looking for, you may need to see a complete
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
286 description of the change, or a list of the files changed, if you're
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
287 trying to decide whether a changeset is the one you're looking for.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
288 The \hgcmd{log} command's \hggopt{-v} (or \hggopt{--verbose})
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
289 option gives you this extra detail.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
290 \interaction{tour.log-v}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
291
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
292 If you want to see both the description and content of a change, add
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
293 the \hgopt{log}{-p} (or \hgopt{log}{--patch}) option. This displays
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
294 the content of a change as a \emph{unified diff} (if you've never seen
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
295 a unified diff before, see section~\ref{sec:mq:patch} for an overview).
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
296 \interaction{tour.log-vp}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
297
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
298 \section{All about command options}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
299
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
300 Let's take a brief break from exploring Mercurial commands to discuss
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
301 a pattern in the way that they work; you may find this useful to keep
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
302 in mind as we continue our tour.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
303
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
304 Mercurial has a consistent and straightforward approach to dealing
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
305 with the options that you can pass to commands. It follows the
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
306 conventions for options that are common to modern Linux and Unix
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
307 systems.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
308 \begin{itemize}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
309 \item Every option has a long name. For example, as we've already
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
310 seen, the \hgcmd{log} command accepts a \hgopt{log}{--rev} option.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
311 \item Most options have short names, too. Instead of
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
312 \hgopt{log}{--rev}, we can use \hgopt{log}{-r}. (The reason that
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
313 some options don't have short names is that the options in question
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
314 are rarely used.)
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
315 \item Long options start with two dashes (e.g.~\hgopt{log}{--rev}),
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
316 while short options start with one (e.g.~\hgopt{log}{-r}).
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
317 \item Option naming and usage is consistent across commands. For
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
318 example, every command that lets you specify a changeset~ID or
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
319 revision number accepts both \hgopt{log}{-r} and \hgopt{log}{--rev}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
320 arguments.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
321 \end{itemize}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
322 In the examples throughout this book, I use short options instead of
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
323 long. This just reflects my own preference, so don't read anything
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
324 significant into it.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
325
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
326 Most commands that print output of some kind will print more output
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
327 when passed a \hggopt{-v} (or \hggopt{--verbose}) option, and less
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
328 when passed \hggopt{-q} (or \hggopt{--quiet}).
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
329
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
330 \section{Making and reviewing changes}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
331
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
332 Now that we have a grasp of viewing history in Mercurial, let's take a
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
333 look at making some changes and examining them.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
334
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
335 The first thing we'll do is isolate our experiment in a repository of
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
336 its own. We use the \hgcmd{clone} command, but we don't need to
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
337 clone a copy of the remote repository. Since we already have a copy
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
338 of it locally, we can just clone that instead. This is much faster
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
339 than cloning over the network, and cloning a local repository uses
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
340 less disk space in most cases, too.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
341 \interaction{tour.reclone}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
342 As an aside, it's often good practice to keep a ``pristine'' copy of a
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
343 remote repository around, which you can then make temporary clones of
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
344 to create sandboxes for each task you want to work on. This lets you
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
345 work on multiple tasks in parallel, each isolated from the others
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
346 until it's complete and you're ready to integrate it back. Because
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
347 local clones are so cheap, there's almost no overhead to cloning and
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
348 destroying repositories whenever you want.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
349
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
350 In our \dirname{my-hello} repository, we have a file
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
351 \filename{hello.c} that contains the classic ``hello, world'' program.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
352 Let's use the ancient and venerable \command{sed} command to edit this
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
353 file so that it prints a second line of output. (I'm only using
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
354 \command{sed} to do this because it's easy to write a scripted example
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
355 this way. Since you're not under the same constraint, you probably
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
356 won't want to use \command{sed}; simply use your preferred text editor to
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
357 do the same thing.)
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
358 \interaction{tour.sed}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
359
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
360 Mercurial's \hgcmd{status} command will tell us what Mercurial knows
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
361 about the files in the repository.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
362 \interaction{tour.status}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
363 The \hgcmd{status} command prints no output for some files, but a line
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
364 starting with ``\texttt{M}'' for \filename{hello.c}. Unless you tell
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
365 it to, \hgcmd{status} will not print any output for files that have
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
366 not been modified.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
367
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
368 The ``\texttt{M}'' indicates that Mercurial has noticed that we
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
369 modified \filename{hello.c}. We didn't need to \emph{inform}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
370 Mercurial that we were going to modify the file before we started, or
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
371 that we had modified the file after we were done; it was able to
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
372 figure this out itself.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
373
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
374 It's a little bit helpful to know that we've modified
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
375 \filename{hello.c}, but we might prefer to know exactly \emph{what}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
376 changes we've made to it. To do this, we use the \hgcmd{diff}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
377 command.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
378 \interaction{tour.diff}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
379
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
380 \section{Recording changes in a new changeset}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
381
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
382 We can modify files, build and test our changes, and use
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
383 \hgcmd{status} and \hgcmd{diff} to review our changes, until we're
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
384 satisfied with what we've done and arrive at a natural stopping point
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
385 where we want to record our work in a new changeset.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
386
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
387 The \hgcmd{commit} command lets us create a new changeset; we'll
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
388 usually refer to this as ``making a commit'' or ``committing''.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
389
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
390 \subsection{Setting up a username}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
391
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
392 When you try to run \hgcmd{commit} for the first time, it is not
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
393 guaranteed to succeed. Mercurial records your name and address with
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
394 each change that you commit, so that you and others will later be able
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
395 to tell who made each change. Mercurial tries to automatically figure
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
396 out a sensible username to commit the change with. It will attempt
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
397 each of the following methods, in order:
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
398 \begin{enumerate}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
399 \item If you specify a \hgopt{commit}{-u} option to the \hgcmd{commit}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
400 command on the command line, followed by a username, this is always
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
401 given the highest precedence.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
402 \item If you have set the \envar{HGUSER} environment variable, this is
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
403 checked next.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
404 \item If you create a file in your home directory called
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
405 \sfilename{.hgrc}, with a \rcitem{ui}{username} entry, that will be
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
406 used next. To see what the contents of this file should look like,
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
407 refer to section~\ref{sec:tour-basic:username} below.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
408 \item If you have set the \envar{EMAIL} environment variable, this
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
409 will be used next.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
410 \item Mercurial will query your system to find out your local user
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
411 name and host name, and construct a username from these components.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
412 Since this often results in a username that is not very useful, it
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
413 will print a warning if it has to do this.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
414 \end{enumerate}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
415 If all of these mechanisms fail, Mercurial will fail, printing an
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
416 error message. In this case, it will not let you commit until you set
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
417 up a username.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
418
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
419 You should think of the \envar{HGUSER} environment variable and the
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
420 \hgopt{commit}{-u} option to the \hgcmd{commit} command as ways to
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
421 \emph{override} Mercurial's default selection of username. For normal
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
422 use, the simplest and most robust way to set a username for yourself
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
423 is by creating a \sfilename{.hgrc} file; see below for details.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
424
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
425 \subsubsection{Creating a Mercurial configuration file}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
426 \label{sec:tour-basic:username}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
427
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
428 To set a user name, use your favourite editor to create a file called
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
429 \sfilename{.hgrc} in your home directory. Mercurial will use this
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
430 file to look up your personalised configuration settings. The initial
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
431 contents of your \sfilename{.hgrc} should look like this.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
432 \begin{codesample2}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
433 # This is a Mercurial configuration file.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
434 [ui]
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
435 username = Firstname Lastname <email.address@domain.net>
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
436 \end{codesample2}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
437 The ``\texttt{[ui]}'' line begins a \emph{section} of the config file,
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
438 so you can read the ``\texttt{username = ...}'' line as meaning ``set
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
439 the value of the \texttt{username} item in the \texttt{ui} section''.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
440 A section continues until a new section begins, or the end of the
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
441 file. Mercurial ignores empty lines and treats any text from
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
442 ``\texttt{\#}'' to the end of a line as a comment.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
443
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
444 \subsubsection{Choosing a user name}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
445
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
446 You can use any text you like as the value of the \texttt{username}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
447 config item, since this information is for reading by other people,
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
448 but for interpreting by Mercurial. The convention that most people
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
449 follow is to use their name and email address, as in the example
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
450 above.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
451
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
452 \begin{note}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
453 Mercurial's built-in web server obfuscates email addresses, to make
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
454 it more difficult for the email harvesting tools that spammers use.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
455 This reduces the likelihood that you'll start receiving more junk
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
456 email if you publish a Mercurial repository on the web.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
457 \end{note}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
458
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
459 \subsection{Writing a commit message}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
460
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
461 When we commit a change, Mercurial drops us into a text editor, to
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
462 enter a message that will describe the modifications we've made in
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
463 this changeset. This is called the \emph{commit message}. It will be
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
464 a record for readers of what we did and why, and it will be printed by
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
465 \hgcmd{log} after we've finished committing.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
466 \interaction{tour.commit}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
467
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
468 The editor that the \hgcmd{commit} command drops us into will contain
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
469 an empty line, followed by a number of lines starting with
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
470 ``\texttt{HG:}''.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
471 \begin{codesample2}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
472 \emph{empty line}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
473 HG: changed hello.c
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
474 \end{codesample2}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
475 Mercurial ignores the lines that start with ``\texttt{HG:}''; it uses
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
476 them only to tell us which files it's recording changes to. Modifying
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
477 or deleting these lines has no effect.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
478
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
479 \subsection{Writing a good commit message}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
480
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
481 Since \hgcmd{log} only prints the first line of a commit message by
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
482 default, it's best to write a commit message whose first line stands
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
483 alone. Here's a real example of a commit message that \emph{doesn't}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
484 follow this guideline, and hence has a summary that is not readable.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
485 \begin{codesample2}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
486 changeset: 73:584af0e231be
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
487 user: Censored Person <censored.person@example.org>
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
488 date: Tue Sep 26 21:37:07 2006 -0700
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
489 summary: include buildmeister/commondefs. Add an exports and install
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
490 \end{codesample2}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
491
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
492 As far as the remainder of the contents of the commit message are
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
493 concerned, there are no hard-and-fast rules. Mercurial itself doesn't
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
494 interpret or care about the contents of the commit message, though
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
495 your project may have policies that dictate a certain kind of
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
496 formatting.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
497
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
498 My personal preference is for short, but informative, commit messages
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
499 that tell me something that I can't figure out with a quick glance at
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
500 the output of \hgcmdargs{log}{--patch}.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
501
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
502 \subsection{Aborting a commit}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
503
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
504 If you decide that you don't want to commit while in the middle of
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
505 editing a commit message, simply exit from your editor without saving
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
506 the file that it's editing. This will cause nothing to happen to
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
507 either the repository or the working directory.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
508
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
509 If we run the \hgcmd{commit} command without any arguments, it records
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
510 all of the changes we've made, as reported by \hgcmd{status} and
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
511 \hgcmd{diff}.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
512
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
513 \subsection{Admiring our new handiwork}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
514
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
515 Once we've finished the commit, we can use the \hgcmd{tip} command to
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
516 display the changeset we just created. This command produces output
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
517 that is identical to \hgcmd{log}, but it only displays the newest
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
518 revision in the repository.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
519 \interaction{tour.tip}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
520 We refer to the newest revision in the repository as the tip revision,
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
521 or simply the tip.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
522
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
523 \section{Sharing changes}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
524
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
525 We mentioned earlier that repositories in Mercurial are
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
526 self-contained. This means that the changeset we just created exists
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
527 only in our \dirname{my-hello} repository. Let's look at a few ways
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
528 that we can propagate this change into other repositories.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
529
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
530 \subsection{Pulling changes from another repository}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
531 \label{sec:tour:pull}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
532
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
533 To get started, let's clone our original \dirname{hello} repository,
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
534 which does not contain the change we just committed. We'll call our
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
535 temporary repository \dirname{hello-pull}.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
536 \interaction{tour.clone-pull}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
537
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
538 We'll use the \hgcmd{pull} command to bring changes from
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
539 \dirname{my-hello} into \dirname{hello-pull}. However, blindly
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
540 pulling unknown changes into a repository is a somewhat scary
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
541 prospect. Mercurial provides the \hgcmd{incoming} command to tell us
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
542 what changes the \hgcmd{pull} command \emph{would} pull into the
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
543 repository, without actually pulling the changes in.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
544 \interaction{tour.incoming}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
545 (Of course, someone could cause more changesets to appear in the
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
546 repository that we ran \hgcmd{incoming} in, before we get a chance to
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
547 \hgcmd{pull} the changes, so that we could end up pulling changes that we
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
548 didn't expect.)
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
549
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
550 Bringing changes into a repository is a simple matter of running the
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
551 \hgcmd{pull} command, and telling it which repository to pull from.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
552 \interaction{tour.pull}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
553 As you can see from the before-and-after output of \hgcmd{tip}, we
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
554 have successfully pulled changes into our repository. There remains
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
555 one step before we can see these changes in the working directory.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
556
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
557 \subsection{Updating the working directory}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
558
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
559 We have so far glossed over the relationship between a repository and
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
560 its working directory. The \hgcmd{pull} command that we ran in
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
561 section~\ref{sec:tour:pull} brought changes into the repository, but
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
562 if we check, there's no sign of those changes in the working
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
563 directory. This is because \hgcmd{pull} does not (by default) touch
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
564 the working directory. Instead, we use the \hgcmd{update} command to
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
565 do this.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
566 \interaction{tour.update}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
567
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
568 It might seem a bit strange that \hgcmd{pull} doesn't update the
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
569 working directory automatically. There's actually a good reason for
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
570 this: you can use \hgcmd{update} to update the working directory to
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
571 the state it was in at \emph{any revision} in the history of the
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
572 repository. If you had the working directory updated to an old
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
573 revision---to hunt down the origin of a bug, say---and ran a
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
574 \hgcmd{pull} which automatically updated the working directory to a
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
575 new revision, you might not be terribly happy.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
576
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
577 However, since pull-then-update is such a common thing to do,
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
578 Mercurial lets you combine the two by passing the \hgopt{pull}{-u}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
579 option to \hgcmd{pull}.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
580 \begin{codesample2}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
581 hg pull -u
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
582 \end{codesample2}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
583 If you look back at the output of \hgcmd{pull} in
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
584 section~\ref{sec:tour:pull} when we ran it without \hgopt{pull}{-u},
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
585 you can see that it printed a helpful reminder that we'd have to take
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
586 an explicit step to update the working directory:
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
587 \begin{codesample2}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
588 (run 'hg update' to get a working copy)
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
589 \end{codesample2}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
590
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
591 To find out what revision the working directory is at, use the
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
592 \hgcmd{parents} command.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
593 \interaction{tour.parents}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
594 If you look back at figure~\ref{fig:tour-basic:history}, you'll see
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
595 arrows connecting each changeset. The node that the arrow leads
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
596 \emph{from} in each case is a parent, and the node that the arrow
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
597 leads \emph{to} is its child. The working directory has a parent in
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
598 just the same way; this is the changeset that the working directory
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
599 currently contains.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
600
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
601 To update the working directory to a particular revision, give a
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
602 revision number or changeset~ID to the \hgcmd{update} command.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
603 \interaction{tour.older}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
604 If you omit an explicit revision, \hgcmd{update} will update to the
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
605 tip revision, as shown by the second call to \hgcmd{update} in the
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
606 example above.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
607
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
608 \subsection{Pushing changes to another repository}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
609
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
610 Mercurial lets us push changes to another repository, from the
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
611 repository we're currently visiting. As with the example of
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
612 \hgcmd{pull} above, we'll create a temporary repository to push our
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
613 changes into.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
614 \interaction{tour.clone-push}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
615 The \hgcmd{outgoing} command tells us what changes would be pushed
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
616 into another repository.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
617 \interaction{tour.outgoing}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
618 And the \hgcmd{push} command does the actual push.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
619 \interaction{tour.push}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
620 As with \hgcmd{pull}, the \hgcmd{push} command does not update the
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
621 working directory in the repository that it's pushing changes into.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
622 (Unlike \hgcmd{pull}, \hgcmd{push} does not provide a \texttt{-u}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
623 option that updates the other repository's working directory.)
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
624
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
625 What happens if we try to pull or push changes and the receiving
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
626 repository already has those changes? Nothing too exciting.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
627 \interaction{tour.push.nothing}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
628
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
629 \subsection{Sharing changes over a network}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
630
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
631 The commands we have covered in the previous few sections are not
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
632 limited to working with local repositories. Each works in exactly the
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
633 same fashion over a network connection; simply pass in a URL instead
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
634 of a local path.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
635 \interaction{tour.outgoing.net}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
636 In this example, we can see what changes we could push to the remote
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
637 repository, but the repository is understandably not set up to let
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
638 anonymous users push to it.
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
639 \interaction{tour.push.net}
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
640
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
641 %%% Local Variables:
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
642 %%% mode: latex
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
643 %%% TeX-master: "00book"
2fb78d342e07 changed es/Leame.1st
jerojasro@localhost
parents: 432
diff changeset
644 %%% End: