comparison ja/daily.tex @ 380:38f034c1da53

finished daily.tex
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Thu, 19 Feb 2009 14:37:50 +0900
parents beab196f78da
children de4142983445
comparison
equal deleted inserted replaced
379:beab196f78da 380:38f034c1da53
91 $B$3$l$K$h$C$F2?$,5/$3$C$F$$$k$N$+M}2r$7$d$9$/$9$k$H6&$K!$D@L[N"$KLq2p$JLd(B 91 $B$3$l$K$h$C$F2?$,5/$3$C$F$$$k$N$+M}2r$7$d$9$/$9$k$H6&$K!$D@L[N"$KLq2p$JLd(B
92 $BBj$,5/$3$k2DG=@-$r8:$i$7$F$$$k!%$3$N5sF0$O(BMercurial$B$NBgH>$N%3%^%s%I$K6&(B 92 $BBj$,5/$3$k2DG=@-$r8:$i$7$F$$$k!%$3$N5sF0$O(BMercurial$B$NBgH>$N%3%^%s%I$K6&(B
93 $BDL$7$F$$$k!%(B 93 $BDL$7$F$$$k!%(B
94 94
95 %\subsection{Aside: Mercurial tracks files, not directories} 95 %\subsection{Aside: Mercurial tracks files, not directories}
96 \subsection{$BM>CL(B: Mercurial$B$O%G%#%l%/%H%j$G$O$J$/%U%!%$%k$rDI@W$9$k(B} 96 \subsection{$B$3$\$lOC(B: Mercurial$B$O%G%#%l%/%H%j$G$O$J$/%U%!%$%k$rDI@W$9$k(B}
97 97
98 %Mercurial does not track directory information. Instead, it tracks 98 %Mercurial does not track directory information. Instead, it tracks
99 %the path to a file. Before creating a file, it first creates any 99 %the path to a file. Before creating a file, it first creates any
100 %missing directory components of the path. After it deletes a file, it 100 %missing directory components of the path. After it deletes a file, it
101 %then deletes any empty directories that were in the deleted file's 101 %then deletes any empty directories that were in the deleted file's
148 $BA0$K:n@.$9$k$3$H$,$"$k!%(B 148 $BA0$K:n@.$9$k$3$H$,$"$k!%(B
149 149
150 %\section{How to stop tracking a file} 150 %\section{How to stop tracking a file}
151 \section{$B%U%!%$%kDI@W$NDd;_(B} 151 \section{$B%U%!%$%kDI@W$NDd;_(B}
152 152
153 Once you decide that a file no longer belongs in your repository, use 153 %Once you decide that a file no longer belongs in your repository, use
154 the \hgcmd{remove} command; this deletes the file, and tells Mercurial 154 %the \hgcmd{remove} command; this deletes the file, and tells Mercurial
155 to stop tracking it. A removed file is represented in the output of 155 %to stop tracking it. A removed file is represented in the output of
156 \hgcmd{status} with a ``\texttt{R}''. 156 %\hgcmd{status} with a ``\texttt{R}''.
157 %\interaction{daily.files.remove}
158
159 $B%U%!%$%k$,%j%]%8%H%j$KI,MW$J$/$J$C$?;~$O(B\hgcmd{remove}$B%3%^%s%I$r<B9T$9(B
160 $B$k!%$3$N%3%^%s%I$O%U%!%$%k$r:o=|$7$?>e$G(BMercurial$B$K%U%!%$%kDI@W$NDd;_$r;X(B
161 $B<($9$k!%:o=|$5$l$?%U%!%$%k$O(B\hgcmd{status}$B%3%^%s%I$N=PNO$G(B``\texttt{R}''
162 $B$HI=<($5$l$k!%(B
157 \interaction{daily.files.remove} 163 \interaction{daily.files.remove}
158 164
159 After you \hgcmd{remove} a file, Mercurial will no longer track 165 %After you \hgcmd{remove} a file, Mercurial will no longer track
160 changes to that file, even if you recreate a file with the same name 166 %changes to that file, even if you recreate a file with the same name
161 in your working directory. If you do recreate a file with the same 167 %in your working directory. If you do recreate a file with the same
162 name and want Mercurial to track the new file, simply \hgcmd{add} it. 168 %name and want Mercurial to track the new file, simply \hgcmd{add} it.
163 Mercurial will know that the newly added file is not related to the 169 %Mercurial will know that the newly added file is not related to the
164 old file of the same name. 170 %old file of the same name.
171
172 $B0lEY%U%!%$%k$r(B\hgcmd{remove}$B$7$?8e$G$O!$(BMercurial$B$O%o!<%-%s%0%G%#%l%/%H%j(B
173 $BFb$K$?$H$(F1$8L>A0$G%U%!%$%k$,:F@8@.$5$l$F$b%U%!%$%k$X$NJQ99$rDI@W$7$J$$!%(B
174 $B%U%!%$%k$r:F@8@.$7!$(BMercurial$B$KDI@W$5$;$?$$$N$G$"$l$P!$(B\hgcmd{add}$B$r9T$&!%(B
175 Mercurial$B$O!$?75,$KDI2C$5$l$?%U%!%$%k$rF1L>$N8E$$%U%!%$%k$H4X78$J$/07$&!%(B
165 176
166 %\subsection{Removing a file does not affect its history} 177 %\subsection{Removing a file does not affect its history}
167 \subsection{$B%U%!%$%k:o=|$OMzNr$K1F6A$rM?$($J$$(B} 178 \subsection{$B%U%!%$%k:o=|$OMzNr$K1F6A$rM?$($J$$(B}
168 179
169 It is important to understand that removing a file has only two 180 %It is important to understand that removing a file has only two
170 effects. 181 %effects.
182 $B%U%!%$%k$N:o=|$,%j%]%8%H%j$KM?$($k1F6A$O(B2$B$D$N$_$G$"$k!%(B
171 \begin{itemize} 183 \begin{itemize}
172 \item It removes the current version of the file from the working 184 %\item It removes the current version of the file from the working
173 directory. 185 % directory.
174 \item It stops Mercurial from tracking changes to the file, from the 186 \item $B%o!<%-%s%0%G%#%l%/%H%j$+$i869F$N%P!<%8%g%s$N%U%!%$%k$r>C5n$9$k!%(B
175 time of the next commit. 187 %\item It stops Mercurial from tracking changes to the file, from the
188 % time of the next commit.
189 \item $B:o=|$9$k%U%!%$%k$X$NJQ99$r<!2s$N%3%_%C%H$+$i(BMercurial$B$,DI@W$7$J$$(B
190 $B$h$&$K$9$k!%(B
176 \end{itemize} 191 \end{itemize}
177 Removing a file \emph{does not} in any way alter the \emph{history} of 192 %Removing a file \emph{does not} in any way alter the \emph{history} of
178 the file. 193 %the file.
179 194 $B%U%!%$%k$r$I$N$h$&$K:o=|$7$F$b%U%!%$%k$N(B\emph{$BMzNr(B}$B$OJQ99(B\emph{$B$5$l$J$$(B}$B!%(B
180 If you update the working directory to a changeset in which a file 195
181 that you have removed was still tracked, it will reappear in the 196 %If you update the working directory to a changeset in which a file
182 working directory, with the contents it had when you committed that 197 %that you have removed was still tracked, it will reappear in the
183 changeset. If you then update the working directory to a later 198 %working directory, with the contents it had when you committed that
184 changeset, in which the file had been removed, Mercurial will once 199 %changeset. If you then update the working directory to a later
185 again remove the file from the working directory. 200 %changeset, in which the file had been removed, Mercurial will once
201 %again remove the file from the working directory.
202
203 $B%o!<%-%s%0%G%#%l%/%H%j$r!$>C5n$7$?%U%!%$%k$r4^$`%A%'%s%8%;%C%H$K99?7$9$k(B
204 $B$H!$%U%!%$%k$O$=$N%A%'%s%8%;%C%H$G$NFbMF$G:F$S%o!<%-%s%0%G%#%l%/%H%j$K8=(B
205 $B$l$k!%$=$3$G%U%!%$%k$,>C5n$5$l$F$$$k8e$N%A%'%s%8%;%C%H$K99?7$9$k(B
206 $B$H!$(BMercurial$B$O%U%!%$%k$r:F$S%o!<%-%s%0%G%#%l%/%H%j$+$i>C5n$9$k!%(B
186 207
187 %\subsection{Missing files} 208 %\subsection{Missing files}
188 \subsection{$B7gMn$7$?%U%!%$%k(B} 209 \subsection{$B7gMn$7$?%U%!%$%k(B}
189 210
190 Mercurial considers a file that you have deleted, but not used 211 %Mercurial considers a file that you have deleted, but not used
191 \hgcmd{remove} to delete, to be \emph{missing}. A missing file is 212 %\hgcmd{remove} to delete, to be \emph{missing}. A missing file is
192 represented with ``\texttt{!}'' in the output of \hgcmd{status}. 213 %represented with ``\texttt{!}'' in the output of \hgcmd{status}.
193 Mercurial commands will not generally do anything with missing files. 214 %Mercurial commands will not generally do anything with missing files.
215 %\interaction{daily.files.missing}
216
217 Mercurial$B$O!$(B\hgcmd{remove}$B$r;H$o$:$K>C5n$5$l$?%U%!%$%k$r(B\emph{$B7gMn(B}$B$7$?(B
218 $B%U%!%$%k$H$7$F07$&!%7gMn%U%!%$%k$O(B\hgcmd{status}$B%3%^%s%I$N=PNO$G(B
219 ``\texttt{!}''$B$HI=<($5$l$k!%(BMercurial$B$N%3%^%s%I$O!$DL>o!$7gMn$7$?%U%!%$(B
220 $B%k$K$O2?$b9T$o$J$$!%(B
194 \interaction{daily.files.missing} 221 \interaction{daily.files.missing}
195 222
196 If your repository contains a file that \hgcmd{status} reports as 223 %If your repository contains a file that \hgcmd{status} reports as
197 missing, and you want the file to stay gone, you can run 224 %missing, and you want the file to stay gone, you can run
198 \hgcmdargs{remove}{\hgopt{remove}{--after}} at any time later on, to 225 %\hgcmdargs{remove}{\hgopt{remove}{--after}} at any time later on, to
199 tell Mercurial that you really did mean to remove the file. 226 %tell Mercurial that you really did mean to remove the file.
227 %\interaction{daily.files.remove-after}
228
229 $B%j%]%8%H%jFb$G(B\hgcmd{status}$B%3%^%s%I$,7gMn$H%j%]!<%H$9$k%U%!%$%k$,$"$k>l(B
230 $B9g!$(B\hgcmdargs{remove}{\hgopt{remove}{--after}}$B$r<B9T$7$F!$(BMercurial$B$K7g(B
231 $BMn%U%!%$%k$,>C5n$5$l$?$b$N$G$"$k$3$H$r;X<($9$k$3$H$,$G$-$k!%(B
200 \interaction{daily.files.remove-after} 232 \interaction{daily.files.remove-after}
201 233
202 On the other hand, if you deleted the missing file by accident, use 234 %On the other hand, if you deleted the missing file by accident, use
203 \hgcmdargs{revert}{\emph{filename}} to recover the file. It will 235 %\hgcmdargs{revert}{\emph{filename}} to recover the file. It will
204 reappear, in unmodified form. 236 %reappear, in unmodified form.
237 %\interaction{daily.files.recover-missing}
238
239 $B0lJ}$G!$8m$C$F%U%!%$%k$r>C5n$7$?>l9g!$(B\hgcmdargs{revert}{\emph{filename}}$B$r(B
240 $B<B9T$9$k$3$H$G%U%!%$%k$r=$I|$9$k$3$H$,$G$-$k!%%U%!%$%k$O2?$bJQ99$5$l$J$$>uBV(B
241 $B$G=$I|$5$l$k!%(B
205 \interaction{daily.files.recover-missing} 242 \interaction{daily.files.recover-missing}
206 243
207 %\subsection{Aside: why tell Mercurial explicitly to remove a file?} 244 %\subsection{Aside: why tell Mercurial explicitly to remove a file?}
208 \subsection{$B$3$\$lOC(B: $B$J$<(BMercurial$B$X%U%!%$%k$N:o=|$rL@<(E*$K;X<($7$J$1(B 245 \subsection{$B$3$\$lOC(B: $B$J$<(BMercurial$B$X%U%!%$%k$N:o=|$rL@<(E*$K;X<($7$J$1(B
209 $B$l$P$J$i$J$$$+(B} 246 $B$l$P$J$i$J$$$+(B}
210 247
211 You might wonder why Mercurial requires you to explicitly tell it that 248 %You might wonder why Mercurial requires you to explicitly tell it that
212 you are deleting a file. Early during the development of Mercurial, 249 %you are deleting a file. Early during the development of Mercurial,
213 it let you delete a file however you pleased; Mercurial would notice 250 %it let you delete a file however you pleased; Mercurial would notice
214 the absence of the file automatically when you next ran a 251 %the absence of the file automatically when you next ran a
215 \hgcmd{commit}, and stop tracking the file. In practice, this made it 252 %\hgcmd{commit}, and stop tracking the file. In practice, this made it
216 too easy to accidentally remove a file without noticing. 253 %too easy to accidentally remove a file without noticing.
254
255 $B$J$<(BMercurial$B$K%U%!%$%k$N:o=|$rL@<(E*$K;X<($7$J$1$l$P$J$i$J$$$N$@$m$&$+!)(B
256 Mercurial$B$N3+H/$N=i4|$K$O!$%U%!%$%k$,$J$$$3$H$r8!CN$9$k$H!$<!$K(B
257 \hgcmd{commit}$B$,<B9T$5$l$k;~$K<+F0E*$K%U%!%$%k$NDI@W$r$d$a$F$$$?!%<B:]$K(B
258 $B;H$C$F$_$k$H$3$NF0:n$G$O%U%!%$%k$rCN$i$:$N$&$A$K<:$&$3$H$,IQH/$7$?$N$G$"(B
259 $B$k!%(B
217 260
218 %\subsection{Useful shorthand---adding and removing files in one step} 261 %\subsection{Useful shorthand---adding and removing files in one step}
219 \subsection{$BLr$KN)$D4JN,K!(B---$B%U%!%$%k$NDI2C$H:o=|$r(B1$B%9%F%C%W$G9T$&(B} 262 \subsection{$BLr$KN)$D4JN,K!(B---$B%U%!%$%k$NDI2C$H:o=|$r(B1$B%9%F%C%W$G9T$&(B}
220 263
221 Mercurial offers a combination command, \hgcmd{addremove}, that adds 264 %Mercurial offers a combination command, \hgcmd{addremove}, that adds
222 untracked files and marks missing files as removed. 265 %untracked files and marks missing files as removed.
266 %\interaction{daily.files.addremove}
267 %The \hgcmd{commit} command also provides a \hgopt{commit}{-A} option
268 %that performs this same add-and-remove, immediately followed by a
269 %commit.
270 %\interaction{daily.files.commit-addremove}
271
272 Mercurial$B$O(B\hgcmd{addremove}$B$H$$$&AH$_9g$o$;%3%^%s%I$r;}$C$F$$$k!%$3$N%3(B
273 $B%^%s%I$ODI@W$5$l$F$$$J$$%U%!%$%k72$rDI2C$7!$7gMn$7$F$$$k%U%!%$%k$r>C5n$5(B
274 $B$l$?$H%^!<%/$9$k!%(B
223 \interaction{daily.files.addremove} 275 \interaction{daily.files.addremove}
224 The \hgcmd{commit} command also provides a \hgopt{commit}{-A} option 276 \hgcmd{commit}$B%3%^%s%I$K$O(B\hgopt{commit}{-A}$B%*%W%7%g%s$,$"$j!$F1$8DI2C$H(B
225 that performs this same add-and-remove, immediately followed by a 277 $B:o=|$NA`:n$r%3%_%C%HD>8e$K9T$&!%(B
226 commit.
227 \interaction{daily.files.commit-addremove} 278 \interaction{daily.files.commit-addremove}
228 279
229 %\section{Copying files} 280 %\section{Copying files}
230 \section{$B%U%!%$%k$N%3%T!<(B} 281 \section{$B%U%!%$%k$N%3%T!<(B}
231 282
241 $BJQ99$r%^!<%8$9$k;~$KFCJL$J<h$j07$$$,$J$5$l$k!%(B 292 $BJQ99$r%^!<%8$9$k;~$KFCJL$J<h$j07$$$,$J$5$l$k!%(B
242 293
243 %\subsection{The results of copying during a merge} 294 %\subsection{The results of copying during a merge}
244 \subsection{$B%^!<%8Cf$N%3%T!<$N7k2L(B} 295 \subsection{$B%^!<%8Cf$N%3%T!<$N7k2L(B}
245 296
246 What happens during a merge is that changes ``follow'' a copy. To 297 %What happens during a merge is that changes ``follow'' a copy. To
247 best illustrate what this means, let's create an example. We'll start 298 %best illustrate what this means, let's create an example. We'll start
248 with the usual tiny repository that contains a single file. 299 %with the usual tiny repository that contains a single file.
300 %\interaction{daily.copy.init}
301 %We need to do some work in parallel, so that we'll have something to
302 %merge. So let's clone our repository.
303 %\interaction{daily.copy.clone}
304 %Back in our initial repository, let's use the \hgcmd{copy} command to
305 %make a copy of the first file we created.
306 %\interaction{daily.copy.copy}
307
308 $B%^!<%8Cf$K$O!$%3%T!<$K(B``$B=>$&(B''$B$3$H$,5/$-$k!%$3$l$N0UL#$9$k$H$3$m$r<($9$?(B
309 $B$a$K!$Nc$r5s$2$k$3$H$K$9$k!%$$$D$b$N$h$&$K!$%U%!%$%k(B1$B$D$@$1$r4^$`>.$5$J%j(B
310 $B%]%8%H%j$r:n@.$9$k!%(B
249 \interaction{daily.copy.init} 311 \interaction{daily.copy.init}
250 We need to do some work in parallel, so that we'll have something to 312 $B%^!<%8$9$Y$-FbMF$r:n$k$?$a$KJB9T$7$F$$$/$D$+$N:n6H$r9T$&I,MW$,$"$k$N$G!$(B
251 merge. So let's clone our repository. 313 $B%j%]%8%H%j$N%/%m!<%s$r9T$&!%(B
252 \interaction{daily.copy.clone} 314 \interaction{daily.copy.clone}
253 Back in our initial repository, let's use the \hgcmd{copy} command to 315 $B:G=i$N%j%]%8%H%j$KLa$C$F!$(B\hgcmd{copy}$B%3%^%s%I$r;H$C$F!$:n@.$7$?%U%!%$%k(B
254 make a copy of the first file we created. 316 $B$N%3%T!<$r9T$&!%(B
255 \interaction{daily.copy.copy} 317 \interaction{daily.copy.copy}
256 318
257 If we look at the output of the \hgcmd{status} command afterwards, the 319 %If we look at the output of the \hgcmd{status} command afterwards, the
258 copied file looks just like a normal added file. 320 %copied file looks just like a normal added file.
321 %\interaction{daily.copy.status}
322 %But if we pass the \hgopt{status}{-C} option to \hgcmd{status}, it
323 %prints another line of output: this is the file that our newly-added
324 %file was copied \emph{from}.
325 %\interaction{daily.copy.status-copy}
326
327 $B$=$N8e$G(B\hgcmd{status}$B%3%^%s%I$N=PNO$r8+$k$H%3%T!<$5$l$?%U%!%$%k$ODL>oDL(B
328 $B$j$KDI2C$5$l$?%U%!%$%k$H$7$F8+$($k!%(B
259 \interaction{daily.copy.status} 329 \interaction{daily.copy.status}
260 But if we pass the \hgopt{status}{-C} option to \hgcmd{status}, it 330 $B$7$+$7(B\hgcmd{status}$B%3%^%s%I$K(B\hgopt{status}{-C}$B%*%W%7%g%s$rEO$9$H!$?7$?(B
261 prints another line of output: this is the file that our newly-added 331 $B$KDI2C$5$l$?%U%!%$%k$,(B\emph{$B$I$N(B}$B%U%!%$%k$+$i%3%T!<$5$l$?$N$+$r<($99T$,(B
262 file was copied \emph{from}. 332 $B=PNO$5$l$k!%(B
263 \interaction{daily.copy.status-copy} 333 \interaction{daily.copy.status-copy}
264 334
265 Now, back in the repository we cloned, let's make a change in 335 %Now, back in the repository we cloned, let's make a change in
266 parallel. We'll add a line of content to the original file that we 336 %parallel. We'll add a line of content to the original file that we
267 created. 337 %created.
338 %\interaction{daily.copy.other}
339 %Now we have a modified \filename{file} in this repository. When we
340 %pull the changes from the first repository, and merge the two heads,
341 %Mercurial will propagate the changes that we made locally to
342 %\filename{file} into its copy, \filename{new-file}.
343 %\interaction{daily.copy.merge}
344
345 $B$3$3$G%/%m!<%s$7$?%j%]%8%H%j$K$bJQ99$r2C$($k!%:n@.$7$?%U%!%$%k$K0l9T$rDI(B
346 $B2C$9$k!%(B
268 \interaction{daily.copy.other} 347 \interaction{daily.copy.other}
269 Now we have a modified \filename{file} in this repository. When we 348 $B$3$l$G$3$N%j%]%8%H%j$K$bJQ99$5$l$?(B\filename{file}$B$,B8:_$9$k$3$H$K$J(B
270 pull the changes from the first repository, and merge the two heads, 349 $B$k!%$3$3$G:G=i$N%j%]%8%H%j$+$iJQ99$r(Bpull$B$7!$(B2$B$D$N(Bhead$B$r%^!<%8$9$k$H(B
271 Mercurial will propagate the changes that we made locally to 350 Mercurial$B$O%m!<%+%k$J(B\filename{file}$B$KBP$9$kJQ99$r$=$N%3%T!<(B
272 \filename{file} into its copy, \filename{new-file}. 351 \filename{new-file}$B$KGH5Z$5$;$k!%(B
273 \interaction{daily.copy.merge} 352 \interaction{daily.copy.merge}
274 353
275 %\subsection{Why should changes follow copies?} 354 %\subsection{Why should changes follow copies?}
276 \subsection{$BJQ99$O$J$<%3%T!<$K=>$o$J$1$l$P$J$i$J$$$+(B} 355 \subsection{$BJQ99$O$J$<%3%T!<$K=>$o$J$1$l$P$J$i$J$$$+(B}
277 \label{sec:daily:why-copy} 356 \label{sec:daily:why-copy}
278 357
279 This behaviour, of changes to a file propagating out to copies of the 358 %This behaviour, of changes to a file propagating out to copies of the
280 file, might seem esoteric, but in most cases it's highly desirable. 359 %file, might seem esoteric, but in most cases it's highly desirable.
281 360
282 First of all, remember that this propagation \emph{only} happens when 361 $B%U%!%$%k$X$NJQ99$,$=$N%3%T!<$XGH5Z$9$kF0:n$OFq2r$K;W$($k$+$b$7$J$$$,!$B?(B
283 you merge. So if you \hgcmd{copy} a file, and subsequently modify the 362 $B$/$N>l9g$OHs>o$KK>$^$7$$F0:n$G$"$k!%(B
284 original file during the normal course of your work, nothing will 363
285 happen. 364 %First of all, remember that this propagation \emph{only} happens when
286 365 %you merge. So if you \hgcmd{copy} a file, and subsequently modify the
287 The second thing to know is that modifications will only propagate 366 %original file during the normal course of your work, nothing will
288 across a copy as long as the repository that you're pulling changes 367 %happen.
289 from \emph{doesn't know} about the copy. 368
290 369 $B$^$:Bh0l$K$3$NGH5Z$O%^!<%8$r9T$&$H$-$K(B\emph{$B$N$_(B}$BH/@8$9$k!%=>$C$F%U%!%$%k(B
291 The reason that Mercurial does this is as follows. Let's say I make 370 $B$r(B\hgcmd{copy}$B$9$k>l9g$d!$DL>o$N:n6H$G%*%j%8%J%k%U%!%$%k$rJQ99$9$k>l9g$O(B
292 an important bug fix in a source file, and commit my changes. 371 $B2?$b5/$-$J$$!%(B
293 Meanwhile, you've decided to \hgcmd{copy} the file in your repository, 372
294 without knowing about the bug or having seen the fix, and you have 373 %The second thing to know is thatmodifications will only propagate
295 started hacking on your copy of the file. 374 %across a copy as long as the repository that you're pulling changes
296 375 %from \emph{doesn't know} about the copy.
297 If you pulled and merged my changes, and Mercurial \emph{didn't} 376
298 propagate changes across copies, your source file would now contain 377 $BCN$C$F$*$/$Y$-E@$N(B2$B$DL\$O!$JQ99$r(Bpull$B$9$k%j%]%8%H%j$,!$%3%T!<$K$D$$$F(B
299 the bug, and unless you remembered to propagate the bug fix by hand, 378 \emph{$B4XCN$7$J$$(B}$B8B$j!$JQ99$OGH5Z$9$k$H$$$&$3$H$G$"$k!%(B
300 the bug would \emph{remain} in your copy of the file. 379
301 380 %The reason that Mercurial does this is as follows. Let's say I make
302 By automatically propagating the change that fixed the bug from the 381 %an important bug fix in a source file, and commit my changes.
303 original file to the copy, Mercurial prevents this class of problem. 382 %Meanwhile, you've decided to \hgcmd{copy} the file in your repository,
304 To my knowledge, Mercurial is the \emph{only} revision control system 383 %without knowing about the bug or having seen the fix, and you have
305 that propagates changes across copies like this. 384 %started hacking on your copy of the file.
306 385
307 Once your change history has a record that the copy and subsequent 386 Mercurial$B$,$3$N$h$&$KF0:n$9$kM}M3$r@bL@$9$k!%:#!$;d$,=EMW$J%P%0=$@5$r(B1$B$D(B
308 merge occurred, there's usually no further need to propagate changes 387 $B$N%=!<%9%U%!%$%k$K$D$$$F9T$$!$JQ99$r%3%_%C%H$7$?$H$9$k!%$=$N4V!$$"$J$?$O(B
309 from the original file to the copied file, and that's why Mercurial 388 $B<+J,$N%j%]%8%H%j$NCf$G!$$=$N%P%0$"$k$$$O=$@5$rCN$i$:!$$=$N%U%!%$%k$N(B
310 only propagates changes across copies until this point, and no 389 \hgcmd{copy}$B$r9T$$!$%U%!%$%k$NJQ99$r;O$a$?$H$9$k!%(B
311 further. 390
391 %If you pulled and merged my changes, and Mercurial \emph{didn't}
392 %propagate changes across copies, your source file would now contain
393 %the bug, and unless you remembered to propagate the bug fix by hand,
394 %the bug would \emph{remain} in your copy of the file.
395
396 $B$"$J$?$,;d$N9T$C$?JQ99$r(Bpull$B$7!$(Bmerge$B$7$?>l9g!$(BMercurial$B$OJQ99$r%3%T!<4V(B
397 $B$GGH5Z$5$;$J$$!%$"$J$?$N%=!<%9%U%!%$%k:#%P%0$r;}$C$F$$$k$+$b$7$l$J$$$,!$(B
398 $B%P%0=$@5$r<j$GGH5Z$5$;$J$1$l$P%P%0$O%U%!%$%k$N%3%T!<$K(B\emph{$B;D$k(B}$B!%(B
399
400 %By automatically propagating the change that fixed the bug from the
401 %original file to the copy, Mercurial prevents this class of problem.
402 %To my knowledge, Mercurial is the \emph{only} revision control system
403 %that propagates changes across copies like this.
404
405 $B%P%0$r=$@5$9$kJQ99$r<+F0E*$K%*%j%8%J%k%U%!%$%k$+$i%3%T!<$XGH5Z$5$;$k$3$H(B
406 $B$K$h$C$F!$(BMercurial$B$O$3$NN`$NLdBj$rHr$1$F$$$k!%;d$NCN$k8B(B
407 $B$j!$(BMercurial$B$O!$$3$N$h$&$J%3%T!<4V$GJQ99$rGH5Z$5$;$kM#0l$N%j%S%8%g%s%3%s(B
408 $B%H%m!<%k%7%9%F%`$G$"$k!%(B
409
410 %Once your change history has a record that the copy and subsequent
411 %merge occurred, there's usually no further need to propagate changes
412 %from the original file to the copied file, and that's why Mercurial
413 %only propagates changes across copies until this point, and no
414 %further.
415
416 $B%3%T!<$H8eB3$N%^!<%8$,5/$3$C$?$3$H$,99?7MzNr$K4^$^$l$k>l9g!$JQ99$r%*%j%8(B
417 $B%J%k%U%!%$%k$+$i%3%T!<$5$l$?%U%!%$%k$X$5$i$KGH5Z$5$;$kI,MW$O$J$$!%$3$l$,(B
418 Mercurial$B$,$3$N;~E@$^$G$N$_JQ99$r%3%T!<4V$GGH5Z$5$;!$$=$N8e$G$O9T$o$J$$M}(B
419 $BM3$G$"$k!%(B
312 420
313 %\subsection{How to make changes \emph{not} follow a copy} 421 %\subsection{How to make changes \emph{not} follow a copy}
314 \subsection{$BJQ99$,%3%T!<$K$7B&FbMF$K$9$kJ}K!(B} 422 \subsection{$BJQ99$,%3%T!<$K=>$o$J$$$h$&$K$9$kJ}K!(B}
315 423
316 If, for some reason, you decide that this business of automatically 424 %If, for some reason, you decide that this business of automatically
317 propagating changes across copies is not for you, simply use your 425 %propagating changes across copies is not for you, simply use your
318 system's normal file copy command (on Unix-like systems, that's 426 %system's normal file copy command (on Unix-like systems, that's
319 \command{cp}) to make a copy of a file, then \hgcmd{add} the new copy 427 %\command{cp}) to make a copy of a file, then \hgcmd{add} the new copy
320 by hand. Before you do so, though, please do reread 428 %by hand. Before you do so, though, please do reread
321 section~\ref{sec:daily:why-copy}, and make an informed decision that 429 %section~\ref{sec:daily:why-copy}, and make an informed decision that
322 this behaviour is not appropriate to your specific case. 430 %this behaviour is not appropriate to your specific case.
431
432 $B2?$i$+$NM}M3$G$3$N$h$&$KJQ99$,<+F0E*$KGH5Z$9$k$d$jJ}$,9%$^$7$/$J$$$H;W$o(B
433 $B$l$k>l9g$O!$%7%9%F%`I8=`$N$"%U%!%$%k%3%T!<%3%^%s%I!J(BUNIX$B7O%7%9%F%`$G$O(B
434 \command{cp}$B!K$r;H$C$F%U%!%$%k$N%3%T!<$r9T$$!$(B\hgcmd{add}$B$G?7$7$$%3%T!<$r(B
435 $B<jF0$GDI2C$9$k$3$H$,$G$-$k!%$3$l$r<B:]$K9T$&A0(B
436 $B$K!$(B~\ref{sec:daily:why-copy}$B@a$r:FFI$7!$$3$N$d$jJ}$N>\:Y$rF'$^$($?>e$G!$(B
437 $B$"$J$?$N%1!<%9$KE,$7$F$$$k$+H=CG$7$F$[$7$$!%(B
323 438
324 %\subsection{Behaviour of the \hgcmd{copy} command} 439 %\subsection{Behaviour of the \hgcmd{copy} command}
325 \subsection{\hgcmd{copy}$B%3%^%s%I$N5sF0(B} 440 \subsection{\hgcmd{copy}$B%3%^%s%I$N5sF0(B}
326 441
327 When you use the \hgcmd{copy} command, Mercurial makes a copy of each 442 %When you use the \hgcmd{copy} command, Mercurial makes a copy of each
328 source file as it currently stands in the working directory. This 443 %source file as it currently stands in the working directory. This
329 means that if you make some modifications to a file, then \hgcmd{copy} 444 %means that if you make some modifications to a file, then \hgcmd{copy}
330 it without first having committed those changes, the new copy will 445 %it without first having committed those changes, the new copy will
331 also contain the modifications you have made up until that point. (I 446 %also contain the modifications you have made up until that point. (I
332 find this behaviour a little counterintuitive, which is why I mention 447 %find this behaviour a little counterintuitive, which is why I mention
333 it here.) 448 %it here.)
334 449
335 The \hgcmd{copy} command acts similarly to the Unix \command{cp} 450 \hgcmd{copy}$B%3%^%s%I$r;H$&;~!$(BMercurial$B$O%o!<%-%s%0%G%#%l%/%H%jFb$N%U%!%$(B
336 command (you can use the \hgcmd{cp} alias if you prefer). The last 451 $B%k$r$=$N;~E@$N>uBV$G%3%T!<$9$k!%$9$J$o$A!$%U%!%$%k$K2?$i$+$NJQ99$r2C$(!$(B
337 argument is the \emph{destination}, and all prior arguments are 452 $BJQ99$N%3%_%C%H$r$;$:$K(B\hgcmd{copy}$B$r9T$&$H!$?7$?$J%3%T!<$b$=$N;~E@$^$G$K(B
338 \emph{sources}. If you pass it a single file as the source, and the 453 $B2C$($?JQ99$r4^$s$G$$$k!%(B $B!JI.<T$O$3$N5sF0$O$d$dD>4Q$KH?$9$k$H9M$($F$$$k$?(B
339 destination does not exist, it creates a new file with that name. 454 $B$a!$4:$($F$3$3$G8@5Z$7$?!%!K(B
455
456 %The \hgcmd{copy} command acts similarly to the Unix \command{cp}
457 %command (you can use the \hgcmd{cp} alias if you prefer). The last
458 %argument is the \emph{destination}, and all prior arguments are
459 %\emph{sources}. If you pass it a single file as the source, and the
460 %destination does not exist, it creates a new file with that name.
461 %\interaction{daily.copy.simple}
462 %If the destination is a directory, Mercurial copies its sources into
463 %that directory.
464 %\interaction{daily.copy.dir-dest}
465 %Copying a directory is recursive, and preserves the directory
466 %structure of the source.
467 %\interaction{daily.copy.dir-src}
468 %If the source and destination are both directories, the source tree is
469 %recreated in the destination directory.
470 %\interaction{daily.copy.dir-src-dest}
471
472 \hgcmd{copy}$B%3%^%s%I$O(BUnix$B$N(B\command{cp}$B$HF1MM$K?6Iq$&!%!J(B\hgcmd{cp}$B%(%$(B
473 $B%j%"%9$rDj5A$7$F;H$&$3$H$b2DG=$@!%!K0z?t$N:G8e$O(B\emph{$B%3%T!<@h(B}$B$G!$$=$l0J(B
474 $BA0$N0z?t$O(B\emph{$B%3%T!<85(B}$B$G$"$k!%%3%T!<85$H$7$FC10l$N%U%!%$%k$r;XDj$7!$%3(B
475 $B%T!<@h%U%!%$%k$,B8:_$7$J$$>l9g!$%3%^%s%I$O%3%T!<@h%U%!%$%k$r?75,$K:n@.$9(B
476 $B$k!%(B
340 \interaction{daily.copy.simple} 477 \interaction{daily.copy.simple}
341 If the destination is a directory, Mercurial copies its sources into 478 $B%3%T!<@h$,%G%#%l%/%H%j$N>l9g!$(BMercurial$B$O%3%T!<85$r%3%T!<@h%G%#%l%/%H%j(B
342 that directory. 479 $B$NCf$K%3%T!<$9$k!%(B
343 \interaction{daily.copy.dir-dest} 480 \interaction{daily.copy.dir-dest}
344 Copying a directory is recursive, and preserves the directory 481 $B%G%#%l%/%H%j$N%3%T!<$O:F5"E*$G!$%3%T!<85$N%G%#%l%/%H%j9=B$$rJ]$D!%(B
345 structure of the source.
346 \interaction{daily.copy.dir-src} 482 \interaction{daily.copy.dir-src}
347 If the source and destination are both directories, the source tree is 483 $B%3%T!<85$H%3%T!<@h$,6&$K%G%#%l%/%H%j$N>l9g!$%3%T!<85$N%D%j!<9=B$$,%3%T!<(B
348 recreated in the destination directory. 484 $B@h$N%G%#%l%/%H%j$NCf$K:F8=$5$l$k!%(B
349 \interaction{daily.copy.dir-src-dest} 485 \interaction{daily.copy.dir-src-dest}
350 486
351 As with the \hgcmd{rename} command, if you copy a file manually and 487 %As with the \hgcmd{rename} command, if you copy a file manually and
352 then want Mercurial to know that you've copied the file, simply use 488 %then want Mercurial to know that you've copied the file, simply use
353 the \hgopt{copy}{--after} option to \hgcmd{copy}. 489 %the \hgopt{copy}{--after} option to \hgcmd{copy}.
490 %\interaction{daily.copy.after}
491
492 \hgcmd{rename}$B%3%^%s%I$HF1MM$K!$%U%!%$%k$r<jF0$G%3%T!<$7$?8e$G!$(BMercurial$B$K(B
493 $BA`:n$rDLCN$7$?$$>l9g$O!$(B\hgcmd{copy}$B%3%^%s%I$K(B\hgopt{copy}{--after}$B%*%W(B
494 $B%7%g%s$rIU$1$l$P$h$$!%(B
354 \interaction{daily.copy.after} 495 \interaction{daily.copy.after}
355 496
356 %\section{Renaming files} 497 %\section{Renaming files}
357 \section{$B%U%!%$%k$N%j%M!<%`(B} 498 \section{$B%U%!%$%k$N%j%M!<%`(B}
358 499
359 It's rather more common to need to rename a file than to make a copy 500 %It's rather more common to need to rename a file than to make a copy
360 of it. The reason I discussed the \hgcmd{copy} command before talking 501 %of it. The reason I discussed the \hgcmd{copy} command before talking
361 about renaming files is that Mercurial treats a rename in essentially 502 %about renaming files is that Mercurial treats a rename in essentially
362 the same way as a copy. Therefore, knowing what Mercurial does when 503 %the same way as a copy. Therefore, knowing what Mercurial does when
363 you copy a file tells you what to expect when you rename a file. 504 %you copy a file tells you what to expect when you rename a file.
364 505
365 When you use the \hgcmd{rename} command, Mercurial makes a copy of 506 $B%U%!%$%k$r%j%M!<%`$9$k$3$H$O%U%!%$%k$N%3%T!<$h$j$b$h$/9T$o$l$k!%%U%!%$%k(B
366 each source file, then deletes it and marks the file as removed. 507 $B$N%j%M!<%`$h$j$bA0$K(B\hgcmd{copy}$B$K$D$$$F=R$Y$?M}M3$O!$(B Mercurial$B$,K\<AE*(B
508 $B$K%j%M!<%`$r%3%T!<$HF1MM$K07$&$+$i$G$"$k!%=>$C$F!$%U%!%$%k$r%3%T!<$9$k;~(B
509 $B$K(BMercurial$B$,9T$&$3$H$rCN$k$3$H$O!$%j%M!<%`$N:]$K5/$3$k$3$H$rCN$k$3$H$K$J(B
510 $B$k!%(B
511
512 %When you use the \hgcmd{rename} command, Mercurial makes a copy of
513 %each source file, then deletes it and marks the file as removed.
514 %\interaction{daily.rename.rename}
515 %The \hgcmd{status} command shows the newly copied file as added, and
516 %the copied-from file as removed.
517 %\interaction{daily.rename.status}
518
519 \hgcmd{rename}$B%3%^%s%I$r;H$&;~!$(BMercurial$B$O3F!9$N%=!<%9%U%!%$%k$r%3%T!<(B
520 $B$7!$85$N%U%!%$%k$r:o=|$7$F!$>C5n:Q$_$H%^!<%/$9$k!%(B
367 \interaction{daily.rename.rename} 521 \interaction{daily.rename.rename}
368 The \hgcmd{status} command shows the newly copied file as added, and 522 \hgcmd{status}$B%3%^%s%I$O?7$?$K%3%T!<$5$l$?%U%!%$%k$rDI2C$5$l$?%U%!%$%k$H(B
369 the copied-from file as removed. 523 $B$7$FI=<($7!$%3%T!<$5$l$?%U%!%$%k$r>C5n$5$l$?%U%!%$%k$HI=<($9$k!%(B
370 \interaction{daily.rename.status} 524 \interaction{daily.rename.status}
371 As with the results of a \hgcmd{copy}, we must use the 525
372 \hgopt{status}{-C} option to \hgcmd{status} to see that the added file 526 %As with the results of a \hgcmd{copy}, we must use the
373 is really being tracked by Mercurial as a copy of the original, now 527 %\hgopt{status}{-C} option to \hgcmd{status} to see that the added file
374 removed, file. 528 %is really being tracked by Mercurial as a copy of the original, now
529 %removed, file.
530 %\interaction{daily.rename.status-copy}
531
532 \hgcmd{copy}$B%3%^%s%I$N>l9g$HF1MM$K!$(B \hgcmd{status}$B%3%^%s%I$K(B
533 \hgopt{status}{-C}$B%*%W%7%g%s$rMQ$$$F!$DI2C$5$l$?%U%!%$%k$,>C5n$5$l$?%*%j(B
534 $B%8%J%k%U%!%$%k$N%3%T!<$H$7$F(BMercurial$B$KDI@W$5$l$F$$$k$N$+$rD4$Y$k$3$H$,$G(B
535 $B$-$k!%(B
375 \interaction{daily.rename.status-copy} 536 \interaction{daily.rename.status-copy}
376 537
377 As with \hgcmd{remove} and \hgcmd{copy}, you can tell Mercurial about 538 %As with \hgcmd{remove} and \hgcmd{copy}, you can tell Mercurial about
378 a rename after the fact using the \hgopt{rename}{--after} option. In 539 %a rename after the fact using the \hgopt{rename}{--after} option. In
379 most other respects, the behaviour of the \hgcmd{rename} command, and 540 %most other respects, the behaviour of the \hgcmd{rename} command, and
380 the options it accepts, are similar to the \hgcmd{copy} command. 541 %the options it accepts, are similar to the \hgcmd{copy} command.
542
543 \hgcmd{remove}$B$H(B\hgcmd{copy}$B$N$h$&$K!$(B\hgopt{rename}{--after}$B%*%W%7%g%s$r(B
544 $B;H$&$3$H$G!$;v8e$K%j%M!<%`$r$9$k$3$H$,$G$-$k!%B?$/$NE@$G(B\hgcmd{rename}$B%3(B
545 $B%^%s%I$N5sF0$H!$$3$N%3%^%s%I$,<u$1F~$l$k%*%W%7%g%s$O(B\hgcmd{copy}$B%3%^%s%I(B
546 $B$HN`;w$7$F$$$k!%(B
381 547
382 %\subsection{Renaming files and merging changes} 548 %\subsection{Renaming files and merging changes}
383 \subsection{$B%U%!%$%k$N%j%M!<%`$HJQ99$N%^!<%8(B} 549 \subsection{$B%U%!%$%k$N%j%M!<%`$HJQ99$N%^!<%8(B}
384 550
385 %Since Mercurial's rename is implemented as copy-and-remove, the same 551 %Since Mercurial's rename is implemented as copy-and-remove, the same