<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="4.3.4">Jekyll</generator><link href="https://chem-bla-ics.linkedchemistry.info/feed/by_tag/svn.xml" rel="self" type="application/atom+xml" /><link href="https://chem-bla-ics.linkedchemistry.info/" rel="alternate" type="text/html" /><updated>2026-08-14T05:35:03+00:00</updated><id>https://chem-bla-ics.linkedchemistry.info/feed/by_tag/svn.xml</id><title type="html">chem-bla-ics</title><subtitle>Chemblaics (pronounced chem-bla-ics) is the science that uses open science and computers to solve problems in chemistry, biochemistry and related fields.</subtitle><author><name>Egon Willighagen</name></author><entry><title type="html">CDK development with branches using Git</title><link href="https://chem-bla-ics.linkedchemistry.info/2008/09/07/cdk-development-with-branches-using-git.html" rel="alternate" type="text/html" title="CDK development with branches using Git" /><published>2008-09-07T00:00:00+00:00</published><updated>2008-09-07T00:00:00+00:00</updated><id>https://chem-bla-ics.linkedchemistry.info/2008/09/07/cdk-development-with-branches-using-git</id><content type="html" xml:base="https://chem-bla-ics.linkedchemistry.info/2008/09/07/cdk-development-with-branches-using-git.html"><![CDATA[<p><a href="http://www.steinbeck-molecular.de/steinblog/">Christoph</a> pointed me to a <a href="http://www.steinbeck-molecular.de/steinblog/index.php/2008/08/26/linus-on-git-on-google-techtalks/">video on Git by Linus</a>.
<a href="http://cdk.sf.net/">CDK</a> is now using branches extensively in development, and just set up a branch for the upcoming 1.2.0 release
later this year (end of October, see <a href="http://cdk.svn.sourceforge.net/viewvc/cdk/cdk/branches/cdk-1.2.x/">cdk-1.2.x</a>). Christoph has just
<a href="http://www.steinbeck-molecular.de/steinblog/index.php/2008/09/01/creating-and-reviewing-patches-in-the-chemistry-development-kit-cdk/">reviewed</a>
the branch containing the API move to <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Iterable.html">Iterable</a>. This patch now
allows to do this (which would really deserve a blog item by itself):</p>

<div class="language-java highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">for</span> <span class="o">(</span><span class="nc">IAtom</span> <span class="n">atom</span> <span class="o">:</span> <span class="n">molecule</span><span class="o">.</span><span class="na">atoms</span><span class="o">())</span> <span class="o">{</span>
  <span class="nc">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="s">"Symbol: "</span> <span class="o">+</span> <span class="n">atom</span><span class="o">.</span><span class="na">getSymbol</span><span class="o">());</span>
<span class="o">}</span>
</code></pre></div></div>

<p>Now, while branching in SVN is easy (<code class="language-plaintext highlighter-rouge">svn copy</code>), merging is a pain, something Miguel and I found out in the last half year, where
he and I experimented with using branches in development (see also <a href="https://chem-bla-ics.linkedchemistry.info/2008/05/02/comparing-junit-test-results-between.html">Comparing Branches <i class="fa-solid fa-recycle fa-xs"></i></a>).
We discovered that porting bug fixes from trunk to a branch, or just keeping the branch synchronized with trunk, simply does not work.
And merging itself, after a while, became a tedious process. So, when watching Linus’ movie on Git where he mentions being able to
merge several branches a day, I knew I had to switch. A full switch for the CDK <a href="http://www.steinbeck-molecular.de/steinblog/index.php/2008/08/26/linus-on-git-on-google-techtalks/#comment-1294">depends</a>
on an always accessible repository (I have been thinking about <a href="http://github.com/blog">GitHub</a>; anyone with an opinion on that?).</p>

<p>However, you can start using Git without a central Git repository, including branch support. This blog by
<a href="http://www.jukie.net/~bart/blog/svn-branches-in-git">Bart</a> has the juicy details, which I’ll apply here to CDK, for easy
copy/pasting. This replaces the earlier writing on
<a href="https://chem-bla-ics.linkedchemistry.info/2007/10/31/offline-cdk-development-using-git-svn.html">Offline CDK development using git-svn <i class="fa-solid fa-recycle fa-xs"></i></a>.</p>

<p>First step is to get yourself a Git mirror of SVN (which will take a long time; do it overnight(s)):</p>

<div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ </span>git svn clone https://cdk.svn.sourceforge.net/svnroot/cdk/cdk/ <span class="nt">-T</span> trunk <span class="nt">-b</span> branches <span class="nt">-t</span> tags
<span class="nv">$ </span>git gc
</code></pre></div></div>

<p>The second command compresses commits to reduce the size of your local Git copy, resulting in a cdk folder of about 300MB. Enter the
directory, and check that it has the default <code class="language-plaintext highlighter-rouge">master</code> branch:</p>

<div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ </span>git branch
<span class="k">*</span> master
</code></pre></div></div>

<p>In SVN one must always do a svn update before one starts coding. Similarly, in git you do (and I found this important to keep your local repository consistent):</p>

<div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ </span>git svn rebase
</code></pre></div></div>

<p>Committing has not changed, and a simple change would go via:</p>

<div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ </span>nano build.xml
<span class="nv">$ </span>git commit <span class="nt">-m</span> <span class="s2">"Changed something, but too lazy to write up what I actually changed"</span> build.xml
<span class="nv">$ </span>git svn dcommit
</code></pre></div></div>

<h2 id="branches">Branches</h2>

<p>Now, before we move to setting up branches, one must realize that there are SVN branches and (local) Git branches. Keep that in mind, and
consider that we have Git to realize how to keep them synchronized. The check the Git branches one uses <code class="language-plaintext highlighter-rouge">git branch</code> as shown above; to
view the SVN branches, however, we type (which should produce a quite long list for the CDK; only a few listed below):</p>

<div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ </span>git branch <span class="nt">-r</span>
 trunk
 tags/cdk-2003-Oct-17
 cdk-1.2.x
 mesprague-iterators
</code></pre></div></div>

<p>Here, the first is <a href="http://cdk.svn.sourceforge.net/viewvc/cdk/cdk/trunk/">CDK trunk</a>, the second a tag
<a href="http://cdk.svn.sourceforge.net/viewvc/cdk/cdk/tags/cdk-2003-Oct-17/">tags/cdk-2003-Oct-17</a>, and the last two are the branches
<a href="http://cdk.svn.sourceforge.net/viewvc/cdk/cdk/branches/cdk-1.2.x/">cdk-1.2.x</a> and <em>mesprague-iterators</em> (no longer existing).
I am not sure why the <em>branches/</em> is missing here; some git-svn magic I presume.</p>

<p>Now, to create local Git branches that are synchronized with the SVN <em>cdk-1.2.x</em> and <em>cdk-1.0.x</em> branches, we type:</p>

<div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ </span>git checkout <span class="nt">-b</span> my-local-1.2 cdk-1.2.x
<span class="nv">$ </span>git checkout <span class="nt">-b</span> my-local-1.0 cdk-1.0.x
<span class="nv">$ </span>git branch
<span class="k">*</span> master
  my-local-1.0
  my-local-1.2
</code></pre></div></div>

<p>You can now easily change branches with <code class="language-plaintext highlighter-rouge">git checkout &lt;BRANCH&gt;</code>, and check which SVN path you are working against with <code class="language-plaintext highlighter-rouge">git log -1</code>:</p>

<div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ </span>git checkout my-local-1.2
<span class="nv">$ </span>git log <span class="nt">-1</span>
commit 93bd0b22bbad31897eed6686e5b208c5e23505f7
Author: egonw
Date:   Sun Sep 7 08:13:38 2008 +0000

    Fixed inline citation <span class="o">(</span>closes <span class="c">#1987947)</span>


    git-svn-id: https://cdk.svn.sourceforge.net/svnroot/cdk/cdk/branches/cdk-1.2.x@12215 eb4e18e3-b210-0410-a6ab-dec725e4b171
</code></pre></div></div>

<p>Inspection of the output shows the <code class="language-plaintext highlighter-rouge">git-svn-id</code> line which indicates that that patch was indeed commited against <em>cdk/branches/cdk-1.2.x</em>.</p>

<p>With this set up, I can easily changes between trunk and branches, and backport patches from trunk to the <em>cdk-1.2.x</em>
branch (using <code class="language-plaintext highlighter-rouge">git cherry-pick</code>) and merge all commits to the branch into trunk using:</p>

<div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ </span>git checkout master
git merge cdk-1.2.x
</code></pre></div></div>

<p>Git does an excellent job here. It recognizes when the branch was last merged with trunk, and will not attempt to apply
patches twice. Even better, it also recognized patches that were backported from trunk to the branch, and will not attempt
to merge that either.</p>

<p>The result: I can easily merge branches now, generally speeding up CDK development! For example, it reduces the time
between someone submits a patch, and when I apply it to <em>trunk</em> (or <em>cdk-1.2.x</em> in case of a bug fix). I just set up a
local branch, apply the patch, and tune until I am happy; I do not keep trunk unstable, as I am doing this in a
separate branch. Similarly, if people develop there patch in an SVN branch, I can just as easily switch branches
(as described above) and check things, before I merge).</p>

<h2 id="setting-up-new-svn-branches">Setting up new SVN branches</h2>

<p>As far as I know, <code class="language-plaintext highlighter-rouge">git-svn</code> cannot create or delete new SVN branches. But this is easy enough with SVN command:</p>

<div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ </span>svn copy https://cdk.svn.sourceforge.net/svnroot/cdk/cdk/trunk https://cdk.svn.sourceforge.net/svnroot/cdk/cdk/branches/egonw-mynewbranch
<span class="nv">$ </span>git svn fetch
<span class="nv">$ </span>git checkout <span class="nt">-b</span> my-local-newbranch egonw-mynewbranch
<span class="nv">$ </span><span class="c"># hack in my-local-newbranch</span>
<span class="nv">$ </span>git commit <span class="nt">-a</span>
<span class="nv">$ </span>git svn dcommit
<span class="nv">$ </span>git checkout master
<span class="nv">$ </span>git merge my-local-newbranch
<span class="nv">$ </span>svn remove https://cdk.svn.sourceforge.net/svnroot/cdk/cdk/branches/egonw-mynewbranch
</code></pre></div></div>

<p>Enough for now.</p>]]></content><author><name>Egon Willighagen</name></author><category term="cdk" /><category term="svn" /><summary type="html"><![CDATA[Christoph pointed me to a video on Git by Linus. CDK is now using branches extensively in development, and just set up a branch for the upcoming 1.2.0 release later this year (end of October, see cdk-1.2.x). Christoph has just reviewed the branch containing the API move to Iterable. This patch now allows to do this (which would really deserve a blog item by itself):]]></summary></entry><entry><title type="html">Offline CDK development using git-svn</title><link href="https://chem-bla-ics.linkedchemistry.info/2007/10/31/offline-cdk-development-using-git-svn.html" rel="alternate" type="text/html" title="Offline CDK development using git-svn" /><published>2007-10-31T00:00:00+00:00</published><updated>2007-10-31T00:00:00+00:00</updated><id>https://chem-bla-ics.linkedchemistry.info/2007/10/31/offline-cdk-development-using-git-svn</id><content type="html" xml:base="https://chem-bla-ics.linkedchemistry.info/2007/10/31/offline-cdk-development-using-git-svn.html"><![CDATA[<p>While <a href="http://subversion.tigris.org/">Subversion</a> is a signification improvement over <a href="http://www.nongnu.org/cvs/">CVS</a>, they both require a
central server. That is, they do not allow me to commit changes when I am not connected to that server. This is annoying when being on a
long train ride, or somewhere else without internet connectivity. I can pile up all my changes, but that would yield one big ugly patch.</p>

<p>Therefore, I tried <a href="http://www.selenic.com/mercurial/wiki/">Mercurial</a> where each client is server too. The version I used, however, did
not have the move command, so it put me back into the old CVS days where I lost the history of a file when I reorganize my archive.</p>

<h2 id="git">Git</h2>

<p>Then <a href="http://git.or.cz/">Git</a>, the version control system developed by <a href="http://en.wikipedia.org/wiki/Linus_Torvalds">Linus Torvalds</a> when he
found that existing tools did not do what he wanted to do. It seems a rather good product, though with a somewhat larger learning curve,
because of the far more flexible architecture (see <a href="http://www.kernel.org/pub/software/scm/git/docs/tutorial.html">this tutorial</a>).
Well, <a href="http://kernel.org/doc/local/git-quick.html">it works for the Linux kernel</a>, so must be good :)</p>

<p>Now, <a href="http://www.sf.net/">SourceForge</a> does not have Git support yet, so we use Subversion. <a href="http://www.flavio.castelli.name/">Flavio</a>,
of <a href="http://strigi.sf.net/">Strigi</a> fame, however, <a href="http://www.flavio.castelli.name/howto_use_git_with_svn">introduced me to git-svn</a>.
Almost two month ago, already, but finally made some time to try it out. I think I like it.</p>

<p>This is what I did to make <a href="http://cdk.svn.sourceforge.net/viewvc/cdk/trunk/cdk/.classpath?r1=8523&amp;r2=9271">a commit to CDKs SVN repository</a>:</p>

<div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ </span><span class="nb">sudo </span>aptitude <span class="nb">install </span>git-svn git-core
<span class="nv">$ </span><span class="nb">mkdir</span> <span class="nt">-p</span> git-svn/cdk-trunk
<span class="nv">$ </span><span class="nb">cd </span>git-svn/cdk-trunk
<span class="nv">$ </span>git-svn init https://cdk.svn.sourceforge.net/svnroot/cdk/trunk/cdk
<span class="nv">$ </span>git-svn fetch <span class="nt">-rHEAD</span>
<span class="nv">$ </span>nano .classpath
<span class="nv">$ </span>git add .classpath
<span class="nv">$ </span>git commit
<span class="nv">$ </span>git-svn dcommit
</code></pre></div></div>

<p>The first git-svn command initializes a log Git repository based on the SVN repository. The <code class="language-plaintext highlighter-rouge">git-svn fetch</code> command makes a local copy of
the SVN repository content defined in the previous command. Local changes are, by default, not commited; unless one explicitly git adds
them to a patch. Once a patch is ready you can do all sorts of interesting things with them, among with commit them to the local Git
repository with <code class="language-plaintext highlighter-rouge">git commit</code>.</p>

<p>Now, these kind of commits are on the local repository, and I do not require internet access for that. When I am connected again, I can
synchronize my local changes with the SVN repository with the <code class="language-plaintext highlighter-rouge">git-svn dcommit</code> command.</p>

<p>A final important command is <code class="language-plaintext highlighter-rouge">git-svn rebase</code>, which is used to update the local git command for changes others made to the SVN repository.</p>]]></content><author><name>Egon Willighagen</name></author><category term="git" /><category term="svn" /><category term="cdk" /><summary type="html"><![CDATA[While Subversion is a signification improvement over CVS, they both require a central server. That is, they do not allow me to commit changes when I am not connected to that server. This is annoying when being on a long train ride, or somewhere else without internet connectivity. I can pile up all my changes, but that would yield one big ugly patch.]]></summary></entry><entry><title type="html">Machine crash; SVN went along</title><link href="https://chem-bla-ics.linkedchemistry.info/2005/11/23/machine-crash-svn-went-along.html" rel="alternate" type="text/html" title="Machine crash; SVN went along" /><published>2005-11-23T00:00:00+00:00</published><updated>2005-11-23T00:00:00+00:00</updated><id>https://chem-bla-ics.linkedchemistry.info/2005/11/23/machine-crash-svn-went-along</id><content type="html" xml:base="https://chem-bla-ics.linkedchemistry.info/2005/11/23/machine-crash-svn-went-along.html"><![CDATA[<p>Doesn’t happen often, but my machine crashed two hours ago. Not a big deal, because I have my important files in SVN. Oh wait, SVN had a commit
in progress during the crash. So, <code class="language-plaintext highlighter-rouge">svn recover</code>. Mmmm… doesn’t work either. OK, SVN FAQ: try <code class="language-plaintext highlighter-rouge">db_recover</code>. That worked. No, it did not:
<code class="language-plaintext highlighter-rouge">svn commit</code> still not working for the files I was trying to commit. Fortunately, I make regular SVN db backups so I created a brand new
SVN repository from scratch and recovered the back up. That worked. Really.</p>]]></content><author><name>Egon Willighagen</name></author><category term="svn" /><summary type="html"><![CDATA[Doesn’t happen often, but my machine crashed two hours ago. Not a big deal, because I have my important files in SVN. Oh wait, SVN had a commit in progress during the crash. So, svn recover. Mmmm… doesn’t work either. OK, SVN FAQ: try db_recover. That worked. No, it did not: svn commit still not working for the files I was trying to commit. Fortunately, I make regular SVN db backups so I created a brand new SVN repository from scratch and recovered the back up. That worked. Really.]]></summary></entry></feed>