<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>experimentalworks &#187; dvcs</title>
	<atom:link href="http://blog.experimentalworks.net/tag/dvcs/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.experimentalworks.net</link>
	<description></description>
	<lastBuildDate>Fri, 27 Jan 2012 10:07:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>Mercurial Bookmarks Revisited &#8211; Part I</title>
		<link>http://blog.experimentalworks.net/2010/06/mercurial-bookmarks-revisited-part-i/</link>
		<comments>http://blog.experimentalworks.net/2010/06/mercurial-bookmarks-revisited-part-i/#comments</comments>
		<pubDate>Wed, 23 Jun 2010 08:53:51 +0000</pubDate>
		<dc:creator>dsp</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Version Control]]></category>
		<category><![CDATA[bookmarks]]></category>
		<category><![CDATA[dvcs]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[hg]]></category>
		<category><![CDATA[mercurial]]></category>

		<guid isPermaLink="false">http://blog.experimentalworks.net/?p=453</guid>
		<description><![CDATA[Bookmarks is an extension to the Mercurial SCM, which adds git-like branches to Mercurial. The extension is distributed together with Mercurial.
Recently the extension has received a major update. Time to look back.

This is a series of blogposts that consists of three parts:
 
 (1) Part   I: History of Bookmarks
 (2) Part  ...]]></description>
			<content:encoded><![CDATA[<p>Bookmarks is an extension to the <a href="http://mercurial-scm.org">Mercurial SCM</a>, which adds git-like branches to Mercurial. The extension is distributed together with Mercurial.<br />
Recently the extension has received a major update. Time to look back.</p>
<p>This is a series of blogposts that consists of three parts:</p>
<p> <strong>(1) Part   I: History of Bookmarks</strong><br />
 (2) Part  II: Daily Bookmarking<br />
 (3) Part III: Pushable Bookmarks</p>
<p><strong>UPDATE</strong> I&#8217;m aware that people wait for Part II. Let me see if I can write about it this weekend&#8230;in the meantime, click the flattr button :)<br />
<span id="more-453"></span><br />
I stumbled over Mercurial in August 2007. Back then I had already<br />
used <a href="http://git-scm.org">Git</a> for 6 months, but wanted<br />
to try out different distributed version control systems (<a href="http://en.wikipedia.org/wiki/Distributed_revision_control">DVCS</a>).<br />
I soon began to like Mercurial&#8217;s approach because of its simple and<br />
intuitive interface and its clean codebase. While playing around<br />
with Mercurial for a few weeks I was content with its concepts.<br />
There was one feature missing<br />
that I really like in Git: <a href="http://www.kernel.org/pub/software/scm/git/docs/git-branch.html">git-like branches</a>.</p>
<p>Unlike in Mercurial or in any other version control system, branches in<br />
Git are simply lightweight markers pointing to a commit. Every ancestor of<br />
the commit is considered part of the branch. Back then, this sounded odd to me. Later I realized it was a really good tool to create small local branches. You can create a small branch<br />
for a feature, merge it into your mainline, and remove the branch<br />
without anyone knowing you ever had a branch called<br />
<em>&#8216;stupid-little-feature</em>&#8216;. To make a long story short: It&#8217;s a good<br />
idea to have a similar concept in Mercurial, but none existed back in 2008.</p>
<p>In June 2008 I started developing Mercurial References providing lightweight branches similar to those available in Git. Although the initial work was appreciated by the community, it was rejected<br />
in favor of a concept more natural to Mercurial. Matt Mackall, the author of<br />
Mercurial proposed Mercurial Bookmarks.</p>
<h3>Bookmarks</h3>
<p>The concept of <a href="http://en.wikipedia.org/wiki/Bookmark">bookmarks</a> is easy:<br />
You can bookmark a commit with a unique name.  So it&#8217;s similar to<br />
a tag, with one exception, a bookmark advanced when you commit.<br />
(Like real bookmarks when you go to the next page).</p>
<p>I wrote an initial version of Mercurial Bookmarks in August, that<br />
was finally accepted in October. This improved git like workflows<br />
in Mercurial but still the implementation was far away from what I<br />
wanted. By adding the notion of a so called &#8220;current bookmark&#8221;, it<br />
got better. Still bookmarks had one major drawback in comparison<br />
to git style branches. They were local only. There was no way to<br />
push or pull bookmarks.</p>
<h3>Pushable bookmarks</h3>
<p>This was the status for the past two years. I tried to make bookmarks<br />
pushable during this time. A proposal by me how extensions in general<br />
can exchange arbitrary information over the wire was rejected in<br />
early 2009 because it was too unrestrictive for the protocol. A new<br />
concept, so called &#8216;pushkey concept&#8217; was developed in 2009.  This<br />
was discussed and accepted during the Mercurial Sprint in Paris,<br />
January 2010.</p>
<p>Matt Mackall, who now gets <a href="http://mercurial.selenic.com/sponsors/">sponsored</a> to work on Mercurial,<br />
worked on the <a href="http://selenic.com/hg/rev/ca4fc993087c">initial implementation</a>of pushkey and<br />
pushable bookmarks. And finally after two years of ongoing complains<br />
by people about local-only bookmarks, Mercurial 1.6 will have<br />
pushable bookmarks and introduces a great new concept to exchange<br />
metadata information between repositories.</p>
<p>The next blogpost will show you how to use bookmarks.</p>
<p class="wp-flattr-button"></p> <p><a href="http://blog.experimentalworks.net/?flattrss_redirect&amp;id=453&amp;md5=6168d680a8f2a3c2086cec08e10d8f7c" title="Flattr" target="_blank"><img src="http://blog.experimentalworks.net/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.experimentalworks.net/2010/06/mercurial-bookmarks-revisited-part-i/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Writing a hg to subversion gate</title>
		<link>http://blog.experimentalworks.net/2009/12/writing-a-hg-to-subversion-gate/</link>
		<comments>http://blog.experimentalworks.net/2009/12/writing-a-hg-to-subversion-gate/#comments</comments>
		<pubDate>Mon, 30 Nov 2009 23:59:04 +0000</pubDate>
		<dc:creator>dsp</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Version Control]]></category>
		<category><![CDATA[dvcs]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[hg]]></category>
		<category><![CDATA[mercurial]]></category>
		<category><![CDATA[subversion]]></category>

		<guid isPermaLink="false">http://blog.experimentalworks.net/?p=318</guid>
		<description><![CDATA[Using a decentralized version control system (DVCS) like Mercurial (hg) or Git as a client for Subversion is very common. With the unique features of a DVCS a developer can have both the features of offline development and local branching while still being able to push to a subversion server. This approach is often ...]]></description>
			<content:encoded><![CDATA[<p>Using a decentralized version control system (DVCS) like Mercurial (hg) or Git as a client for Subversion is very common. With the unique features of a DVCS a developer can have both the features of offline development and local branching while still being able to push to a subversion server. This approach is often used in environments in which subversion is the given version control system. While the approach of using this bi-directional push and pull mechanism, provided by git-svn or hgsubversion, works perfectly for one developer, it has limitations working in a team using the usual DVCS push and pull concepts.</p>
<p>The following article will outline the current limitations of bi-directional dvcs to subversion bridges and shows a simple approach to implement a solution for a certain instance of the problem.</p>
<p><span id="more-318"></span><br />
<strong>The bi-directional bridge</strong><br />
The idea of finding a way to interchange commits back and forth between a DVCS and subversion was born early in the development of tools like Git and Mercurial. The basic idea is easy to grasp. To initialize a repository the DVCS requests all changes between revision 0 and the current HEAD from the subversion server and imports every change as a regular changeset into the local repository of the DVCS. In addition it maintains a mapping between the local, DVCS specific, changeset IDs and the revision numbers in the subversion repository. If a developer wants to push his newly created changesets from it&#8217;s local repository back to subversion, the bridge determines the latest pushed changeset and then iterates over the unpushed changes, committing them bit by bit to the subversion server. </p>
<p>Depending on the DVCS you use it will then delete the local changeset and reimport the comitted changesets from the subversion server to ensure that the changeset contains the right date and comitter information as well as the right mapping to the subversion revisionnumber.</p>
<p><em>Example</em><br />
To clarify what we just discussed. Assume that we are using git-svn. We are importing a subversion repository with just one commit using the command (I won&#8217;t get into detail how to use the command):<br />
<code><br />
 $ git svn clone svn://example.com/repo<br />
</code><br />
This command results in a repository which in our example contains the following commit.<br />
<code><br />
commit 7a730e9187becbe1979059cd9752fdea38e3cd9e<br />
Author: david &gt;david @cffdd316-8dd2-4046-8f43-d0df91842a18&lt;<br />
Date:   Thu Jul 12 19:39:51 2007 +0000</p>
<p>    Crescas in mille millia<br />
</code><br />
Let&#8217;s asusme that we create a new commit on top:<br />
<code><br />
commit 129e0e4239ac4d375f2a2132dee042a27f2fd70c<br />
Author: David S. P. &gt;dsp at php.ent&lt;<br />
Date:   Fri Jul 13 12:23:42 2007 +0000</p>
<p>	First Draft<br />
</code><br />
If we push it using <em>git svn dcommit</em>, it&#8217;ll be committed into subversion and<br />
reimported as:<br />
<code><br />
commit 8200f32f61432004b488d063564ac9dae7bf6827<br />
Author: david &gt;david @cffdd316-8dd2-4046-8f43-d0df91842a18&lt;<br />
Date:   Fri Jul 13 12:23:42 2007 +0000</p>
<p>	First Draft<br />
</code></p>
<p><strong>Limitations</strong><br />
Tools like <em>git-svn</em> or <em>hgsubversion</em> are working perfectly fine as long as you use them just as a subversion client. There is a serious limitation in what you can push and pull from and to a subversion server. Particularly, problems arise if you are using the usual DVCS push and pull method to exchange changesets. Why so? If you push and pull from other DVCS repositories you might have to create a merge. Modern DVCS like Git, Mercurial or Bazaar represent history as a directed acyclic graph (DAG). Therefore a merge is a commit which has two (or more) parents, which means that a merge is the resulting connection of two parallel strands of history. Now this is a very comfortable and powerful way to describe history in parallel development. Sadly subversion doesn&#8217;t handles history and hence merges the same way (at least not priort svn 1.5). As a result, it is not possible to represent the Merge from a DVCS in subversion.</p>
<p>Different bi-directional bridges have different approaches to this problems. Git-svn will commit the Merge but not the commits which are part of the seconds strand of history, while hgsubversion will abort if it has to push a merge. The fact that hgsubversion aborts in case of a merge is our actual problem. We want to use Mercurial and therefore need to find a way to push a merge to subversion.</p>
<p><strong>A usecase</strong><br />
You shouldn&#8217;t care much about these limitations. Usually, people are using the bi-directional bridge locally to be able to do offline commits or bisect a bug. In that case, everything will work fine.</p>
<p>But why do I write a complete blog post about a hg to svn bridge if the problem is already solved? The answer is pretty simple.</p>
<ol>
<li>Imagine you are working in a small team. Everybody in the team knows Mercurial and everybody likes to use it. Moreover you are working offline from time to time, and the members of the team sometimes have to exchange unfinished features with other members. In that case you will probably use Mercurial as your version control system. The problem here is the customer. He dictates the VCS and it has to be Subversion. Now subversion at all is not that bad, but in your particular case, it&#8217;s a huge drawback. You have to find a way to mirror your Mercurial repository to the Subversion server.
</li>
<li>A second use case is that you are working on an OpenSource project which uses github or bitbucket to host it&#8217;s repositories. As you are using the OpenSource framework also at work. You have to use Subversion and you want to use svn:externals to integrate your fancy framework into the existing Subversion repository</li>
</ol>
<p>As you see, there is a use case for DVSC to Subversion mirror. As no such tool exists at the moment, we&#8217;ll try to implement a (frankly, very stupid) mirroring mechanism.</p>
<p><strong>The idea and it&#8217;s limitations</strong><br />
We see that we need to mirror a existing Mercurial repository to Subversion.<br />
We also know that we cannot use the existing tools. Our requirements are the following.</p>
<ol>
<li>Mirror a Mercurial repository into a Subversion repository</li>
<li>Track latest synchronized changeset</li>
<li>Handle merges</li>
</ol>
<p>Note that we would have been able to do this with git-svn, while it&#8217;s not possible to do it with hgsubversion.</p>
<p>A few assumptions about the environment where we want to use our mirroring mechanism helps us to simplify the requirements.</p>
<ol>
<li>We do not need to preserve the author information</li>
<li>We have a central Mercurial repository called Gate</li>
<li>No commit will be done into the repository other than our mirroring (and believe me, things get ulgy for you if you try to&#8230;)</li>
<li>We do not need to preserve all commits</li>
</ol>
<p>So what is the end result? We just need to find a way to push all changesets and just ignore all merged changes, but commit the merge itself. This should be sufficient.</p>
<p>In our particular environment everyone has his own repository, but one person integrates all changes into one repository called the Gate. Commits reaching the gate are committed to Subversion.</p>
<p><strong>The implementation</strong><br />
To make a long story short (it&#8217;s getting late). We are using Mercurials log command and it&#8217;s option to obtain a linear history that can be pushed. To get the the history, we use<br />
<code><br />
	hg log --follow-first<br />
</code><br />
This will return the history omitting all merged changesets but including the merges itself. We silently drop the changesets that were merged, but retain the result. As we need to get just the SHA-1, we use the &#8211;template option to get the node. We then iterate over the history, updating our working copy to each changeset in the history, adding all newly created files and deleting all removed files and then comitting the current state of the working directory. So here is our final script<br />
<code></p>
<pre>
#!/bin/sh

lc=0
cont=0
if test -f "LAST_COMMIT"
then
	lc=`cat LAST_COMMIT`
	cont=1
fi

for hash in `hg log --follow-first --template "{node}\n" -r $lc:tip`
	do
		if test $cont -eq 1
		then
			cont=0
			continue
		fi

		echo "update to $hash"
		if ! hg log --template "{desc}\n"  -r $hash > COMMIT_MSG
		then
			echo "Canno get log" >&#038;2
			exit 127;
		fi
		cat COMMIT_MSG

		hg up -C -r $hash
		for file in `hg log --template "{file_adds}\n" -r $hash`
			do
				echo "add $file"
				svn add --parents $file
			done
		for file in `hg log --template "{file_dels}\n" -r $hash`
			do
				echo "del $file"
				svn rm $file
			done
		svn commit -F COMMIT_MSG
		echo $hash > LAST_COMMIT
	done
</pre>
<p></code><br />
It looks scary, and yes it <em>is</em> scary. But for the moment it works. Our simple hg to subversion bridge is finished.</p>
<p class="wp-flattr-button"></p> <p><a href="http://blog.experimentalworks.net/?flattrss_redirect&amp;id=318&amp;md5=5699db1240db9791bfbd9c5808d4f26d" title="Flattr" target="_blank"><img src="http://blog.experimentalworks.net/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.experimentalworks.net/2009/12/writing-a-hg-to-subversion-gate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>hg-scm.org</title>
		<link>http://blog.experimentalworks.net/2009/08/hg-scm-org/</link>
		<comments>http://blog.experimentalworks.net/2009/08/hg-scm-org/#comments</comments>
		<pubDate>Sun, 02 Aug 2009 21:34:08 +0000</pubDate>
		<dc:creator>dsp</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Version Control]]></category>
		<category><![CDATA[dvcs]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[hg]]></category>
		<category><![CDATA[mercurial]]></category>

		<guid isPermaLink="false">http://blog.experimentalworks.net/?p=281</guid>
		<description><![CDATA[For those of you, who didn't notice so far, in the last 6 month we worked on a more userfriendly and accessible page than the current mercurial website. Three weeks ago we launched hg-scm.org which is quite similar to git-scm.org. I hope you enjoy it]]></description>
			<content:encoded><![CDATA[<p>For those of you, who didn&#8217;t notice so far, in the last 6 month we worked on a more userfriendly and accessible page than the current mercurial website. Three weeks ago we launched <a href="http://hg-scm.org">hg-scm.org</a> which is quite similar to <a href="http://git-scm.org">git-scm.org</a>. I hope you enjoy it</p>
<p class="wp-flattr-button"></p> <p><a href="http://blog.experimentalworks.net/?flattrss_redirect&amp;id=281&amp;md5=a3a31131e7051326deb1106db2e45072" title="Flattr" target="_blank"><img src="http://blog.experimentalworks.net/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.experimentalworks.net/2009/08/hg-scm-org/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>git2svn, a little bit of git voodoo.</title>
		<link>http://blog.experimentalworks.net/2009/07/git-voodoo/</link>
		<comments>http://blog.experimentalworks.net/2009/07/git-voodoo/#comments</comments>
		<pubDate>Mon, 06 Jul 2009 15:59:29 +0000</pubDate>
		<dc:creator>dsp</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Version Control]]></category>
		<category><![CDATA[dvcs]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[voodoo]]></category>

		<guid isPermaLink="false">http://blog.experimentalworks.net/?p=232</guid>
		<description><![CDATA[Interacting between git and subversion is quite common. The git command git-svn can be used to import existing subversion repositories into git and commit synchronize commits between two repositories. While importing a subversion repository into git is common, importing an git repository into subversion is quite unusual. There are various tools to do so, ...]]></description>
			<content:encoded><![CDATA[<p><em>Interacting between <a href="http://git-scm.org">git</a> and <a href="http://subversion.tigris.org/">subversion</a> is quite common. The git command <a href="http://www.kernel.org/pub/software/scm/git/docs/git-svn.html">git-svn</a> can be used to import existing subversion repositories into git and commit synchronize commits between two repositories. While importing a subversion repository into git is common, importing an git repository into subversion is quite unusual. There are various tools to do so, but most of them require direct access to the svn repository. In fact it is possible to use git-svn to get that job done. Frankly it requires some git voodoo and knowledge of the <a href="http://git.or.cz/gitwiki/GraftPoint">graft-feature</a>. We&#8217;ll do a sample import using grafts, but before we start, we&#8217;ll explain the theory behind the import.</em><br />
<span id="more-232"></span><br />
We assume that we have a remote subversion repository. It is empty and we want to import an existing git repository into that subversion repository.</p>
<p><strong>The idea</strong><br />
Our general idea to import the git repository into subversion is easy. We import the current subversion repository and then push the changes from the our existing git repository on top of that imported subversion repository. We than can use git-svn to commit the changes back to the subversion repository. Even thought this sound simple, it is not. Part of the problem is the fact that subversion usually deals with linear history, while git does not. (1) We have to keep in mind that we need to linearize the git repository while pushing changes to the imported subversion repository. (2) we have to make sure that every commit from the original git repository is pushed to the imported repository as a descendant of the last commit from the subversion repository to avoid conflicts. (3) the imported subversion repository and the existing git repository are not related to each other. As they don&#8217;t have a <a href="http://www.kernel.org/pub/software/scm/git/docs/git-merge-base.html">common ancestor</a> in terms of a common commit (with according sha1s), we are not able to merge both repositories easily. We will use a technique called <em>grafts</em> to create a fake common ancestor, which will make it possible to merge both repositories.</p>
<p><strong>1. Importing the svn repository into git</strong><br />
Our first step is importing the svn repository into git. We are using <em>git-svn</em> for that task.<br />
<code><br />
# git svn clone svn://path/to/repo<br />
</code><br />
We will get a git repository with a branch called <em>master</em>. As we later want to push our git repository on top of the imported svn repository, we need to remember the current id of the repositories head (we&#8217;ll discuss later why we need that).  The command <em><a href="http://www.kernel.org/pub/software/scm/git/docs/git-rev-parse.html">git rev-parse</a></em> will give us the necessary information.<br />
<code><br />
# git rev-parse HEAD<br />
00f97c72f22b82c6c77ae429986060832c6b6f55<br />
</code></p>
<p><strong>2. Importing the git repository into our imported svn repository</strong><br />
Let&#8217;s start with the voodoo part. We want to merge our imported svn repository and our existing git repository. But git doesn&#8217;t know how to <a href="http://www.kernel.org/pub/software/scm/git/docs/git-merge.html">merge </a>them because both repositories don&#8217;t share a common ancestor. We can solve this problems by creating a fake common ancestor, but to do so we need all commits of both repositories in one repository. Therefore we fetch the content of the git repository into our imported subversion repository. To fetch the existing git repository into our imported svn repository we use the following <em><a href="http://www.kernel.org/pub/software/scm/git/docs/git-fetch.html">git-fetch</a></em> command:<br />
<code><br />
# git fetch /path/to/git/repository master:tomerge<br />
</code><br />
The resulting repository will look that way:<br />
<img src="http://blog.experimentalworks.net/wp-content/uploads/2009/07/graft1.png" alt="Imported" title="Imported" width="500" height="237" class="alignnone size-full wp-image-245" /><br />
Both branches the one from the existing git repository and the svn imported one exist in parallel in the same repository.</p>
<p><strong>3. Tell git what to merge&#8230;</strong><br />
We have two parallel branches. We now create the fake ancestor. This is called a <em>graft</em>. Unfortunately git&#8217;s grafts are not very well documented. Let&#8217;s visualize which commits we want to graft on each other:<br />
<img src="http://blog.experimentalworks.net/wp-content/uploads/2009/07/graft21.png" alt="graft21" title="graft21" width="500" height="215" class="alignnone size-full wp-image-252" /><br />
So we will graft the existing git branch on top of the svn branch. The fake ancestor will be the HEAD of the svn branch and the first commit of the existing git branch. To get the first commit of the existing git branch we use the following command:<br />
<code><br />
# git rev-list --reverse tomerge  | head -n 1<br />
bab39ed371145b83340750101e7ec85167845857<br />
</code><br />
Therefore the commit <em>bab3&#8230;</em> and <em>00f97&#8230;</em> will be our grafts. We create the file <em>.git/info/grafts</em> with the content<br />
<code><br />
bab39ed371145b83340750101e7ec85167845857 00f97c72f22b82c6c77ae429986060832c6b6f55<br />
</code><br />
We use gitk to check if our history seems to be linear. If everything is correct, just switch to the master branch and <em><a href="http://www.kernel.org/pub/software/scm/git/docs/git-rebase.html">rebase</a></em> your tomerge branch. We use rebase here to get a linear history. A merge might make it impossible for git-svn to push to the remote svn repository as imported commits cannot have commits which are not synchronized to the svn yet.<br />
<code><br />
# git checkout master<br />
# git rebase tomerge<br />
# git svn dcommit<br />
</code></p>
<p>Done.</p>
<p class="wp-flattr-button"></p> <p><a href="http://blog.experimentalworks.net/?flattrss_redirect&amp;id=232&amp;md5=f9d3756239a6ea93a3163fa7f5c055f1" title="Flattr" target="_blank"><img src="http://blog.experimentalworks.net/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.experimentalworks.net/2009/07/git-voodoo/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Merge vs. Rebase &#8211; A deep dive into the mysteries of revision control</title>
		<link>http://blog.experimentalworks.net/2009/03/merge-vs-rebase-a-deep-dive-into-the-mysteries-of-revision-control/</link>
		<comments>http://blog.experimentalworks.net/2009/03/merge-vs-rebase-a-deep-dive-into-the-mysteries-of-revision-control/#comments</comments>
		<pubDate>Sat, 07 Mar 2009 02:51:51 +0000</pubDate>
		<dc:creator>dsp</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Version Control]]></category>
		<category><![CDATA[dvcs]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[mercurial]]></category>

		<guid isPermaLink="false">http://blog.experimentalworks.net/?p=163</guid>
		<description><![CDATA[I remember the days when I started learning Git about two years ago. I crawled through all the available commands and read the man pages what they are for and I remember when I stumbled over rebase and stuck. After figuring out what it actually does, I start loving it, but didn't understand it's ...]]></description>
			<content:encoded><![CDATA[<p>I remember the days when I started learning <a href="http://git-scm.com">Git</a> about two years ago. I crawled through all the available commands and read the man pages what they are for and I remember when I stumbled over <a href="http://www.kernel.org/pub/software/scm/git/docs/git-rebase.html">rebase</a> and stuck. After figuring out what it actually does, I start loving it, but didn&#8217;t understand it&#8217;s dangerousness until someday I somehow got duplicated commits after pulling from another repository. So let me explain what goes wrong and why merge and rebase are often misunderstood. I&#8217;ll also present a list of golden-rules about their usage. Before we start with explaining both commands, I would like to give you one of the most important rules, in case you don&#8217;t want to read the complete article.</p>
<blockquote style="background-color: #fffad1; font-weight: bold; color: black"><p>
Never rebase branches or trees that you pulled. Only rebase local branches.
</p></blockquote>
<p><span id="more-163"></span><br />
<em>Disclaimer: I never read this article myself</em></p>
<hr />
<strong>Merge</strong><br />
<a href="http://www.kernel.org/pub/software/scm/git/docs/git-merge.html">Merging</a> is one of the most important operations in <a href="http://en.wikipedia.org/wiki/Distributed_revision_control">distributed revision control systems</a>. Basically a merge is a new commit on top of <em>both</em> branches that should be merged. It is like melting two different pipes of steel together. The pipe itself doesn&#8217;t break, it&#8217;s just combined with another pipe. So, the commit itself knows that it is a merge commit. It is important to notice that it is a new commit that gives the revision control system a hint that there was a merge between two branches.</p>
<p>Let&#8217;s visualize this:<br />
Let&#8217;s assume that we have a linear history. In our graphic we see the last tree commits in that history.<br />
<img src="http://blog.experimentalworks.net/wp-content/uploads/2009/03/simple-linear.jpg" alt="simple-linear" title="simple-linear" width="640" height="177" class="alignleft size-full wp-image-165" /></p>
<p>Okay. Now let&#8217;s say there is a bug in the software. For sure, we don&#8217;t do any mistakes, certainly a co-worker did that mistakes. Unfortunatly we are the only one <a href="http://www.titanic-magazin.de/">smart</a> enough to know how to fix that. So we checked out our stable branch and committed our fixes to that branch. Our fix needs <a href="http://en.wikipedia.org/wiki/42">two</a> commits. Let&#8217;s see how this reflects in our <a href="http://en.wikipedia.org/wiki/LSD">visualization</a>:<br />
<img src="http://blog.experimentalworks.net/wp-content/uploads/2009/03/before-merge.jpg" alt="Branch off" title="Branch off" width="640" height="177" class="alignleft size-full wp-image-173" /></p>
<p>The commit <em>433fa</em> and <em>322ac</em> are our commits that fix a certain problem. Now we need to integrate these commits into our current experimental development version. <em>But as we keep our stable branch also public for other employees to push, we push this branch first before we merge it into our experimental branch</em>. Let&#8217;s repeat this. We pushed this branch to a place where other people can pull it. Again, we <a href="http://www.kernel.org/pub/software/scm/git/docs/git-push.html">pushed</a> it. Remember that!</p>
<p>So we have to get that fix into our experimental branch. So we use the merge command. In Git or <a href="http://selenic.com/mercurial">Mercurial </a>this would look like:</p>
<blockquote><p>
$ git checkout stable<br />
..fix fix fix fix..<br />
$ git commit<br />
&#8230;<br />
$ git checkout experimental<br />
$ git merge stable
</p></blockquote>
<blockquote><p>
$ hg branch stable<br />
..fix fix fix..<br />
$ hg commit<br />
&#8230;.<br />
$ hg branch default<br />
$ hg merge stable
</p></blockquote>
<p>So we create our merge commit. This is a <em>new</em> commit that reflects our merge.<br />
<img src="http://blog.experimentalworks.net/wp-content/uploads/2009/03/merge.jpg" alt="merge" title="merge" width="640" height="177" class="alignleft size-full wp-image-176" /><br />
Please note: <em>The actual ID&#8217;s of our commits that include the fixes did not change</em>.</p>
<hr />
<strong>Deep dive</strong><br />
So here is the deep dive into merging. Our revision control system now knows that there was a merge. Therefore if we later start to work on stable again, commit new fixes on top of the old fixes and then do a merge again into the experimental branch, the systems tries to find the common ancestor. This is our merge commit, therefore only commits and changes later than the last merge commit will be used to do the new merge commit. This results in less merge conflicts and in a better tracking when fixes really get back into the experimental branch. Because all these new fancy revision control systems like Git or Mercurial are designed to be fast and to deal with a humongous amount of commits and data, they don&#8217;t compare the actual changes to determine the first common ancestor of two heads. They are using the calculated SHA1 key. So if we merge, the SHA1s don&#8217;t change and we the system has a way to detect that some commits already exist in our tree if we push from other people that pulled from use once.</p>
<hr />
<strong>Rebase</strong><br />
Rebase has a different approach as merging. It is one of the more sophisticated and hard to learn commands. It&#8217;s about cutting off a pipe and weld it on another pipe. In Git it is a build-in command, but as it usually not used very often, it is just an extension in Mercurial. Bascially a rebase is a way to cut of a set of commits from a branch and apply those commits on another branch. This seems to be pretty easy, but usually developers get a lot of problems when using rebase if they are not familar with all the implications of &#8216;cut off&#8217;.</p>
<p>So let&#8217;s get back to our &#8216;stable&#8217; branch which were we commitet our fixes to:<br />
<img src="http://blog.experimentalworks.net/wp-content/uploads/2009/03/before-merge.jpg" alt="Branch off" title="Branch off" width="640" height="177" class="alignleft size-full wp-image-173" /></p>
<p>So we want to rebase this branch on top of our experimental branch. What does rebase do: It cuts off these commits. The commits don&#8217;t have any information about their parents anymore. The system then applies them on top of the new branch, which is in our example the experimental branch. If everything went fine, we get a nice linear <a href="http://www.kernel.org/pub/software/scm/git/docs/git-log.html">history</a>. Our old branch doesn&#8217;t exist anymore but instead we have all the important commits applied on top of our experimental branch. <a href="http://www.buttugly.ca/">As people tend to dislike merge conflicts</a> rebase is the perfect tool to get rid off these commits. Let&#8217;s visualize this:<br />
<img src="http://blog.experimentalworks.net/wp-content/uploads/2009/03/cut-rebase.jpg" alt="cut-rebase" title="cut-rebase" width="640" height="177" class="alignleft size-full wp-image-191" /><br />
We literally cut of these commits and then apply it on top of the new branch:<br />
<img src="http://blog.experimentalworks.net/wp-content/uploads/2009/03/rebase.jpg" alt="rebase" title="rebase" width="640" height="177" class="alignleft size-full wp-image-192" /></p>
<p>But what are the implications? Why does merge even exists if we found such a nice way to handle our history? Ohhhhh. Let&#8217;s way&#8230;take a look at the graphics. <strong>Our commit ID changed!</strong> Why? We have a new parent, we even might have completly new changesets (depending on the changes on the new branch). Our revision control system really thinks of our commits as patches and applies them on top of the new branch.  Therefore our revision control system thinks that our commits are new commits. <em>Recapitulate this</em>. IT THINKS THAT THESE ARE NEW COMMITS. Why? Because they have new IDs. It&#8217;s that simple. The common ancestor of a commit is determined by traversing the list of commit IDs and their parent IDs. As the parents changed, the ID&#8217;s have changed too.</p>
<hr />
<strong>git rebase [--onto branch] <upstream> [branch]</upstream></strong><br />
When you rebase in git, you provide an <i>upstream</i> branch. The upstream branch is the branch to which the commits should be moved. The cut-off point is calculated as the common-ancestor between your current<br />
branch and the provided upstream. You can also provide the branch for that calculation manually as a parameter to git rebase.</p>
<hr />
<strong>Deep dive</strong><br />
E.g. Git literally take this commits as patches by removing the commits from the history, creating patches out of it and applythem on top of the new branch. If you rebase the first time, it will result in more or less the same conflicts as merging, but if your rebase the second time, the revision control system doesn&#8217;t know about that rebase and uses the same common ancestor that was used by the first rebase. Hence if you use rebase frequently between the same branches, Git uses more and more commits to do the actual merge, which is equal to have branches that get more and more diveregent. This usually leads to much more merge conflicts. Think about rebasing as if you pop all those commits from the branch and push it to the new branch (if you speak in the terms of a patch management system like quilt).</p>
<hr />
<p>So if you have pulled your branch to some place and you now pull it back, you will get duplicated commits. Okay you might be smart enough to get around this, but other people that might have pulled from your stable branch might not know what happened, so they have all these duplicated commits, or if you pull from them, you get these commits back. Actually you don&#8217;t even see them until you try to merge them, because their ID is completly different. As a result you get a millions of merge conflicts and have to find a way to get rid of the duplicated commits. But why, and how can you prevent his? And why do these systems include a command that can cause so much pain?</p>
<p>So let&#8217;s see.</p>
<p><strong>Rebase done right</strong><br />
We saw that rebasing results in duplicated commits if we try to rebase branches that we already pushed to some repository, that either we or others pulled from. Let&#8217;s see why there is still a point to use rebase at all. Imagine you want to fix a bug <em>locally</em>. This means, you do not push this branch somewhere. Did you get that point? If you then rebase your local fancy branch on top of your branch that you usally push everything is fine. Let&#8217;s take a look at a good example:</p>
<blockquote><p>
$ git branch pdo-mysql-config-fix<br />
$ git checkout pdo-mysql-config-fix<br />
..hack.hack..<br />
$ git commit<br />
$ git rebase master<br />
$ git checkout master<br />
$ git merge pdo-mysql-config-fix
</p></blockquote>
<p>Got it? We never cut off the pipe. It&#8217;s just like we prepared that pipe on another stream. We realized the main pipe was changed so we weld it of and put it back on top of the main pipe. As all the people just look at our main pipe it looks like we just added a new piece on top of the old pipe. We brought the feature branch in line with master, so the merge will be trivial and git will consider it as a &#8220;fast-forward&#8221; which means there won&#8217;t be a merge commit. We never gonna push the branch that we use to rebase. If we push it, I would get duplicated commits:</p>
<p>So let&#8217;s rehearse the <strong>Golden Rule Of Rebasing</strong>:</p>
<blockquote style="background-color: #fffad1; font-weight: bold; color: black"><p>
Never ever rebase a branch that you pushed, or that you pulled from another person
</p></blockquote>
<p>It&#8217;s that simple. If you would rebase a branch from another person and he would pull back the integrated changes from you, he would get duplicated commits. So never ever do this.</p>
<p>The bad news: Too many developer get rebasing wrong and think that it&#8217;s a fancy way to get a linear history<br />
The good news: Believe me, even well known top-level maintainer didn&#8217;t get what rebasing is about.</p>
<p><em>This article is about rebasing. Rebasing is a way to push commits from a branch on top of another branch. Decentralized revision control systems such as Git or Mercurial implement this feature.</em></p>
<p><strong>UPDATE</strong><br />
A few people at reddit.com pointed out that it might not be a good idea to rebase a dev branch on top of master. If you are doing drastic changes in your dev branch, that&#8217;s right. People might use rebase then to keep their dev branch up to date on top of the master branch and therefore rebase against master. At the end they can merge the dev branch into the master branch (in fact the result is the same here, as it&#8217;s both way a fast forward).</p>
<p class="wp-flattr-button"></p> <p><a href="http://blog.experimentalworks.net/?flattrss_redirect&amp;id=163&amp;md5=b984daf91768896b476d2ebbb025abf6" title="Flattr" target="_blank"><img src="http://blog.experimentalworks.net/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.experimentalworks.net/2009/03/merge-vs-rebase-a-deep-dive-into-the-mysteries-of-revision-control/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Mercurial bookmarks</title>
		<link>http://blog.experimentalworks.net/2008/11/mercurial-bookmarks/</link>
		<comments>http://blog.experimentalworks.net/2008/11/mercurial-bookmarks/#comments</comments>
		<pubDate>Sun, 09 Nov 2008 11:39:37 +0000</pubDate>
		<dc:creator>dsp</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Version Control]]></category>
		<category><![CDATA[bookmarks]]></category>
		<category><![CDATA[dvcs]]></category>
		<category><![CDATA[mercurial]]></category>

		<guid isPermaLink="false">http://wp.experimentalworks.net/?p=80</guid>
		<description><![CDATA[
Please note that this blog post is outdated. please refer to the mercurial help for more information about bookmarks.

A few month ago, Matt Mackall the maintainer of the Mercurial version control system, came up with the idea to implement so called bookmarks for mercurial.
Basic idea
The basic idea of these bookmarks is simple. Instead of ...]]></description>
			<content:encoded><![CDATA[<blockquote style="background-color: #fffad1; font-weight: bold; color: black"><p>
Please note that this blog post is outdated. please refer to the mercurial help for more information about bookmarks.
</p></blockquote>
<p>A few month ago, <a href="http://selenic.com" >Matt Mackall</a> the maintainer of the <a href="http://en.wikipedia.org/wiki/Mercurial_(software)" >Mercurial</a> version control system, came up with <a href="http://thread.gmane.org/gmane.comp.version-control.mercurial.devel/15744" >the idea</a> to implement so called <i>bookmarks</i> for mercurial.<br />
<span id="more-80"></span><b>Basic idea</b><br />
The basic idea of these bookmarks is simple. Instead of referring to a commit by it&#8217;s linear rev number or it&#8217;s SHA1 key, the user should be able to set a <i>bookmark</i> on a commit and use this name to refer to the commit. So you can do:</p>
<blockquote><p>
 $ hg bookmark -r 132 my-bookmark<br />
 $ hg update my-bookmark
</p></blockquote>
<p><b>Further thoughts</b><br />
Just referring to a commit by a given name is nice, but it is not quite why we finally introduced bookmarks. A lot of people using both <a href="http://git.or.cz" >git</a> and Mercurial like Mercurial for it&#8217;s simplicity and it&#8217;s clear interface. Nevertheless they are missing certain features from git and one of the most often requested are git-styled branches. Let me just give you a short overview of the differences between the branch implementation of both systems:</p>
<p><i>Mercurial branches</i><br />
<a href="http://www.selenic.com/mercurial/wiki/index.cgi/Branch" >Mercurial branches</a> have a lot in common with branches in <a href="http://subversion.tigris.org" >Subversion</a> or <a href="http://www.nongnu.org/cvs/" >CVS</a>. If you commit to a branch, the name of the branch is stored in the <a href="http://www.selenic.com/mercurial/wiki/index.cgi/ChangeSet" >changeset</a> and therefore an immutable part of the history. This means, unlike bookmarks, branches can not be deleted if you created them, and that you will always know to which branch a certain commit belongs.</p>
<p><i>git branches</i><br />
In git&#8217;s notion of <a href="http://www.kernel.org/pub/software/scm/git/docs/git-branch.html" >branches</a> a branch is just a fork in the directed acyclic graph (DAG) of the history. Therefore the branch name is not recorded in the changeset. Branches are just pointers to a certain head of a <a href="http://en.wikipedia.org/wiki/Directed_acyclic_graph" >DAG</a> branch that move forward with every commit to that branch. This gives you the opportunity to create branches just for testing purposes or with stupid names that might be <a href="http://www.kernel.org/pub/software/scm/git/docs/git-merge.html" >merged</a> or <a href="http://www.kernel.org/pub/software/scm/git/docs/git-rebase.html" >rebased</a> later. If you delete the branch name, the branch in the DAG resides, but the name is gone.</p>
<p>As bookmarks are also just pointers to commits in the history, it is quite obvious that it is easy to implement a mechanism equal to the branch mechanism of git. Therefore bookmarks are not just pointers, but they move forward to the next commit if you create a child commit on a commit that is referred by a bookmark.</p>
<p><b>Problems</b><br />
As the branch notion in mercurial is different from git, it is clear the the internal design of mercurial makes some assumptions that rely on this behavior. This leads to some design decisions that might confuse people that come from git. If you switch to a branch in git and commit to it, only the branch that you are on is moved forward even though the parent commit has two branch names. Mercurial bookmarks are always forwarded if the parent commit is referred by a bookmark. Therefore you might forward bookmarks on commit without evening knowing. We don&#8217;t have a notion of a <i>current</i> bookmark. Furthermore bookmarks are local. There is no way to push or pull bookmarks. This is a limitation by the wire protocol of mercurial. There are patches floating around that implement a way to bring push/pull mechanism for various data including bookmarks, but as the wire protocol is a critical part of mercurial, the developer usually don&#8217;t like to enhance or change the protocol. You can use bookmarks remotely and do a lookup on them, but it requires a certain amount of deep knowledge.</p>
<p><b>Implementation</b><br />
As already mentioned, we have a <a href="http://www.selenic.com/hg/index.cgi/rev/135003a470f3" >working bookmark implementation now</a>. I worked on these bookmark stuff for several months. With the help of the mercurial community we finally made our way to the main tree (mpm&#8217;s and the crew tree) and therefore my extension will be part of the upcoming Mercurial 1.1 release. I&#8217;m currently <a href="http://www.bitbucket.org/segv/bookmarks" >maintaining the bookmarks</a> on <a href="http://bitbucket.org" >bitbucket.org</a> and a crew member is usually merging changes from me into the crew tree from time to time.</p>
<p><b>Example</b><br />
Let&#8217;s give you a short example how bookmarks work. First of all we have to checkout recent versions of Mercurial. You can get an hourly snapshot <a href="http://www.selenic.com/mercurial-snapshot.tar.gz" >here</a>. Then we have to setup the extension by adding the following lines to our <i>~/.hgrc</i>:</p>
<blockquote><p>
[extensions]<br />
hgext.bookmarks =
</p></blockquote>
<p>Now let&#8217;s go into a Mercurial repository. You can run <i>hg help bookmarks</i> to show the available flags.<br />
Let&#8217;s start with a basic listing of available bookmarks:</p>
<blockquote><p>
 $ hg bookmarks<br />
 no bookmarks set
</p></blockquote>
<p>Create a bookmark on the current tip of the repository:</p>
<blockquote><p>
 $ hg bookmark my-tip<br />
 $ hg bookmarks<br />
   + my-tip                    7348:1a5c9ca2bfd5
</p></blockquote>
<p>Let&#8217;s create a bookmark on an other revision in the history:</p>
<blockquote><p>
 $ hg bookmark -r 7300 hgweb-fix<br />
 $ hg bookmarks<br />
   + my-tip                  7348:1a5c9ca2bfd5<br />
     hgweb-fix               7300:591767e6ea7a
</p></blockquote>
<p>We can than update to the revision:</p>
<blockquote><p>
 $ hg update hgweb-fix<br />
 82 files updated, 0 files merged, 31 files removed, 0 files unresolved<br />
 $ hg bookmarks<br />
      my-tip                  7348:1a5c9ca2bfd5<br />
   +  hgweb-fix               7300:591767e6ea7a
</p></blockquote>
<p>We also can now commit to this bookmark and create a new head:</p>
<blockquote><p>
 &#8230;hack..hack..<br />
 $ hg commit -m&#8217;Another hgweb bugfix&#8217;<br />
 $ hg bookmarks<br />
      my-tip                  7348:1a5c9ca2bfd5<br />
   +  hgweb-fix               7349:ca3fbad32554
</p></blockquote>
<p>Let&#8217;s go back to our tip and merge our change into it:</p>
<blockquote><p>
 $ hg update my-tip<br />
 $ hg merge hgweb-fix<br />
 $ hg commit -m&#8217;Merge bookmark hgweb-fix&#8217;
</p></blockquote>
<p>Now we can just delete our bookmarks</p>
<blockquote><p>
 $ hg bookmark -d hgweb-fix<br />
 $ hg bookmarks<br />
      + my-tip                  7350:3acda44343da
</p></blockquote>
<p>You can use bookmarks in every rev lookup. This means you can also do <i>hg log my-tip</i> or <i>hg qimport -r my-tip</i>. It is even possible to look them up using <i>hg id -r <bookmark> <remoteurl></remoteurl></bookmark></i>. I hope you enjoy it. If you encounter any bugs don&#8217;t hesitate to file an issue at the mercurial bugtracker.</p>
<p><b>Thanks to</b><br />
A lot of people were involved in the development of the bookmarks extension either by giving ideas or by actually patching it. Thanks to ronny, mpm, tonfa, piranha, parren, joel, dimitriy and #mercurial.</p>
<p><b>Links</b></p>
<ul>
<li><a href="http://selenic.com/mercurial" >Mercurial</a></li>
<li><a href="http://hg.intevation.org/mercurial/crew" >Crew repository</a></li>
<li><a href="http://thread.gmane.org/gmane.comp.version-control.mercurial.general/9936" >Announcement of the bookmark extension</a></li>
<li><a href="http://www.bitbucket.org/segv/bookmarks" >My bookmark repository</a></li>
</ul>
<p><i>Mercurial is a fast decentralized version control system used by projects like Mozilla and OpenJDK for their software development. It is written in python and currently maintained by Matt Mackall.</i></p>
<p class="wp-flattr-button"></p> <p><a href="http://blog.experimentalworks.net/?flattrss_redirect&amp;id=80&amp;md5=33aaed8787567aa7a45981da513f46de" title="Flattr" target="_blank"><img src="http://blog.experimentalworks.net/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.experimentalworks.net/2008/11/mercurial-bookmarks/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>GIT vs. SVN: 2:0</title>
		<link>http://blog.experimentalworks.net/2008/07/git-vs-svn-20/</link>
		<comments>http://blog.experimentalworks.net/2008/07/git-vs-svn-20/#comments</comments>
		<pubDate>Sun, 27 Jul 2008 22:55:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Version Control]]></category>
		<category><![CDATA[dvcs]]></category>
		<category><![CDATA[subversion]]></category>

		<guid isPermaLink="false">http://wp.experimentalworks.net/?p=70</guid>
		<description><![CDATA[Again, git vs. SVN. Last time, it was big win for git. And guess what, git will strike again.

I mean nobody is perfect (expect Linus, but there is just one - as he mentioned once), so we actually fail writing bugfree code. Therefore we end up sitting in front of a huge code base ...]]></description>
			<content:encoded><![CDATA[<p>Again, git vs. SVN. Last time, it was big win for git. And guess what, git will strike again.</p>
<p>I mean nobody is perfect (expect Linus, but there is just one &#8211; as he mentioned once), so we actually fail writing bugfree code. Therefore we end up sitting in front of a huge code base trying to figure out what&#8217;s wrong. Thanks to <i>our</i> agile development process we usually end up fixing code we are not into.</p>
<p>So the facts: </p>
<ul>
<li>We don&#8217;t know the code
 </li>
<li>We don&#8217;t have a clue where to search
 </li>
<li>We are lazy
</li>
</ul>
<p><b>bisect</b><br />
Okay, if we drop 1. and 2. we still have to find out what went wrong. So as we tend to get our evening beer fast and don&#8217;t want to waste time, we use <i>git bisect</i> to find out when the problem was introduced.</p>
<p>Assume following commit history:</p>
<p> a &#8211;> a&#8217; (bug introduced) &#8211;> b &#8211;> a&#8221; &#8211;> c</p>
<p>When we <b>bisect</b> the problem, we will end up doing a quick search on the commits, marking buggy commits/trees bad and those that work fine good. This means, we mark <b>c</b> as good, then git will take us to <b>a</b>. We mark that commit as good, which will git move to <b>b</b>. If we mark b bad, git <b>knows</b> that <b>a&#8217;</b> must introduce the bug. Than just view the diff and you might know where to find the bad code and how to fix it.</p>
<p>Well, as long nobody trashed the history with their &#8216;fixed a hundred bugs&#8217; commits, containing like thousends of unrelated changes. In those cases, just bisect your collegue. <b>git vs. SVN: 2:0</b></p>
<p><i>take it with humour</i></p>
<p class="wp-flattr-button"></p> <p><a href="http://blog.experimentalworks.net/?flattrss_redirect&amp;id=70&amp;md5=9bf1b4912119f45b2804a4f4b4ce0071" title="Flattr" target="_blank"><img src="http://blog.experimentalworks.net/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.experimentalworks.net/2008/07/git-vs-svn-20/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>GIT vs. SVN: 1 : 0</title>
		<link>http://blog.experimentalworks.net/2008/07/git-vs-svn-1-0/</link>
		<comments>http://blog.experimentalworks.net/2008/07/git-vs-svn-1-0/#comments</comments>
		<pubDate>Wed, 23 Jul 2008 19:44:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Version Control]]></category>
		<category><![CDATA[dvcs]]></category>
		<category><![CDATA[subversion]]></category>

		<guid isPermaLink="false">http://wp.experimentalworks.net/?p=69</guid>
		<description><![CDATA[I used git for the last 6 month in a big project. The project itself is not maintained
in git but in subversion as this is what developers know and what project leaders like to use
for several reasons. 

In fact it's not a bad idea to actually use subversion as version control system, particularly if
the ...]]></description>
			<content:encoded><![CDATA[<p>I used git for the last 6 month in a big project. The project itself is not maintained<br />
in git but in subversion as this is what developers know and what project leaders like to use<br />
for several reasons. </p>
<p>In fact it&#8217;s not a bad idea to actually use subversion as version control system, particularly if<br />
the developer are used to it. Well, I don&#8217;t care about that. Thanks to <i>git-svn</i> I could use<br />
<i>git</i> as my <i>subversion</i> frontend. For sure, the distributed architecture of git didn&#8217;t help me that much when it comes to exchanging changes as I was the only developer using git.</p>
<p>But thanks to the repository format and git rich featureset, I found myself using git in a<br />
much more productive way than people could use subversion. </p>
<p><b>Pickaxe:</b><br />
What I really love is pickaxe. You can use that feature by passing -S to git log causing the log<br />
to search for the string in the commit history and display all the commits that contain these changes.<br />
Actually one of our developers had a problem with a blur event in the java script code, causing<br />
all forms in the script to lose their focus all the time. He was just searching for the point all the<br />
time as going through the commit messages was obviously too much time consuming (with about 100 commits per day). To make a long story short: I&#8217;m really a Javascript dumbass, but I just picked the<br />
latest commits having a blur in their name with <i>git log -Sblur</i> and I found 2 promising commits. Showing him the commits actually solved the problem. He just missed one point in the thousands lines<br />
of Javascript containing the blur event that caused the problems. Okay so here are the statistics for that event: Subversion with incremental search, but Javascript knowledge: 3hours. Git without any knowledige and a lazy person using it: 10mins. <b>GIT vs. SVN: 1:0</b></p>
<p class="wp-flattr-button"></p> <p><a href="http://blog.experimentalworks.net/?flattrss_redirect&amp;id=69&amp;md5=6517abdae1adfb424fc230fc5df6d3c8" title="Flattr" target="_blank"><img src="http://blog.experimentalworks.net/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.experimentalworks.net/2008/07/git-vs-svn-1-0/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Experimental PHP 5.3 Tree</title>
		<link>http://blog.experimentalworks.net/2008/07/experimental-php-53-tree/</link>
		<comments>http://blog.experimentalworks.net/2008/07/experimental-php-53-tree/#comments</comments>
		<pubDate>Wed, 02 Jul 2008 19:08:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Version Control]]></category>
		<category><![CDATA[dvcs]]></category>

		<guid isPermaLink="false">http://wp.experimentalworks.net/?p=68</guid>
		<description><![CDATA[Approaching the 5.3 release of PHP, a lot of features were introduced
and discussed at the internals mailinglist. This includes closures, traits
and various other patches. Some of these patches are on hold and not yet
applied. Therefore only a few people can take a look at the new features. Particularly because they scare patching PHP themselves ...]]></description>
			<content:encoded><![CDATA[<p>Approaching the 5.3 release of PHP, a lot of features were introduced<br />
and discussed at the internals mailinglist. This includes closures, traits<br />
and various other patches. Some of these patches are on hold and not yet<br />
applied. Therefore only a few people can take a look at the new features. Particularly because they scare patching PHP themselves or they run into troubles while patching. To make those patches available for a wider audience<br />
I start maintaining a PHP 5.3-exp branch containing experimental features and<br />
patches.</p>
<p>Who is the audience:</p>
<ul>
<li>(Core) Developers that don&#8217;t want to maintain their own patch series</li>
<li>Developers that want to discuss recent proposals at the mailinglist</li>
<li>PHP lovers, that want to keep up-to-date</li>
</ul>
<p>The 5.3-exp branch is available at: </p>
<p> <a href="http://git.experimentalworks.net/php-exp.git" >http://git.experimentalworks.net/php-exp.git</a></p>
<p>Latest tarballs are available at:</p>
<p> <a href="http://git.experimentalworks.net/php-exp.git" >http://git.experimentalworks.net/php-exp.git</a></p>
<p>Please notice that experimental patches are untested and therefor can cause<br />
problems. Also notice that I cannot guarantee that the patches run under every<br />
platform supported by PHP. The patchset is tested under a recent Ubuntu Linux<br />
system with latest re2c and librarys from the Ubuntu repositories.</p>
<p>Comments are welcome</p>
<p class="wp-flattr-button"></p> <p><a href="http://blog.experimentalworks.net/?flattrss_redirect&amp;id=68&amp;md5=82c8ce90354dc56cd2c7e63360f3f9c4" title="Flattr" target="_blank"><img src="http://blog.experimentalworks.net/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.experimentalworks.net/2008/07/experimental-php-53-tree/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I love you, INDEX</title>
		<link>http://blog.experimentalworks.net/2008/05/i-love-you-index/</link>
		<comments>http://blog.experimentalworks.net/2008/05/i-love-you-index/#comments</comments>
		<pubDate>Sat, 31 May 2008 20:17:39 +0000</pubDate>
		<dc:creator>dsp</dc:creator>
				<category><![CDATA[Version Control]]></category>
		<category><![CDATA[dvcs]]></category>

		<guid isPermaLink="false">http://wp.experimentalworks.net/?p=65</guid>
		<description><![CDATA[Okay, there wasn't a blog entry on git for quite a while, but well, here it is. This time about the incredible INDEX mechanism and git  add -i. I know that I annoy a lot of people out there with my beloved GIT and I just gave up with trying to explain why ...]]></description>
			<content:encoded><![CDATA[<p>Okay, there wasn&#8217;t a blog entry on git for quite a while, but well, here it is. This time about the incredible INDEX mechanism and <em>git  add -i</em>.<span id="more-65"></span> I know that I annoy a lot of people out there with my beloved GIT and I just gave up with trying to explain why GIT is just great. I&#8217;m one of those alpha geeks, and I have to realize that a lot of people out there a just too dumb to even understand subversion, so don&#8217;t expect them to get into GIT at all. But nevermind, those guys who call themself programmers and don&#8217;t like to play around  and test new tools, they are&#8230;&lt;quote&gt;stupid and ugly&lt;quote&gt; (maybe that&#8217;s a web 7.x thingy).</p>
<p>Now a few days ago I discovered <i>git add -i</i>. It&#8217;s incredible. Thanks to the staging mechanism of GIT, that acutally don&#8217;t add files straight ahead, but moreover &#8216;stage&#8217; them into an index that is compared and commited to the actual repository. It&#8217;s only important what is in the INDEX when you commit and it doesn&#8217;t count what is in your working directory. (If you don&#8217;t understand this, go ahead and READ, if you don&#8217;t do it, you are&#8230;.stu&#8230;.you know). So know here is the uber-killer-feature. </p>
<p>You can interactivly browse your patches for certain files, hunk per hunk and just commit a hunk, and not the entire file. So you changed a file and you get annoyed by a bug in another method in the same file. You don&#8217;t want do complicated things with stashing, branching, etc so you just edit the method, do a <i>git add -i</i> select the hunk that contains your changes to the method, stage it, and commit it. The other changes are completly untouched.</p>
<p>And by the way: don&#8217;t just talk about fancy new agile methods in your elite-buzzword-speech, adopt the right tools for such methods and don&#8217;t f**** around with tools that helps you to get people insane when you break dependencies during refactoring while other people need to do a pretty fast hotfix in a bigger environment, well or that &#8216;when do we merge, please don&#8217;t commit while merging, sorry I need to merge that, stop working on that&#8217; thing. It&#8217;s getting bored</p>
<p>@stop!</p>
<p class="wp-flattr-button"></p> <p><a href="http://blog.experimentalworks.net/?flattrss_redirect&amp;id=65&amp;md5=4bcf8c3d236c4de51aedbf0cd307ba6c" title="Flattr" target="_blank"><img src="http://blog.experimentalworks.net/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.experimentalworks.net/2008/05/i-love-you-index/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

