Mercurial > hgbook
annotate es/undo.tex @ 494:149ea8ae39c4
translated a couple of paragraphs of the "behind the scenes" chapter
author | Javier Rojas <jerojasro@devnull.li> |
---|---|
date | Tue, 04 Nov 2008 23:50:20 -0500 |
parents | b7d4d66c3ae5 |
children | b8d9066abcea |
rev | line source |
---|---|
473
c2ff82128ac5
Started translating undo.tex , added mistake and rollback
Igor TAmara <igor@tamarapatino.org>
parents:
442
diff
changeset
|
1 \chapter{Encontrar y arreglar sus equivocaciones} |
442 | 2 \label{chap:undo} |
3 | |
473
c2ff82128ac5
Started translating undo.tex , added mistake and rollback
Igor TAmara <igor@tamarapatino.org>
parents:
442
diff
changeset
|
4 Errar es humano, pero tratar adecuadamente las consecuencias requiere |
c2ff82128ac5
Started translating undo.tex , added mistake and rollback
Igor TAmara <igor@tamarapatino.org>
parents:
442
diff
changeset
|
5 un sistema de control de revisiones de primera categoría. En este |
c2ff82128ac5
Started translating undo.tex , added mistake and rollback
Igor TAmara <igor@tamarapatino.org>
parents:
442
diff
changeset
|
6 capítulo, discutiremos algunas técnicas que puede usar cuando |
c2ff82128ac5
Started translating undo.tex , added mistake and rollback
Igor TAmara <igor@tamarapatino.org>
parents:
442
diff
changeset
|
7 encuentra que hay un problema enraizado en su proyecto. Mercurial |
c2ff82128ac5
Started translating undo.tex , added mistake and rollback
Igor TAmara <igor@tamarapatino.org>
parents:
442
diff
changeset
|
8 tiene unas características poderosas que le ayudarán a isolar las |
c2ff82128ac5
Started translating undo.tex , added mistake and rollback
Igor TAmara <igor@tamarapatino.org>
parents:
442
diff
changeset
|
9 fuentes de los problemas, y a dar cuenta de ellas apropiadamente. |
442 | 10 |
473
c2ff82128ac5
Started translating undo.tex , added mistake and rollback
Igor TAmara <igor@tamarapatino.org>
parents:
442
diff
changeset
|
11 \section{Borrar la historia local} |
442 | 12 |
473
c2ff82128ac5
Started translating undo.tex , added mistake and rollback
Igor TAmara <igor@tamarapatino.org>
parents:
442
diff
changeset
|
13 \subsection{La consignación accidental} |
442 | 14 |
473
c2ff82128ac5
Started translating undo.tex , added mistake and rollback
Igor TAmara <igor@tamarapatino.org>
parents:
442
diff
changeset
|
15 Tengo el problema ocasional, pero persistente de teclear más rápido de |
c2ff82128ac5
Started translating undo.tex , added mistake and rollback
Igor TAmara <igor@tamarapatino.org>
parents:
442
diff
changeset
|
16 lo que pienso, que aveces resulta en consignar un conjunto de cambios |
c2ff82128ac5
Started translating undo.tex , added mistake and rollback
Igor TAmara <igor@tamarapatino.org>
parents:
442
diff
changeset
|
17 incompleto o simplemente malo. En mi caso, el conjunto de cambios |
477
6d2bbeb50af6
Fixing mistake preventing from build, footnote to ndt, moving archivo to fichero on daily.tex
Igor TAmara <igor@tamarapatino.org>
parents:
476
diff
changeset
|
18 incompleto consiste en que creé un nuevo fichero fuente, pero olvidé |
473
c2ff82128ac5
Started translating undo.tex , added mistake and rollback
Igor TAmara <igor@tamarapatino.org>
parents:
442
diff
changeset
|
19 hacerle \hgcmd{add}. Un conjunto de cambios``simplemente malo'' no es |
c2ff82128ac5
Started translating undo.tex , added mistake and rollback
Igor TAmara <igor@tamarapatino.org>
parents:
442
diff
changeset
|
20 tan común, pero sí resulta muy molesto. |
442 | 21 |
477
6d2bbeb50af6
Fixing mistake preventing from build, footnote to ndt, moving archivo to fichero on daily.tex
Igor TAmara <igor@tamarapatino.org>
parents:
476
diff
changeset
|
22 \subsection{Hacer rollback una transacción} |
442 | 23 \label{sec:undo:rollback} |
24 | |
473
c2ff82128ac5
Started translating undo.tex , added mistake and rollback
Igor TAmara <igor@tamarapatino.org>
parents:
442
diff
changeset
|
25 En la sección~\ref{sec:concepts:txn}, mencioné que Mercurial trata |
c2ff82128ac5
Started translating undo.tex , added mistake and rollback
Igor TAmara <igor@tamarapatino.org>
parents:
442
diff
changeset
|
26 modificación a un repositorio como una \emph{transacción}. Cada vez |
c2ff82128ac5
Started translating undo.tex , added mistake and rollback
Igor TAmara <igor@tamarapatino.org>
parents:
442
diff
changeset
|
27 que consigna un conjunto de cambios o lo jala de otro repositorio, |
477
6d2bbeb50af6
Fixing mistake preventing from build, footnote to ndt, moving archivo to fichero on daily.tex
Igor TAmara <igor@tamarapatino.org>
parents:
476
diff
changeset
|
28 Mercurial recuerda lo que hizo. Puede deshacer, o hacer \emph{roll back}\ndt{El significado igual que en los |
6d2bbeb50af6
Fixing mistake preventing from build, footnote to ndt, moving archivo to fichero on daily.tex
Igor TAmara <igor@tamarapatino.org>
parents:
476
diff
changeset
|
29 ambientes de sistemas manejadores de bases de datos se refiere a |
6d2bbeb50af6
Fixing mistake preventing from build, footnote to ndt, moving archivo to fichero on daily.tex
Igor TAmara <igor@tamarapatino.org>
parents:
476
diff
changeset
|
30 la atomicidad e integridad al devolver un conjunto de acciones que |
6d2bbeb50af6
Fixing mistake preventing from build, footnote to ndt, moving archivo to fichero on daily.tex
Igor TAmara <igor@tamarapatino.org>
parents:
476
diff
changeset
|
31 permitan dejar el repositorio en un estado consistente previo}, |
473
c2ff82128ac5
Started translating undo.tex , added mistake and rollback
Igor TAmara <igor@tamarapatino.org>
parents:
442
diff
changeset
|
32 exactamente una de tales acciones usando la orden \hgcmd{rollback}. |
c2ff82128ac5
Started translating undo.tex , added mistake and rollback
Igor TAmara <igor@tamarapatino.org>
parents:
442
diff
changeset
|
33 (Ver en la sección~\ref{sec:undo:rollback-after-push} una anotación |
c2ff82128ac5
Started translating undo.tex , added mistake and rollback
Igor TAmara <igor@tamarapatino.org>
parents:
442
diff
changeset
|
34 importante acerca del uso de esta orden.) |
442 | 35 |
473
c2ff82128ac5
Started translating undo.tex , added mistake and rollback
Igor TAmara <igor@tamarapatino.org>
parents:
442
diff
changeset
|
36 A continuación una equivocación que me sucede frecuentemente: |
c2ff82128ac5
Started translating undo.tex , added mistake and rollback
Igor TAmara <igor@tamarapatino.org>
parents:
442
diff
changeset
|
37 consignar un cambio en el cual he creado un nuevo fichero, pero he |
c2ff82128ac5
Started translating undo.tex , added mistake and rollback
Igor TAmara <igor@tamarapatino.org>
parents:
442
diff
changeset
|
38 olvidado hacerle \hgcmd{add}. |
442 | 39 \interaction{rollback.commit} |
473
c2ff82128ac5
Started translating undo.tex , added mistake and rollback
Igor TAmara <igor@tamarapatino.org>
parents:
442
diff
changeset
|
40 La salida de \hgcmd{status} después de la consignación confirma |
c2ff82128ac5
Started translating undo.tex , added mistake and rollback
Igor TAmara <igor@tamarapatino.org>
parents:
442
diff
changeset
|
41 inmediatamente este error. |
442 | 42 \interaction{rollback.status} |
477
6d2bbeb50af6
Fixing mistake preventing from build, footnote to ndt, moving archivo to fichero on daily.tex
Igor TAmara <igor@tamarapatino.org>
parents:
476
diff
changeset
|
43 La consignación capturó los cambios en el fichero \filename{a}, pero |
473
c2ff82128ac5
Started translating undo.tex , added mistake and rollback
Igor TAmara <igor@tamarapatino.org>
parents:
442
diff
changeset
|
44 no el nuevo fichero \filename{b}. Si yo publicara este conjunto de |
c2ff82128ac5
Started translating undo.tex , added mistake and rollback
Igor TAmara <igor@tamarapatino.org>
parents:
442
diff
changeset
|
45 cambios a un repositorio compartido con un colega, es bastante |
c2ff82128ac5
Started translating undo.tex , added mistake and rollback
Igor TAmara <igor@tamarapatino.org>
parents:
442
diff
changeset
|
46 probable que algo en \filename{a} se refiriera a \filename{b}, el cual |
c2ff82128ac5
Started translating undo.tex , added mistake and rollback
Igor TAmara <igor@tamarapatino.org>
parents:
442
diff
changeset
|
47 podría no estar presente cuando jalen mis cambios del repositorio. Me |
c2ff82128ac5
Started translating undo.tex , added mistake and rollback
Igor TAmara <igor@tamarapatino.org>
parents:
442
diff
changeset
|
48 convertiría el sujeto de cierta indignación. |
442 | 49 |
473
c2ff82128ac5
Started translating undo.tex , added mistake and rollback
Igor TAmara <igor@tamarapatino.org>
parents:
442
diff
changeset
|
50 Como sea, la suerte me acompaña---Encontré mi error antes de publicar |
c2ff82128ac5
Started translating undo.tex , added mistake and rollback
Igor TAmara <igor@tamarapatino.org>
parents:
442
diff
changeset
|
51 el conjunto de cambios. Uso la orden \hgcmd{rollback}, y Mercurial |
c2ff82128ac5
Started translating undo.tex , added mistake and rollback
Igor TAmara <igor@tamarapatino.org>
parents:
442
diff
changeset
|
52 hace desaparecer el último conjunto de cambios. |
442 | 53 \interaction{rollback.rollback} |
473
c2ff82128ac5
Started translating undo.tex , added mistake and rollback
Igor TAmara <igor@tamarapatino.org>
parents:
442
diff
changeset
|
54 El conjunto de cambios ya no está en la historia del repositorio, y el |
c2ff82128ac5
Started translating undo.tex , added mistake and rollback
Igor TAmara <igor@tamarapatino.org>
parents:
442
diff
changeset
|
55 directorio de trabajo cree que el fichero \filename{a} ha sido |
476
d5f1049a79dd
roll back untranslatable and more on undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
473
diff
changeset
|
56 modificado. La consignación y el roll back dejaron el directorio de |
d5f1049a79dd
roll back untranslatable and more on undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
473
diff
changeset
|
57 trabajo exactamente como estaba antes de la consignación; el conjunto |
473
c2ff82128ac5
Started translating undo.tex , added mistake and rollback
Igor TAmara <igor@tamarapatino.org>
parents:
442
diff
changeset
|
58 de cambios ha sido eliminado totlamente. Ahora puedo hacer \hgcmd{add} |
c2ff82128ac5
Started translating undo.tex , added mistake and rollback
Igor TAmara <igor@tamarapatino.org>
parents:
442
diff
changeset
|
59 al fichero \filename{b}, y hacer de nuevo la consignación. |
442 | 60 \interaction{rollback.add} |
61 | |
473
c2ff82128ac5
Started translating undo.tex , added mistake and rollback
Igor TAmara <igor@tamarapatino.org>
parents:
442
diff
changeset
|
62 \subsection{Erroneamente jalado} |
442 | 63 |
473
c2ff82128ac5
Started translating undo.tex , added mistake and rollback
Igor TAmara <igor@tamarapatino.org>
parents:
442
diff
changeset
|
64 Mantener ramas de desarrollo separadas de un proyecto en distintos |
c2ff82128ac5
Started translating undo.tex , added mistake and rollback
Igor TAmara <igor@tamarapatino.org>
parents:
442
diff
changeset
|
65 repositorios es una práctica común con Mercurial. Su equipo de |
c2ff82128ac5
Started translating undo.tex , added mistake and rollback
Igor TAmara <igor@tamarapatino.org>
parents:
442
diff
changeset
|
66 desarrollo puede tener un repositorio compartido para la versión ``0.9'' |
c2ff82128ac5
Started translating undo.tex , added mistake and rollback
Igor TAmara <igor@tamarapatino.org>
parents:
442
diff
changeset
|
67 y otra con cambios distintos para la versión ``1.0''. |
442 | 68 |
473
c2ff82128ac5
Started translating undo.tex , added mistake and rollback
Igor TAmara <igor@tamarapatino.org>
parents:
442
diff
changeset
|
69 Con este escenario, puede imaginar las consecuencias si tuviera un |
c2ff82128ac5
Started translating undo.tex , added mistake and rollback
Igor TAmara <igor@tamarapatino.org>
parents:
442
diff
changeset
|
70 repositorio local ``0.9'', y jalara accidentalmente los cambios del |
c2ff82128ac5
Started translating undo.tex , added mistake and rollback
Igor TAmara <igor@tamarapatino.org>
parents:
442
diff
changeset
|
71 repositorio compartido de la versión ``1.0'' en este. En el peor de |
c2ff82128ac5
Started translating undo.tex , added mistake and rollback
Igor TAmara <igor@tamarapatino.org>
parents:
442
diff
changeset
|
72 los casos, por falta de atención, es posible que publique tales |
c2ff82128ac5
Started translating undo.tex , added mistake and rollback
Igor TAmara <igor@tamarapatino.org>
parents:
442
diff
changeset
|
73 cambios en el árbol compartido ``0.9'', confundiendo a todo su equipo |
c2ff82128ac5
Started translating undo.tex , added mistake and rollback
Igor TAmara <igor@tamarapatino.org>
parents:
442
diff
changeset
|
74 de trabajo(pero no se preocupe, volveremos a este terrorífico |
c2ff82128ac5
Started translating undo.tex , added mistake and rollback
Igor TAmara <igor@tamarapatino.org>
parents:
442
diff
changeset
|
75 escenario posteriormente). En todo caso, es muy probable que usted se |
c2ff82128ac5
Started translating undo.tex , added mistake and rollback
Igor TAmara <igor@tamarapatino.org>
parents:
442
diff
changeset
|
76 de cuenta inmediatamente, dado que Mercurial mostrará el URL de donde |
c2ff82128ac5
Started translating undo.tex , added mistake and rollback
Igor TAmara <igor@tamarapatino.org>
parents:
442
diff
changeset
|
77 está jalando, o que vea jalando una sospechosa gran cantidad de |
c2ff82128ac5
Started translating undo.tex , added mistake and rollback
Igor TAmara <igor@tamarapatino.org>
parents:
442
diff
changeset
|
78 cambios en el repositorio. |
442 | 79 |
476
d5f1049a79dd
roll back untranslatable and more on undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
473
diff
changeset
|
80 La orden \hgcmd{rollback} excluirá eficientemente los conjuntos de |
d5f1049a79dd
roll back untranslatable and more on undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
473
diff
changeset
|
81 cambios que haya acabado de jalar. Mercurial agrupa todos los cambios |
d5f1049a79dd
roll back untranslatable and more on undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
473
diff
changeset
|
82 de un \hgcmd{pull} a una única transacción y bastará con un |
d5f1049a79dd
roll back untranslatable and more on undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
473
diff
changeset
|
83 \hgcmd{rollback} para deshacer esta equivocación. |
442 | 84 |
476
d5f1049a79dd
roll back untranslatable and more on undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
473
diff
changeset
|
85 \subsection{Después de publicar, un roll back es futil} |
442 | 86 \label{sec:undo:rollback-after-push} |
87 | |
476
d5f1049a79dd
roll back untranslatable and more on undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
473
diff
changeset
|
88 El valor de \hgcmd{rollback} se anula cuando ha publicado sus cambios |
d5f1049a79dd
roll back untranslatable and more on undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
473
diff
changeset
|
89 a otro repositorio. Un cambio desaparece totalmente al hacer roll back, |
d5f1049a79dd
roll back untranslatable and more on undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
473
diff
changeset
|
90 pero \emph{solamente} en el repositorio en el cual aplica |
d5f1049a79dd
roll back untranslatable and more on undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
473
diff
changeset
|
91 \hgcmd{rollback}. Debido a que un roll back elimina la historia, |
d5f1049a79dd
roll back untranslatable and more on undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
473
diff
changeset
|
92 no hay forma de que la desaparición de un cambio se propague entre |
d5f1049a79dd
roll back untranslatable and more on undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
473
diff
changeset
|
93 repositorios. |
442 | 94 |
476
d5f1049a79dd
roll back untranslatable and more on undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
473
diff
changeset
|
95 Si ha publicado un cambio en otro repositorio---particularmente si es |
d5f1049a79dd
roll back untranslatable and more on undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
473
diff
changeset
|
96 un repositorio público---esencialmente está ``en terreno agreste,'' |
d5f1049a79dd
roll back untranslatable and more on undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
473
diff
changeset
|
97 y tendrá que reparar la equivocación de un modo distinto. Lo que |
d5f1049a79dd
roll back untranslatable and more on undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
473
diff
changeset
|
98 pasará si publica un conjunto de cambios en algún sitio, hacer |
d5f1049a79dd
roll back untranslatable and more on undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
473
diff
changeset
|
99 rollback y después volver a jalar del repositorio del cual había |
d5f1049a79dd
roll back untranslatable and more on undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
473
diff
changeset
|
100 publicado, es que el conjunto de cambios reaparecerá en su repositorio. |
442 | 101 |
476
d5f1049a79dd
roll back untranslatable and more on undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
473
diff
changeset
|
102 (Si está absolutamente segruro de que el conjunto de cambios al que |
d5f1049a79dd
roll back untranslatable and more on undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
473
diff
changeset
|
103 desea hacer rollback es el cambio más reciente del repositorio en el |
d5f1049a79dd
roll back untranslatable and more on undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
473
diff
changeset
|
104 cual publicó, \emph{y} sabe que nadie más pudo haber jalado de tal |
d5f1049a79dd
roll back untranslatable and more on undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
473
diff
changeset
|
105 repositorio, puede hacer rollback del conjunto de cambios allí, pero |
d5f1049a79dd
roll back untranslatable and more on undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
473
diff
changeset
|
106 es mejor no confiar en una solución de este estilo. Si lo hace, tarde |
d5f1049a79dd
roll back untranslatable and more on undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
473
diff
changeset
|
107 o temprano un conjunto de cambios logrará colarse en un repositorio |
d5f1049a79dd
roll back untranslatable and more on undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
473
diff
changeset
|
108 que usted no controle directamente(o del cual se ha olvidado), y |
d5f1049a79dd
roll back untranslatable and more on undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
473
diff
changeset
|
109 volverá a hostigarle.) |
d5f1049a79dd
roll back untranslatable and more on undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
473
diff
changeset
|
110 |
d5f1049a79dd
roll back untranslatable and more on undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
473
diff
changeset
|
111 \subsection{Solamente hay un roll back} |
442 | 112 |
476
d5f1049a79dd
roll back untranslatable and more on undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
473
diff
changeset
|
113 Mercurial almacena exactamente una transacción en su bitácora de |
d5f1049a79dd
roll back untranslatable and more on undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
473
diff
changeset
|
114 transacciones; tal transacción es la más reciente de las que haya |
d5f1049a79dd
roll back untranslatable and more on undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
473
diff
changeset
|
115 ocurrido en el repositorio. Esto significa que solamente puede hacer |
d5f1049a79dd
roll back untranslatable and more on undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
473
diff
changeset
|
116 roll back a una transacción. Si espera poder hacer roll back a una |
d5f1049a79dd
roll back untranslatable and more on undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
473
diff
changeset
|
117 transacción después al antecesor, observará que no es el |
d5f1049a79dd
roll back untranslatable and more on undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
473
diff
changeset
|
118 comportamiento que obtendrá. |
442 | 119 \interaction{rollback.twice} |
476
d5f1049a79dd
roll back untranslatable and more on undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
473
diff
changeset
|
120 Una vez que haya aplicado un rollback en una transacción a un |
d5f1049a79dd
roll back untranslatable and more on undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
473
diff
changeset
|
121 repositorio, no podrá volver a hacer rollback hasta que haga una |
d5f1049a79dd
roll back untranslatable and more on undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
473
diff
changeset
|
122 consignación o haya jalado. |
442 | 123 |
485
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
124 \section{Revertir un cambio equivocado} |
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
125 |
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
126 Si modifica un fichero y se da cuenta que no quería realmente cambiar |
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
127 tal fichero, y todavía no ha consignado los cambios, la orden |
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
128 necesaria es \hgcmd{revert}. Observa el conjunto de cambios padre del |
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
129 directorio y restaura los contenidos del fichero al estado de tal |
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
130 conjunto de cambios. (Es una forma larga de decirlo, usualmente |
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
131 deshace sus modificaciones.) |
442 | 132 |
485
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
133 Ilustremos como actúa la orden \hgcmd{revert} con un ejemplo |
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
134 pequeño. Comenzaremos modificando un fichero al cual Mercurial ya está |
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
135 siguiendo. |
442 | 136 \interaction{daily.revert.modify} |
485
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
137 Si no queremos ese cambio, podemos aplicar \hgcmd{revert} al fichero. |
442 | 138 \interaction{daily.revert.unmodify} |
485
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
139 La orden \hgcmd{revert} nos brinda un grado adicional de seguridad |
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
140 guardando nuestro fichero modificado con la extensión \filename{.orig}. |
442 | 141 \interaction{daily.revert.status} |
142 | |
485
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
143 Este es un resumen de casos en los cuales la orden \hgcmd{revert} es |
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
144 de utilidad. Describiremos cada uno de ellos con más detalle en la |
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
145 sección siguiente. |
442 | 146 \begin{itemize} |
485
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
147 \item Si usted modifica un fichero, lo restaurará a su estado sin |
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
148 modificación previo. |
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
149 \item Si usted hace \hgcmd{add} a un fichero, revertirá el estado de |
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
150 ``adicionado'' del fichero, pero no lo tocará |
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
151 \item Si borra un fichero sin decirle a Mercurial, restaurará el |
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
152 fichero con sus contenidos sin modificación. |
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
153 \item Si usa la orden \hgcmd{remove} para eliminar un fichero, deshará |
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
154 el estado ``removido'' del fichero, y lo restaurará con sus |
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
155 contenidos sin modificación. |
442 | 156 \end{itemize} |
157 | |
485
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
158 \subsection{Errores al administrar ficheros} |
442 | 159 \label{sec:undo:mgmt} |
160 | |
485
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
161 La orden \hgcmd{revert} es útil para más que ficheros modificados. Le |
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
162 permite reversar los resultados de todas las órdenes de administración |
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
163 de ficheros que provee Mercurial---\hgcmd{add}, \hgcmd{remove}, y las |
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
164 demás. |
442 | 165 |
485
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
166 Si usted hace \hgcmd{add} a un fichero, y no deseaba que Mercurial le |
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
167 diera seguimiento, use \hgcmd{revert} para deshacer la adición. No se |
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
168 preocupe; Mercurial no modificará de forma alguna el fichero. |
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
169 Solamente lo ``desmarcará''. |
442 | 170 \interaction{daily.revert.add} |
171 | |
485
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
172 De forma similar, Si le solicita a Mercurial hacer \hgcmd{remove} a un |
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
173 fichero, puede usar \hgcmd{revert} para restarurarlo a los contenidos |
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
174 que tenía la revisión padre del directorio de trabajo. |
442 | 175 \interaction{daily.revert.remove} |
485
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
176 Funciona de la misma manera para un fichero que usted haya eliminado |
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
177 manualmente, sin decirle a Mercurial (recuerde que en la terminología |
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
178 de Mercurial esta clase de fichero se llama ``faltante''). |
442 | 179 \interaction{daily.revert.missing} |
180 | |
485
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
181 Si usted revierte un \hgcmd{copy}, el fichero a donde se copió |
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
182 permanece en su directorio de trabajo, pero sin seguimiento. Dado que |
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
183 una copia no afecta el fichero fuente de copiado de ninguna maner, |
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
184 Mercurial no hace nada con este. |
442 | 185 \interaction{daily.revert.copy} |
186 | |
485
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
187 \subsubsection{Un caso ligeramente especial:revertir un renombramiento} |
442 | 188 |
485
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
189 Si hace \hgcmd{rename} a un fichero, hay un detalle que debe tener en |
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
190 cuenta. Cuando aplica \hgcmd{revert} a un cambio de nombre, no es |
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
191 suficiente proveer el nombre del fichero destino, como puede verlo en |
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
192 el siguiente ejemplo. |
442 | 193 \interaction{daily.revert.rename} |
485
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
194 Como puede ver en la salida de \hgcmd{status}, el fichero con el nuevo |
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
195 nombre no se identifica más como agregado, pero el fichero con el |
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
196 nombre-\emph{inicial} se elimna! Esto es contra-intuitivo (por lo |
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
197 menos para mí), pero por lo menos es fácil arreglarlo. |
442 | 198 \interaction{daily.revert.rename-orig} |
485
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
199 Por lo tanto, recuerde, para revertir un \hgcmd{rename}, debe proveer |
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
200 \emph{ambos} nombres, la fuente y el destino. |
442 | 201 |
202 % TODO: the output doesn't look like it will be removed! | |
203 | |
485
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
204 (A propósito, si elimina un fichero, y modifica el fichero con el |
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
205 nuevo nombre, al revertir ambos componentes del renombramiento, cuando |
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
206 Mercurial restaure el fichero que fue eliminado como parte del |
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
207 renombramiento, no será modificado. |
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
208 Si necesita que las modificaciones en el archivo destino del |
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
209 renombramiento se muestren, no olvide copiarlas encima.) |
442 | 210 |
486
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
211 Estos aspectos engorrosos al revertir un renombramiento se constituyen |
485
d2467817c934
some paragraphs translated to spanish
Igor TAmara <igor@tamarapatino.org>
parents:
477
diff
changeset
|
212 discutiblemente en un fallo de Mercurial. |
442 | 213 |
486
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
214 \section{Tratar cambios consignados} |
442 | 215 |
486
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
216 Considere un caso en el que ha consignado el cambio $a$, y otro cambio |
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
217 $b$ sobre este; se ha dado cuenta que el cambio $a$ era |
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
218 incorrecto. Mercurial le permite ``retroceder'' un conjunto de cambios |
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
219 completo automáticamente, y construir bloques que le permitan revertir |
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
220 parte de un conjunto de cambios a mano. |
442 | 221 |
486
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
222 Antes de leer esta sección, hay algo para tener en cuenta: la orden |
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
223 \hgcmd{backout} deshace cambios \emph{adicionando} a la historia, sin |
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
224 modificar o borrar. Es la herramienta correcta si está arreglando |
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
225 fallos, pero no si está tratando de deshacer algún cambio que tiene |
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
226 consecuencias catastróficas. Para tratar con esos, vea la sección~\ref{sec:undo:aaaiiieee}. |
442 | 227 |
486
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
228 \subsection{Retroceder un conjunto de cambios} |
442 | 229 |
486
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
230 La orden \hgcmd{backout} le permite ``deshacer'' los efectos de todo |
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
231 un conjunto de cambios de forma automatizada. Dado que la historia de |
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
232 Mercurial es inmutable, esta orden \emph{no} se deshace del conjunto |
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
233 de cambios que usted desea deshacer. En cambio, crea un nuevo |
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
234 conjunto de cambios que \emph{reversa} el conjunto de cambios que |
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
235 usted indique. |
442 | 236 |
486
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
237 La operación de la orden \hgcmd{backout} es un poco intrincada, y lo |
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
238 ilustraremos con algunos ejemplos. Primero crearemos un repositorio |
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
239 con algunos cambios sencillos. |
442 | 240 \interaction{backout.init} |
241 | |
486
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
242 La orden \hgcmd{backout} toma un ID de conjunto de cambios como su |
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
243 argumento; el conjunto de cambios a retroceder. Normalmente |
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
244 \hgcmd{backout} le ofrecerá un editor de texto para escribir el |
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
245 mensaje de la consignación, para dejar un registro de por qué está |
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
246 retrocediendo. En este ejemplo, colocamos un mensaje en la |
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
247 consignación usando la opción \hgopt{backout}{-m} . |
442 | 248 |
487
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
249 \subsection{Retroceder el conjunto de cambios punta} |
442 | 250 |
486
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
251 Comenzamos retrocediendo el último conjunto de cambios que consignamos. |
442 | 252 \interaction{backout.simple} |
486
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
253 Puede ver que la segunda línea de \filename{myfile} ya no está |
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
254 presente. La salida de \hgcmd{log} nos da una idea de lo que la orden |
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
255 \hgcmd{backout} ha hecho. |
442 | 256 \interaction{backout.simple.log} |
486
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
257 Vea que el nuevo conjunto de cambios que \hgcmd{backout} ha creado es |
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
258 un hijo del conjunto de cambios que retrocedimos. Es más sencillo de |
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
259 ver en la figura~\ref{fig:undo:backout}, que presenta una vista |
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
260 gráfica de la historia de cambios. Como puede ver, la historia es |
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
261 bonita y lineal. |
442 | 262 |
263 \begin{figure}[htb] | |
264 \centering | |
265 \grafix{undo-simple} | |
486
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
266 \caption{Retroceso de un cambio con la orden \hgcmd{backout}} |
442 | 267 \label{fig:undo:backout} |
268 \end{figure} | |
269 | |
487
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
270 \subsection{Retroceso de un cambio que no es la punta} |
442 | 271 |
486
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
272 Si desea retrocede un cambio distinto al último que ha consignado, use |
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
273 la opción \hgopt{backout}{--merge} a la orden \hgcmd{backout}. |
442 | 274 \interaction{backout.non-tip.clone} |
486
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
275 Que resulta en un retroceso de un conjunto de cambios ``en un sólo |
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
276 tiro'', una operación que resulta normalmente rápida y sencilla. |
442 | 277 \interaction{backout.non-tip.backout} |
278 | |
486
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
279 Si ve los contenidos del fichero \filename{myfile} después de |
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
280 finalizar el retroceso, verá que el primer y el tercer cambio están |
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
281 presentes, pero no el segundo. |
442 | 282 \interaction{backout.non-tip.cat} |
283 | |
486
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
284 Como lo muestra la historia gráfica en la |
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
285 figura~\ref{fig:undo:backout-non-tip}, Mercurial realmente consigna |
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
286 \emph{dos} cambios en estas situaciones (los nodos encerrados en una |
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
287 caja son aquellos que Mercurial consigna automaticamente). Antes de |
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
288 que Mercurial comience el proceso de retroceso, primero recuerda cuál |
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
289 es el padre del directorio de trabajo. Posteriormente hace un |
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
290 retroceso al conjunto de cambios objetivo y lo consigna como un |
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
291 conjunto de cambios. Finalmente, fusiona con el padre anterior del |
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
292 directorio de trabajo, y consigna el resultado de la fusión. |
442 | 293 |
294 % TODO: to me it looks like mercurial doesn't commit the second merge automatically! | |
295 | |
296 \begin{figure}[htb] | |
297 \centering | |
298 \grafix{undo-non-tip} | |
487
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
299 \caption{Retroceso automatizado de un cambio a algo que no es la punta con la orden \hgcmd{backout}} |
442 | 300 \label{fig:undo:backout-non-tip} |
301 \end{figure} | |
302 | |
486
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
303 El resultado es que usted termina ``donde estaba'', solamente con un |
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
304 poco de historia adicional que deshace el efecto de un conjunto de |
7864f2264e28
translated some paragraphs of undo.tex
Igor TAmara <igor@tamarapatino.org>
parents:
485
diff
changeset
|
305 cambios que usted quería evitar. |
442 | 306 |
487
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
307 \subsubsection{Use siempre la opción \hgopt{backout}{--merge}} |
442 | 308 |
487
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
309 De hecho, dado que la opción \hgopt{backout}{--merge} siempre hara lo |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
310 ``correcto'' esté o no retrocediendo el conjunto de cambios punta |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
311 (p.e.~no tratará de fusionar si está retrocediendo la punta, dado que |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
312 no es necesario), usted debería usar \emph{siempre} esta opción cuando |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
313 ejecuta la orden \hgcmd{backout}. |
442 | 314 |
487
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
315 \subsection{Más control sobre el proceso de retroceso} |
442 | 316 |
487
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
317 A pesar de que recomiendo usar siempre la opción |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
318 \hgopt{backout}{--merge} cuando está retrocediendo un cambio, la orden |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
319 \hgcmd{backout} le permite decidir cómo mezclar un retroceso de un |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
320 conjunto de cambios. Es muy extraño que usted necestite tomar control |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
321 del proceso de retroceso de forma manual, pero puede ser útil entender |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
322 lo que la orden \hgcmd{backout} está haciendo automáticamente para |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
323 usted. Para ilustrarlo, clonemos nuestro primer repositorio, pero |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
324 omitamos el retroceso que contiene. |
442 | 325 |
326 \interaction{backout.manual.clone} | |
487
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
327 Como en el ejemplo anterior, consignaremos un tercer cambio, después |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
328 haremos retroceso de su padre, y veremos qué pasa. |
442 | 329 \interaction{backout.manual.backout} |
487
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
330 Nuestro nuevo conjunto de cambios es de nuevo un descendiente del |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
331 conjunto de cambio que retrocedimos; es por lo tanto una nueva cabeza, |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
332 \emph{no} un descendiente del conjunto de cambios que era la punta. La |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
333 orden \hgcmd{backout} fue muy explícita diciéndolo. |
442 | 334 \interaction{backout.manual.log} |
335 | |
487
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
336 De nuevo, es más sencillo lo que pasó viendo una gráfica de la |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
337 historia de revisiones, en la figura~\ref{fig:undo:backout-manual}. |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
338 Esto nos aclara que cuando usamos \hgcmd{backout} para retroceder un |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
339 cambio a algo que no sea la punta, Mercurial añade una nueva cabeza al |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
340 repositorio (el cambio que consignó está encerrado en una caja). |
442 | 341 |
342 \begin{figure}[htb] | |
343 \centering | |
344 \grafix{undo-manual} | |
487
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
345 \caption{Retroceso usando la orden \hgcmd{backout}} |
442 | 346 \label{fig:undo:backout-manual} |
347 \end{figure} | |
348 | |
487
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
349 Después de que la orden \hgcmd{backout} ha terminado, deja un nuevo |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
350 conjunto de cambios de ``retroceso'' como el padre del directorio de trabajo. |
442 | 351 \interaction{backout.manual.parents} |
487
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
352 Ahora tenemos dos conjuntos de cambios aislados. |
442 | 353 \interaction{backout.manual.heads} |
354 | |
487
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
355 Reflexionemos acerca de lo que esperamos ver como contenidos de |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
356 \filename{myfile}. El primer cambio debería estar presente, porque |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
357 nunca le hicimos retroceso. El segundo cambio debió desaparecer, |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
358 puesto que es el que retrocedimos. Dado que la gráfica de la historia |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
359 muestra que el tercer camlio es una cabeza separada, \emph{no} |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
360 esperamos ver el tercer cambio presente en \filename{myfile}. |
442 | 361 \interaction{backout.manual.cat} |
487
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
362 Para que el tercer cambio esté en el archivo, hacemos una fusión usual |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
363 de las dos cabezas. |
442 | 364 \interaction{backout.manual.merge} |
487
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
365 Después de eso, la historia gráfica de nuestro repositorio luce como |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
366 la figura~\ref{fig:undo:backout-manual-merge}. |
442 | 367 |
368 \begin{figure}[htb] | |
369 \centering | |
370 \grafix{undo-manual-merge} | |
487
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
371 \caption{Fusión manual de un retroceso} |
442 | 372 \label{fig:undo:backout-manual-merge} |
373 \end{figure} | |
374 | |
487
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
375 \subsection{Por qué \hgcmd{backout} hace lo que hace} |
442 | 376 |
487
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
377 Esta es una descripción corta de cómo trabaja la orden \hgcmd{backout}. |
442 | 378 \begin{enumerate} |
487
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
379 \item Se asegura de que el directorio de trabajo es ``limpio'', esto |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
380 es, que la salida de \hgcmd{status} debería ser vacía. |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
381 \item Recuerda el padre actual del directorio de trabajo. A este |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
382 conjunto de cambio lo llamaremos \texttt{orig} |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
383 \item Hace el equivalente de un \hgcmd{update} para sincronizar el |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
384 directorio de trabajo con el conjunto de cambios que usted quiere |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
385 retroceder. Lo llamaremos \texttt{backout} |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
386 \item Encuentra el padre del conjunto de cambios. Lo llamaremos |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
387 \texttt{parent}. |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
388 \item Para cada archivo del conjunto de cambios que el |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
389 \texttt{retroceso} afecte, hará el equivalente a |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
390 \hgcmdargs{revert}{-r parent} sobre ese fichero, para restaurarlo a |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
391 los contenidos que tenía antes de que el conjunto de cambios fuera |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
392 consignado. |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
393 \item Se consigna el resultado como un nuevo conjunto de cambios y |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
394 tiene a \texttt{backout} como su padre. |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
395 \item Si especifica \hgopt{backout}{--merge} en la línea de comandos, |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
396 se fusiona con \texttt{orig}, y se consigna el resultado de la |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
397 fusión. |
442 | 398 \end{enumerate} |
399 | |
487
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
400 Una vía alternativa de implementar la orden \hgcmd{backout} sería usar |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
401 \hgcmd{export} sobre el conjunto de cambios a retroceder como un diff |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
402 y después usar laa opción \cmdopt{patch}{--reverse} de la orden |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
403 \command{patch} para reversar el efecto del cambio sin molestar el |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
404 directorio de trabajo. Suena mucho más simple, pero no funcionaría |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
405 bien ni de cerca. |
442 | 406 |
487
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
407 La razón por la cual \hgcmd{backout} hace una actualización, una |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
408 consignación, una fusión y otra consignación es para dar a la |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
409 maquinaria de fusión la mayor oportunidad de hacer un buen trabajo |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
410 cuando se trata con todos los cambios \emph{entre} el cambio que está |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
411 retrocediendo y la punta actual. |
442 | 412 |
487
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
413 Si está retrocediendo un conjunto de cambios que está a unas ~100 |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
414 atrás en su historia del proyecto, las posibilidades de que una orden |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
415 \command{patch} sea capaz de ser aplicada a un diff reverso, |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
416 claramente no son altas, porque los cambios que intervienen podrían |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
417 ``no coincidir con el contexto'' que \command{patch} usa para |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
418 determinar si puede aplicar un parche (si esto suena como cháchara, |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
419 vea una discusión de la orden \command{patch} en \ref{sec:mq:patch}). |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
420 Adicionalmente, la maquinaria de fusión de Mercurial manejará ficheros |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
421 y directorios renombrados, cambios de permisos, y modificaciones a |
9fdb45b994d4
Finished backing out section
Igor TAmara <igor@tamarapatino.org>
parents:
486
diff
changeset
|
422 archivos binarios, nada de lo cual la orden \command{patch} puede manejar. |
442 | 423 |
488
b7d4d66c3ae5
Aiiiiiee section translated
Igor TAmara <igor@tamarapatino.org>
parents:
487
diff
changeset
|
424 \section{Cambios que nunca debieron ocurrir} |
442 | 425 \label{sec:undo:aaaiiieee} |
426 | |
488
b7d4d66c3ae5
Aiiiiiee section translated
Igor TAmara <igor@tamarapatino.org>
parents:
487
diff
changeset
|
427 En la mayoría de los casos, la orden \hgcmd{backout} es exactamente lo |
b7d4d66c3ae5
Aiiiiiee section translated
Igor TAmara <igor@tamarapatino.org>
parents:
487
diff
changeset
|
428 que necesita para deshacer los efectos de un cambio. Deja un registro |
b7d4d66c3ae5
Aiiiiiee section translated
Igor TAmara <igor@tamarapatino.org>
parents:
487
diff
changeset
|
429 permanente y exacto de lo que usted hizo, cuando se consignó el |
b7d4d66c3ae5
Aiiiiiee section translated
Igor TAmara <igor@tamarapatino.org>
parents:
487
diff
changeset
|
430 conjunto de cambios original y cuando se hizo la limpieza. |
442 | 431 |
488
b7d4d66c3ae5
Aiiiiiee section translated
Igor TAmara <igor@tamarapatino.org>
parents:
487
diff
changeset
|
432 En ocasiones particulares, puede haber consignado un cambio que no |
b7d4d66c3ae5
Aiiiiiee section translated
Igor TAmara <igor@tamarapatino.org>
parents:
487
diff
changeset
|
433 debería estar de ninguna forma en el repositorio. Por ejemplo, sería |
b7d4d66c3ae5
Aiiiiiee section translated
Igor TAmara <igor@tamarapatino.org>
parents:
487
diff
changeset
|
434 muy inusual, y considerado como una equivocación, consignar los |
b7d4d66c3ae5
Aiiiiiee section translated
Igor TAmara <igor@tamarapatino.org>
parents:
487
diff
changeset
|
435 archivos objeto junto con el código fuente. los ficheros objeto no |
b7d4d66c3ae5
Aiiiiiee section translated
Igor TAmara <igor@tamarapatino.org>
parents:
487
diff
changeset
|
436 tienen valor intrínseco y son \emph{grandes}, por lo tanto aumentan el |
b7d4d66c3ae5
Aiiiiiee section translated
Igor TAmara <igor@tamarapatino.org>
parents:
487
diff
changeset
|
437 tamaño del repositorio y la cantidad de tiempo que se emplea al clonar |
b7d4d66c3ae5
Aiiiiiee section translated
Igor TAmara <igor@tamarapatino.org>
parents:
487
diff
changeset
|
438 o jalar cambios. |
442 | 439 |
488
b7d4d66c3ae5
Aiiiiiee section translated
Igor TAmara <igor@tamarapatino.org>
parents:
487
diff
changeset
|
440 Antes de discutir las opciones que tiene si consignó cambio del tipo |
b7d4d66c3ae5
Aiiiiiee section translated
Igor TAmara <igor@tamarapatino.org>
parents:
487
diff
changeset
|
441 ``bolsa de papel deschable'' (el tipo que es tan malo que le gustaría |
b7d4d66c3ae5
Aiiiiiee section translated
Igor TAmara <igor@tamarapatino.org>
parents:
487
diff
changeset
|
442 colocarse una bolsa de papel desechable en su cabeza), permítame |
b7d4d66c3ae5
Aiiiiiee section translated
Igor TAmara <igor@tamarapatino.org>
parents:
487
diff
changeset
|
443 discutir primero unas aproximaciones que probablemente no funcionen. |
442 | 444 |
488
b7d4d66c3ae5
Aiiiiiee section translated
Igor TAmara <igor@tamarapatino.org>
parents:
487
diff
changeset
|
445 Dado que Mercurial trata de forma acumulativa la historia---cada |
b7d4d66c3ae5
Aiiiiiee section translated
Igor TAmara <igor@tamarapatino.org>
parents:
487
diff
changeset
|
446 cambio se coloca encima de todos los cambios que leo |
b7d4d66c3ae5
Aiiiiiee section translated
Igor TAmara <igor@tamarapatino.org>
parents:
487
diff
changeset
|
447 preceden---usualmente usted no puede hacer que unos cambios desastros |
b7d4d66c3ae5
Aiiiiiee section translated
Igor TAmara <igor@tamarapatino.org>
parents:
487
diff
changeset
|
448 desaparezcan. La única excepción es cuando usted ha acabado de |
b7d4d66c3ae5
Aiiiiiee section translated
Igor TAmara <igor@tamarapatino.org>
parents:
487
diff
changeset
|
449 consignar un cambio y este no ha sido publicado o jalado en otro |
b7d4d66c3ae5
Aiiiiiee section translated
Igor TAmara <igor@tamarapatino.org>
parents:
487
diff
changeset
|
450 repositorio. Ahí es cuando puede usar la orden \hgcmd{rollback} con |
b7d4d66c3ae5
Aiiiiiee section translated
Igor TAmara <igor@tamarapatino.org>
parents:
487
diff
changeset
|
451 seguridad, Como detallé en la sección~\ref{sec:undo:rollback}. |
b7d4d66c3ae5
Aiiiiiee section translated
Igor TAmara <igor@tamarapatino.org>
parents:
487
diff
changeset
|
452 |
b7d4d66c3ae5
Aiiiiiee section translated
Igor TAmara <igor@tamarapatino.org>
parents:
487
diff
changeset
|
453 Después de que usted haya publicado un cambio en otro repositorio, usted |
b7d4d66c3ae5
Aiiiiiee section translated
Igor TAmara <igor@tamarapatino.org>
parents:
487
diff
changeset
|
454 \emph{podría} usar la orden \hgcmd{rollback} para hacer que en su copia |
b7d4d66c3ae5
Aiiiiiee section translated
Igor TAmara <igor@tamarapatino.org>
parents:
487
diff
changeset
|
455 local desaparezca el cambio, pero no tendrá las consecuencias que |
b7d4d66c3ae5
Aiiiiiee section translated
Igor TAmara <igor@tamarapatino.org>
parents:
487
diff
changeset
|
456 desea. El cambio estará presente en un repositorio remoto, y |
b7d4d66c3ae5
Aiiiiiee section translated
Igor TAmara <igor@tamarapatino.org>
parents:
487
diff
changeset
|
457 reaparecerá en su repositorio local la próxima vez que jale |
442 | 458 |
488
b7d4d66c3ae5
Aiiiiiee section translated
Igor TAmara <igor@tamarapatino.org>
parents:
487
diff
changeset
|
459 Si una situación como esta se presenta, y usted sabe en qué |
b7d4d66c3ae5
Aiiiiiee section translated
Igor TAmara <igor@tamarapatino.org>
parents:
487
diff
changeset
|
460 repositorios su mal cambio se ha propagado, puede \emph{intentar} |
b7d4d66c3ae5
Aiiiiiee section translated
Igor TAmara <igor@tamarapatino.org>
parents:
487
diff
changeset
|
461 deshacerse del conjunto de cambios de \emph{todos} los repositorios en |
b7d4d66c3ae5
Aiiiiiee section translated
Igor TAmara <igor@tamarapatino.org>
parents:
487
diff
changeset
|
462 los que se pueda encontrar. Esta por supuesto, no es una solución |
b7d4d66c3ae5
Aiiiiiee section translated
Igor TAmara <igor@tamarapatino.org>
parents:
487
diff
changeset
|
463 satisfactoria: si usted deja de hacerlo en un solo repositorio, |
b7d4d66c3ae5
Aiiiiiee section translated
Igor TAmara <igor@tamarapatino.org>
parents:
487
diff
changeset
|
464 mientras esté eliminándolo, el cambio todavía estará ``allí afuera'', |
b7d4d66c3ae5
Aiiiiiee section translated
Igor TAmara <igor@tamarapatino.org>
parents:
487
diff
changeset
|
465 y podría propagarse más tarde. |
442 | 466 |
488
b7d4d66c3ae5
Aiiiiiee section translated
Igor TAmara <igor@tamarapatino.org>
parents:
487
diff
changeset
|
467 Si ha consignado uno o más cambios \emph{después} del cambio que desea |
b7d4d66c3ae5
Aiiiiiee section translated
Igor TAmara <igor@tamarapatino.org>
parents:
487
diff
changeset
|
468 desaparecer, sus opciones son aún más reducidas. Mercurial no provee |
b7d4d66c3ae5
Aiiiiiee section translated
Igor TAmara <igor@tamarapatino.org>
parents:
487
diff
changeset
|
469 una forma de ``cabar un hueco'' en la historia, dejando los conjuntos |
b7d4d66c3ae5
Aiiiiiee section translated
Igor TAmara <igor@tamarapatino.org>
parents:
487
diff
changeset
|
470 de cambios intactos. |
442 | 471 |
488
b7d4d66c3ae5
Aiiiiiee section translated
Igor TAmara <igor@tamarapatino.org>
parents:
487
diff
changeset
|
472 %Dejamos de traducir lo que viene a continuación, porque será |
b7d4d66c3ae5
Aiiiiiee section translated
Igor TAmara <igor@tamarapatino.org>
parents:
487
diff
changeset
|
473 %modificado por upstream... |
442 | 474 |
475 XXX This needs filling out. The \texttt{hg-replay} script in the | |
476 \texttt{examples} directory works, but doesn't handle merge | |
477 changesets. Kind of an important omission. | |
478 | |
479 \subsection{Protect yourself from ``escaped'' changes} | |
480 | |
481 If you've committed some changes to your local repository and they've | |
482 been pushed or pulled somewhere else, this isn't necessarily a | |
483 disaster. You can protect yourself ahead of time against some classes | |
484 of bad changeset. This is particularly easy if your team usually | |
485 pulls changes from a central repository. | |
486 | |
487 By configuring some hooks on that repository to validate incoming | |
488 changesets (see chapter~\ref{chap:hook}), you can automatically | |
489 prevent some kinds of bad changeset from being pushed to the central | |
490 repository at all. With such a configuration in place, some kinds of | |
491 bad changeset will naturally tend to ``die out'' because they can't | |
492 propagate into the central repository. Better yet, this happens | |
493 without any need for explicit intervention. | |
494 | |
495 For instance, an incoming change hook that verifies that a changeset | |
496 will actually compile can prevent people from inadvertantly ``breaking | |
497 the build''. | |
498 | |
499 \section{Finding the source of a bug} | |
500 \label{sec:undo:bisect} | |
501 | |
502 While it's all very well to be able to back out a changeset that | |
503 introduced a bug, this requires that you know which changeset to back | |
504 out. Mercurial provides an invaluable command, called | |
505 \hgcmd{bisect}, that helps you to automate this process and accomplish | |
506 it very efficiently. | |
507 | |
508 The idea behind the \hgcmd{bisect} command is that a changeset has | |
509 introduced some change of behaviour that you can identify with a | |
510 simple binary test. You don't know which piece of code introduced the | |
511 change, but you know how to test for the presence of the bug. The | |
512 \hgcmd{bisect} command uses your test to direct its search for the | |
513 changeset that introduced the code that caused the bug. | |
514 | |
515 Here are a few scenarios to help you understand how you might apply | |
516 this command. | |
517 \begin{itemize} | |
518 \item The most recent version of your software has a bug that you | |
519 remember wasn't present a few weeks ago, but you don't know when it | |
520 was introduced. Here, your binary test checks for the presence of | |
521 that bug. | |
522 \item You fixed a bug in a rush, and now it's time to close the entry | |
523 in your team's bug database. The bug database requires a changeset | |
524 ID when you close an entry, but you don't remember which changeset | |
525 you fixed the bug in. Once again, your binary test checks for the | |
526 presence of the bug. | |
527 \item Your software works correctly, but runs~15\% slower than the | |
528 last time you measured it. You want to know which changeset | |
529 introduced the performance regression. In this case, your binary | |
530 test measures the performance of your software, to see whether it's | |
531 ``fast'' or ``slow''. | |
532 \item The sizes of the components of your project that you ship | |
533 exploded recently, and you suspect that something changed in the way | |
534 you build your project. | |
535 \end{itemize} | |
536 | |
537 From these examples, it should be clear that the \hgcmd{bisect} | |
538 command is not useful only for finding the sources of bugs. You can | |
539 use it to find any ``emergent property'' of a repository (anything | |
540 that you can't find from a simple text search of the files in the | |
541 tree) for which you can write a binary test. | |
542 | |
543 We'll introduce a little bit of terminology here, just to make it | |
544 clear which parts of the search process are your responsibility, and | |
545 which are Mercurial's. A \emph{test} is something that \emph{you} run | |
546 when \hgcmd{bisect} chooses a changeset. A \emph{probe} is what | |
547 \hgcmd{bisect} runs to tell whether a revision is good. Finally, | |
548 we'll use the word ``bisect'', as both a noun and a verb, to stand in | |
549 for the phrase ``search using the \hgcmd{bisect} command. | |
550 | |
551 One simple way to automate the searching process would be simply to | |
552 probe every changeset. However, this scales poorly. If it took ten | |
553 minutes to test a single changeset, and you had 10,000 changesets in | |
554 your repository, the exhaustive approach would take on average~35 | |
555 \emph{days} to find the changeset that introduced a bug. Even if you | |
556 knew that the bug was introduced by one of the last 500 changesets, | |
557 and limited your search to those, you'd still be looking at over 40 | |
558 hours to find the changeset that introduced your bug. | |
559 | |
560 What the \hgcmd{bisect} command does is use its knowledge of the | |
561 ``shape'' of your project's revision history to perform a search in | |
562 time proportional to the \emph{logarithm} of the number of changesets | |
563 to check (the kind of search it performs is called a dichotomic | |
564 search). With this approach, searching through 10,000 changesets will | |
565 take less than three hours, even at ten minutes per test (the search | |
566 will require about 14 tests). Limit your search to the last hundred | |
567 changesets, and it will take only about an hour (roughly seven tests). | |
568 | |
569 The \hgcmd{bisect} command is aware of the ``branchy'' nature of a | |
570 Mercurial project's revision history, so it has no problems dealing | |
571 with branches, merges, or multiple heads in a repoository. It can | |
572 prune entire branches of history with a single probe, which is how it | |
573 operates so efficiently. | |
574 | |
575 \subsection{Using the \hgcmd{bisect} command} | |
576 | |
577 Here's an example of \hgcmd{bisect} in action. | |
578 | |
579 \begin{note} | |
580 In versions 0.9.5 and earlier of Mercurial, \hgcmd{bisect} was not a | |
581 core command: it was distributed with Mercurial as an extension. | |
582 This section describes the built-in command, not the old extension. | |
583 \end{note} | |
584 | |
585 Now let's create a repository, so that we can try out the | |
586 \hgcmd{bisect} command in isolation. | |
587 \interaction{bisect.init} | |
588 We'll simulate a project that has a bug in it in a simple-minded way: | |
589 create trivial changes in a loop, and nominate one specific change | |
590 that will have the ``bug''. This loop creates 35 changesets, each | |
591 adding a single file to the repository. We'll represent our ``bug'' | |
592 with a file that contains the text ``i have a gub''. | |
593 \interaction{bisect.commits} | |
594 | |
595 The next thing that we'd like to do is figure out how to use the | |
596 \hgcmd{bisect} command. We can use Mercurial's normal built-in help | |
597 mechanism for this. | |
598 \interaction{bisect.help} | |
599 | |
600 The \hgcmd{bisect} command works in steps. Each step proceeds as follows. | |
601 \begin{enumerate} | |
602 \item You run your binary test. | |
603 \begin{itemize} | |
604 \item If the test succeeded, you tell \hgcmd{bisect} by running the | |
605 \hgcmdargs{bisect}{good} command. | |
606 \item If it failed, run the \hgcmdargs{bisect}{--bad} command. | |
607 \end{itemize} | |
608 \item The command uses your information to decide which changeset to | |
609 test next. | |
610 \item It updates the working directory to that changeset, and the | |
611 process begins again. | |
612 \end{enumerate} | |
613 The process ends when \hgcmd{bisect} identifies a unique changeset | |
614 that marks the point where your test transitioned from ``succeeding'' | |
615 to ``failing''. | |
616 | |
617 To start the search, we must run the \hgcmdargs{bisect}{--reset} command. | |
618 \interaction{bisect.search.init} | |
619 | |
620 In our case, the binary test we use is simple: we check to see if any | |
621 file in the repository contains the string ``i have a gub''. If it | |
622 does, this changeset contains the change that ``caused the bug''. By | |
623 convention, a changeset that has the property we're searching for is | |
624 ``bad'', while one that doesn't is ``good''. | |
625 | |
626 Most of the time, the revision to which the working directory is | |
627 synced (usually the tip) already exhibits the problem introduced by | |
628 the buggy change, so we'll mark it as ``bad''. | |
629 \interaction{bisect.search.bad-init} | |
630 | |
631 Our next task is to nominate a changeset that we know \emph{doesn't} | |
632 have the bug; the \hgcmd{bisect} command will ``bracket'' its search | |
633 between the first pair of good and bad changesets. In our case, we | |
634 know that revision~10 didn't have the bug. (I'll have more words | |
635 about choosing the first ``good'' changeset later.) | |
636 \interaction{bisect.search.good-init} | |
637 | |
638 Notice that this command printed some output. | |
639 \begin{itemize} | |
640 \item It told us how many changesets it must consider before it can | |
641 identify the one that introduced the bug, and how many tests that | |
642 will require. | |
643 \item It updated the working directory to the next changeset to test, | |
644 and told us which changeset it's testing. | |
645 \end{itemize} | |
646 | |
647 We now run our test in the working directory. We use the | |
648 \command{grep} command to see if our ``bad'' file is present in the | |
649 working directory. If it is, this revision is bad; if not, this | |
650 revision is good. | |
651 \interaction{bisect.search.step1} | |
652 | |
653 This test looks like a perfect candidate for automation, so let's turn | |
654 it into a shell function. | |
655 \interaction{bisect.search.mytest} | |
656 We can now run an entire test step with a single command, | |
657 \texttt{mytest}. | |
658 \interaction{bisect.search.step2} | |
659 A few more invocations of our canned test step command, and we're | |
660 done. | |
661 \interaction{bisect.search.rest} | |
662 | |
663 Even though we had~40 changesets to search through, the \hgcmd{bisect} | |
664 command let us find the changeset that introduced our ``bug'' with | |
665 only five tests. Because the number of tests that the \hgcmd{bisect} | |
666 command performs grows logarithmically with the number of changesets to | |
667 search, the advantage that it has over the ``brute force'' search | |
668 approach increases with every changeset you add. | |
669 | |
670 \subsection{Cleaning up after your search} | |
671 | |
672 When you're finished using the \hgcmd{bisect} command in a | |
673 repository, you can use the \hgcmdargs{bisect}{reset} command to drop | |
674 the information it was using to drive your search. The command | |
675 doesn't use much space, so it doesn't matter if you forget to run this | |
676 command. However, \hgcmd{bisect} won't let you start a new search in | |
677 that repository until you do a \hgcmdargs{bisect}{reset}. | |
678 \interaction{bisect.search.reset} | |
679 | |
680 \section{Tips for finding bugs effectively} | |
681 | |
682 \subsection{Give consistent input} | |
683 | |
684 The \hgcmd{bisect} command requires that you correctly report the | |
685 result of every test you perform. If you tell it that a test failed | |
686 when it really succeeded, it \emph{might} be able to detect the | |
687 inconsistency. If it can identify an inconsistency in your reports, | |
688 it will tell you that a particular changeset is both good and bad. | |
689 However, it can't do this perfectly; it's about as likely to report | |
690 the wrong changeset as the source of the bug. | |
691 | |
692 \subsection{Automate as much as possible} | |
693 | |
694 When I started using the \hgcmd{bisect} command, I tried a few times | |
695 to run my tests by hand, on the command line. This is an approach | |
696 that I, at least, am not suited to. After a few tries, I found that I | |
697 was making enough mistakes that I was having to restart my searches | |
698 several times before finally getting correct results. | |
699 | |
700 My initial problems with driving the \hgcmd{bisect} command by hand | |
701 occurred even with simple searches on small repositories; if the | |
702 problem you're looking for is more subtle, or the number of tests that | |
703 \hgcmd{bisect} must perform increases, the likelihood of operator | |
704 error ruining the search is much higher. Once I started automating my | |
705 tests, I had much better results. | |
706 | |
707 The key to automated testing is twofold: | |
708 \begin{itemize} | |
709 \item always test for the same symptom, and | |
710 \item always feed consistent input to the \hgcmd{bisect} command. | |
711 \end{itemize} | |
712 In my tutorial example above, the \command{grep} command tests for the | |
713 symptom, and the \texttt{if} statement takes the result of this check | |
714 and ensures that we always feed the same input to the \hgcmd{bisect} | |
715 command. The \texttt{mytest} function marries these together in a | |
716 reproducible way, so that every test is uniform and consistent. | |
717 | |
718 \subsection{Check your results} | |
719 | |
720 Because the output of a \hgcmd{bisect} search is only as good as the | |
721 input you give it, don't take the changeset it reports as the | |
722 absolute truth. A simple way to cross-check its report is to manually | |
723 run your test at each of the following changesets: | |
724 \begin{itemize} | |
725 \item The changeset that it reports as the first bad revision. Your | |
726 test should still report this as bad. | |
727 \item The parent of that changeset (either parent, if it's a merge). | |
728 Your test should report this changeset as good. | |
729 \item A child of that changeset. Your test should report this | |
730 changeset as bad. | |
731 \end{itemize} | |
732 | |
733 \subsection{Beware interference between bugs} | |
734 | |
735 It's possible that your search for one bug could be disrupted by the | |
736 presence of another. For example, let's say your software crashes at | |
737 revision 100, and worked correctly at revision 50. Unknown to you, | |
738 someone else introduced a different crashing bug at revision 60, and | |
739 fixed it at revision 80. This could distort your results in one of | |
740 several ways. | |
741 | |
742 It is possible that this other bug completely ``masks'' yours, which | |
743 is to say that it occurs before your bug has a chance to manifest | |
744 itself. If you can't avoid that other bug (for example, it prevents | |
745 your project from building), and so can't tell whether your bug is | |
746 present in a particular changeset, the \hgcmd{bisect} command cannot | |
747 help you directly. Instead, you can mark a changeset as untested by | |
748 running \hgcmdargs{bisect}{--skip}. | |
749 | |
750 A different problem could arise if your test for a bug's presence is | |
751 not specific enough. If you check for ``my program crashes'', then | |
752 both your crashing bug and an unrelated crashing bug that masks it | |
753 will look like the same thing, and mislead \hgcmd{bisect}. | |
754 | |
755 Another useful situation in which to use \hgcmdargs{bisect}{--skip} is | |
756 if you can't test a revision because your project was in a broken and | |
757 hence untestable state at that revision, perhaps because someone | |
758 checked in a change that prevented the project from building. | |
759 | |
760 \subsection{Bracket your search lazily} | |
761 | |
762 Choosing the first ``good'' and ``bad'' changesets that will mark the | |
763 end points of your search is often easy, but it bears a little | |
764 discussion nevertheless. From the perspective of \hgcmd{bisect}, the | |
765 ``newest'' changeset is conventionally ``bad'', and the older | |
766 changeset is ``good''. | |
767 | |
768 If you're having trouble remembering when a suitable ``good'' change | |
769 was, so that you can tell \hgcmd{bisect}, you could do worse than | |
770 testing changesets at random. Just remember to eliminate contenders | |
771 that can't possibly exhibit the bug (perhaps because the feature with | |
772 the bug isn't present yet) and those where another problem masks the | |
773 bug (as I discussed above). | |
774 | |
775 Even if you end up ``early'' by thousands of changesets or months of | |
776 history, you will only add a handful of tests to the total number that | |
777 \hgcmd{bisect} must perform, thanks to its logarithmic behaviour. | |
778 | |
779 %%% Local Variables: | |
780 %%% mode: latex | |
781 %%% TeX-master: "00book" | |
782 %%% End: |