{
  "version": "https://jsonfeed.org/version/1.1",
  "title": "chem-bla-ics",
  "description": "Chemblaics (pronounced chem-bla-ics) is the science that uses open science and computers to solve problems in chemistry, biochemistry and related fields.",
  "home_page_url": "https://chem-bla-ics.linkedchemistry.info/",
  "feed_url": "https://chem-bla-ics.linkedchemistry.info/2008/09/07/cdk-development-with-branches-using-git.json",
  "icon": "https://chem-bla-ics.linkedchemistry.info/assets/images/chem-bla-ics_logo.png",
  "language": "en",
  "authors": [
    {
      "name": "Egon Willighagen",
      "url": "https://orcid.org/0000-0001-7542-0286",
      "_orcid": "0000-0001-7542-0286"
    }
  ],
  "items": [

    {
      "id": "https://doi.org/10.59350/vt3yd-8nb03",
      "url": "https://chem-bla-ics.linkedchemistry.info/2008/09/07/cdk-development-with-branches-using-git.html",
      "title": "CDK development with branches using Git",
      "content_html": "<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>.\n<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\nlater 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\n<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>\nthe 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\nallows to do this (which would really deserve a blog item by itself):</p>\n\n<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>\n  <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>\n<span class=\"o\">}</span>\n</code></pre></div></div>\n\n<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\nhe 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>).\nWe discovered that porting bug fixes from trunk to a branch, or just keeping the branch synchronized with trunk, simply does not work.\nAnd merging itself, after a while, became a tedious process. So, when watching Linus’ movie on Git where he mentions being able to\nmerge 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>\non an always accessible repository (I have been thinking about <a href=\"http://github.com/blog\">GitHub</a>; anyone with an opinion on that?).</p>\n\n<p>However, you can start using Git without a central Git repository, including branch support. This blog by\n<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\ncopy/pasting. This replaces the earlier writing on\n<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>\n\n<p>First step is to get yourself a Git mirror of SVN (which will take a long time; do it overnight(s)):</p>\n\n<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\n<span class=\"nv\">$ </span>git gc\n</code></pre></div></div>\n\n<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\ndirectory, and check that it has the default <code class=\"language-plaintext highlighter-rouge\">master</code> branch:</p>\n\n<div class=\"language-shell highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"nv\">$ </span>git branch\n<span class=\"k\">*</span> master\n</code></pre></div></div>\n\n<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>\n\n<div class=\"language-shell highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"nv\">$ </span>git svn rebase\n</code></pre></div></div>\n\n<p>Committing has not changed, and a simple change would go via:</p>\n\n<div class=\"language-shell highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"nv\">$ </span>nano build.xml\n<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\n<span class=\"nv\">$ </span>git svn dcommit\n</code></pre></div></div>\n\n<h2 id=\"branches\">Branches</h2>\n\n<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\nconsider 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\nview the SVN branches, however, we type (which should produce a quite long list for the CDK; only a few listed below):</p>\n\n<div class=\"language-shell highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"nv\">$ </span>git branch <span class=\"nt\">-r</span>\n trunk\n tags/cdk-2003-Oct-17\n cdk-1.2.x\n mesprague-iterators\n</code></pre></div></div>\n\n<p>Here, the first is <a href=\"http://cdk.svn.sourceforge.net/viewvc/cdk/cdk/trunk/\">CDK trunk</a>, the second a tag\n<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\n<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).\nI am not sure why the <em>branches/</em> is missing here; some git-svn magic I presume.</p>\n\n<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>\n\n<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\n<span class=\"nv\">$ </span>git checkout <span class=\"nt\">-b</span> my-local-1.0 cdk-1.0.x\n<span class=\"nv\">$ </span>git branch\n<span class=\"k\">*</span> master\n  my-local-1.0\n  my-local-1.2\n</code></pre></div></div>\n\n<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>\n\n<div class=\"language-shell highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"nv\">$ </span>git checkout my-local-1.2\n<span class=\"nv\">$ </span>git log <span class=\"nt\">-1</span>\ncommit 93bd0b22bbad31897eed6686e5b208c5e23505f7\nAuthor: egonw\nDate:   Sun Sep 7 08:13:38 2008 +0000\n\n    Fixed inline citation <span class=\"o\">(</span>closes <span class=\"c\">#1987947)</span>\n\n\n    git-svn-id: https://cdk.svn.sourceforge.net/svnroot/cdk/cdk/branches/cdk-1.2.x@12215 eb4e18e3-b210-0410-a6ab-dec725e4b171\n</code></pre></div></div>\n\n<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>\n\n<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>\nbranch (using <code class=\"language-plaintext highlighter-rouge\">git cherry-pick</code>) and merge all commits to the branch into trunk using:</p>\n\n<div class=\"language-shell highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"nv\">$ </span>git checkout master\ngit merge cdk-1.2.x\n</code></pre></div></div>\n\n<p>Git does an excellent job here. It recognizes when the branch was last merged with trunk, and will not attempt to apply\npatches twice. Even better, it also recognized patches that were backported from trunk to the branch, and will not attempt\nto merge that either.</p>\n\n<p>The result: I can easily merge branches now, generally speeding up CDK development! For example, it reduces the time\nbetween 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\nlocal branch, apply the patch, and tune until I am happy; I do not keep trunk unstable, as I am doing this in a\nseparate branch. Similarly, if people develop there patch in an SVN branch, I can just as easily switch branches\n(as described above) and check things, before I merge).</p>\n\n<h2 id=\"setting-up-new-svn-branches\">Setting up new SVN branches</h2>\n\n<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>\n\n<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\n<span class=\"nv\">$ </span>git svn fetch\n<span class=\"nv\">$ </span>git checkout <span class=\"nt\">-b</span> my-local-newbranch egonw-mynewbranch\n<span class=\"nv\">$ </span><span class=\"c\"># hack in my-local-newbranch</span>\n<span class=\"nv\">$ </span>git commit <span class=\"nt\">-a</span>\n<span class=\"nv\">$ </span>git svn dcommit\n<span class=\"nv\">$ </span>git checkout master\n<span class=\"nv\">$ </span>git merge my-local-newbranch\n<span class=\"nv\">$ </span>svn remove https://cdk.svn.sourceforge.net/svnroot/cdk/cdk/branches/egonw-mynewbranch\n</code></pre></div></div>\n\n<p>Enough for now.</p>",
      "summary": "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):",
      
      "date_published": "2008-09-07T00:00:00+00:00",
      "date_modified": "2025-10-11T00:00:00+00:00",
      "tags": ["cdk","svn"],
      
      
      
      
      
      
        "authors": [ { "name": "Egon Willighagen", "url": "https://orcid.org/0000-0001-7542-0286" } ]
      
    }

  ]
}
