Mercurial > hgbook
comparison en/daily.tex @ 156:91a936be78b8
Document merge behaviour with file names.
author | Bryan O'Sullivan <bos@serpentine.com> |
---|---|
date | Mon, 12 Mar 2007 23:11:26 -0700 |
parents | 9094c9fda8ec |
children | 1b55292716a4 |
comparison
equal
deleted
inserted
replaced
155:914babdc99c8 | 156:91a936be78b8 |
---|---|
301 | 301 |
302 Since Mercurial's rename is implemented as copy-and-remove, the same | 302 Since Mercurial's rename is implemented as copy-and-remove, the same |
303 propagation of changes happens when you merge after a rename as after | 303 propagation of changes happens when you merge after a rename as after |
304 a copy. | 304 a copy. |
305 | 305 |
306 If I modify a file, and you rename it to a new name, then we merge our | 306 If I modify a file, and you rename it to a new name, and then we merge |
307 respective changes, my modifications to the file under its original | 307 our respective changes, my modifications to the file under its |
308 name will be propagated into the file under its new name. (This is | 308 original name will be propagated into the file under its new name. |
309 something you might expect to ``simply work,'' but not all revision | 309 (This is something you might expect to ``simply work,'' but not all |
310 control systems actually do this.) | 310 revision control systems actually do this.) |
311 | 311 |
312 Whereas having changes follow a copy is a feature where you can | 312 Whereas having changes follow a copy is a feature where you can |
313 perhaps nod and say ``yes, that might be useful,'' it should be clear | 313 perhaps nod and say ``yes, that might be useful,'' it should be clear |
314 that having them follow a rename is definitely important. Without | 314 that having them follow a rename is definitely important. Without |
315 this facility, it would simply be too easy for changes to become | 315 this facility, it would simply be too easy for changes to become |
316 orphaned when files are renamed. | 316 orphaned when files are renamed. |
317 | 317 |
318 \subsection{Divergent renames and merging} | |
319 | |
320 The case of diverging names occurs when two developers start with a | |
321 file---let's call it \filename{foo}---in their respective | |
322 repositories. | |
323 | |
324 \interaction{rename.divergent.clone} | |
325 Anne renames the file to \filename{bar}. | |
326 \interaction{rename.divergent.rename.anne} | |
327 Meanwhile, Bob renames it to \filename{quux}. | |
328 \interaction{rename.divergent.rename.bob} | |
329 | |
330 I like to think of this as a conflict because each developer has | |
331 expressed different intentions about what the file ought to be named. | |
332 | |
333 What do you think should happen when they merge their work? | |
334 Mercurial's actual behaviour is that it always preserves \emph{both} | |
335 names when it merges changesets that contain divergent renames. | |
336 \interaction{rename.divergent.merge} | |
337 | |
338 I personally find this behaviour quite surprising, which is why I | |
339 wanted to explicitly mention it here. I would have expected Mercurial | |
340 to prompt me with a three-way choice instead: do I want to keep only | |
341 \filename{bar}, only \filename{quux}, or both? | |
342 | |
343 In practice, when you rename a source file, it is likely that you will | |
344 also modify another file (such as a makefile) that knows how to build | |
345 the source file. So what will happen if Anne renames a file and edits | |
346 \filename{Makefile} to build it under its new name, while Bob does the | |
347 same, but chooses a different name for the file, is that after the | |
348 merge, there will be two copies of the source file in the working | |
349 directory under different names, \emph{and} a conflict in the section | |
350 of the \filename{Makefile} that both Bob and Anne edited. | |
351 | |
352 This behaviour is considered surprising by other people, too: | |
353 see~\bug{455} for details. | |
354 | |
355 \subsection{Convergent renames and merging} | |
356 | |
357 Another kind of rename conflict occurs when two people choose to | |
358 rename different \emph{source} files to the same \emph{destination}. | |
359 In this case, Mercurial runs its normal merge machinery, and lets you | |
360 guide it to a suitable resolution. | |
361 | |
362 \subsection{Other name-related corner cases} | |
363 | |
364 Mercurial has a longstanding bug in which it fails to handle a merge | |
365 where one side has a file with a given name, while another has a | |
366 directory with the same name. This is documented as~\bug{29}. | |
367 \interaction{issue29.go} | |
318 | 368 |
319 %%% Local Variables: | 369 %%% Local Variables: |
320 %%% mode: latex | 370 %%% mode: latex |
321 %%% TeX-master: "00book" | 371 %%% TeX-master: "00book" |
322 %%% End: | 372 %%% End: |