<p>I have been hearing a lot of good things about DVCS systems, in particular about bazaar. Apart from the concept of distributed repository, I see two main advantages being touted: the merge is better automated, and the rename is handled right.</p>

<p>Could someone please point me at some text explaining how exactly the improvements work? How does bazaar know that I renamed a file? What if I rename two files as part of the same commit? What happens when I refactor by putting half of the file's contents into a new file, re-indenting everything and losing some whitespace in nearly every line?</p>

<p>In other words, I'd like to hear from people using bazaar (or another DVCS) in real life, or from people who know how it (they) works. Is the merge really that much better? And how is it achieved?</p>

<hr>

<p>Related question, with a useful answer:</p>

<p><a href="https://stackoverflow.com/questions/43995/why-is-branching-and-merging-easier-in-mercurial-than-in-subversion">Why is branching and merging easier in Mercurial than in Subversion?</a></p>

[{'answer_id': 46296, 'author': 'Kyle Cronin', 'author_id': 658, 'author_profile': 'https://Stackoverflow.com/users/658', 'pm_score': 0, 'selected': False, 'text': "<p>I'm not familiar with bazaar, but git doesn't track file renames. To git, this looks like a delete and an add. However, git is smart enough to see that the contents of the file already exist in its repository and will track their position in the system. If you split files up or merge them it's smart enough to keep track of segments of code (blobs) and store that information too.</p>\n"}, {'answer_id': 46544, 'author': 'John Millikin', 'author_id': 3560, 'author_profile': 'https://Stackoverflow.com/users/3560', 'pm_score': 2, 'selected': False, 'text': '<p>DVCS achieve better merges by tracking the parent revisions of merges. In Subversion, when you merge one branch into another, you lose information about where the merge originated from. In a DVCS like Bazaar or Git, the "merged" revision ends up with two parent revisions.</p>\n\n<p>Renaming is handled differently between DVCS\'s. Git, for example, does not track renaming at all because it wasn\'t important to Linus. Mercurial records them as "copy old file to new, delete old". <a href="http://www.markshuttleworth.com/archives/123" rel="nofollow noreferrer">According to Mark Shuttleworth</a>, founder of Canonical, Darcs and Bazaar are the only DVCS\'s that handle file renaming correctly.</p>\n\n<blockquote>\n  <p>How does bazaar know that I renamed a file?</p>\n</blockquote>\n\n<p>Renames are specified by the user, just like adding or removing files. Use the "<code>bzr rename &lt;old&gt; &lt;new&gt;</code>" command to mark files or directories for renaming. If you\'ve already renamed a file in the tree, you can use the "<code>--after</code>" option.</p>\n\n<blockquote>\n  <p>What if I rename two files as part of the same commit?</p>\n</blockquote>\n\n<p>Then you type "<code>bzr rename &lt;old&gt; &lt;new&gt;</code>" once for each file. Bazaar doesn\'t try to guess which files have been renamed.</p>\n\n<blockquote>\n  <p>What happens when I refactor by putting half of the file\'s contents into a new file, re-indenting everything and losing some whitespace in nearly every line?</p>\n</blockquote>\n\n<p>Then you type "<code>bzr add</code>" on the new file, since you\'re not really renaming it.</p>\n'}, {'answer_id': 71406, 'author': 'David Cournapeau', 'author_id': 11465, 'author_profile': 'https://Stackoverflow.com/users/11465', 'pm_score': 3, 'selected': True, 'text': '<p>Merge is not intrinsically better in DVCS, it is just that they would be practically very difficult to use if the branch/merge did not work correctly (svn arguably does not implement branching/merging correctly), because instead of making a checkout, you are making a new branch everytime you start working on a project from an existing code. I think some proprietary, centralized SCS do handle merge/branch correctly.</p>\n\n<p>The way it works for all of them is to record every commit in a Directly Acyclic Graph (DAG), and from this, you have different merge strategies available. Here you can find more information:</p>\n\n<p><a href="http://revctrl.org/CategoryMergeAlgorithm" rel="nofollow noreferrer">http://revctrl.org/CategoryMergeAlgorithm</a></p>\n\n<p>At least hg, bzr and git can use external merge utilities.</p>\n'}, {'answer_id': 71492, 'author': 'benefactual', 'author_id': 6445, 'author_profile': 'https://Stackoverflow.com/users/6445', 'pm_score': 1, 'selected': False, 'text': '<p>The following is a discussion of how darcs (<a href="http://darcs.net" rel="nofollow noreferrer">http://darcs.net</a>) deals with patches - <a href="http://darcs.net/manual/node9.html" rel="nofollow noreferrer">http://darcs.net/manual/node9.html</a>.</p>\n'}, {'answer_id': 224554, 'author': 'Setori', 'author_id': 21537, 'author_profile': 'https://Stackoverflow.com/users/21537', 'pm_score': 1, 'selected': False, 'text': '<p>Neat article to read</p>\n\n<p><a href="http://betterexplained.com/articles/intro-to-distributed-version-control-illustrated/" rel="nofollow noreferrer">http://betterexplained.com/articles/intro-to-distributed-version-control-illustrated/</a></p>\n'}]
['https://Stackoverflow.com/questions/46281', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/-1/']