<?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>Luanatic with features &#187; subversion</title>
	<atom:link href="http://www.pplux.com/category/subversion/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.pplux.com</link>
	<description>PpluX &#039;s blog</description>
	<lastBuildDate>Mon, 11 May 2009 08:21:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>from subversion to git</title>
		<link>http://www.pplux.com/2008/11/26/from-subversion-to-git/</link>
		<comments>http://www.pplux.com/2008/11/26/from-subversion-to-git/#comments</comments>
		<pubDate>Wed, 26 Nov 2008 14:55:55 +0000</pubDate>
		<dc:creator>PpluX</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[recetas]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[SCM]]></category>

		<guid isPermaLink="false">http://www.pplux.com/?p=194</guid>
		<description><![CDATA[Recently I&#8217;ve been playing with git and I found it fascinating!, for those that still don&#8217;t know what it is, git is a really fast distributed revision control system (wikipedia). Now the problem is how to switch from subversion to git, fortunately git-svn helps a lot and we can play with git and subversion in [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I&#8217;ve been playing with git and I found it fascinating!, for those that still don&#8217;t know what it is, git is a really fast distributed revision control system (<a href="http://en.wikipedia.org/wiki/Git_%28software%29">wikipedia</a>). Now the problem is how to switch from subversion to git, fortunately <a href="http://www.kernel.org/pub/software/scm/git/docs/git-svn.html">git-svn</a> helps a lot and we can play with git and subversion in many ways. Let&#8217;s talk about them from the easiest to the not-so-easy way. I&#8217;m supposing here that you want to move from a centralized subversion to a git repository that probably will be online on a server.</p>
<h2>Complete migration from subversion to git</h2>
<p>This is for those that want to throw  subversion away completely, for some reason this is the easiest way to switch. First what you would do on the server:</p>
<p><code><span class="blue"># first clone the repository from subversion<br />
#  if you can use file:// it will be faster,<br />
#  otherwise use </span><span class="red">http://your-project-url.com/svn/MySuperProject </span><br />
[server]$ git svn clone -s <span class="red">file:///home/pplux/.../svn/MySuperProject</span> tmp<br />
<span class="blue"># clone to a bare new git repository (with no track of subversion)</span><br />
[server]$ git clone --bare file://`pwd`/tmp MySuperProject<br />
<span class="blue"># remove the old git repo from subversion, no longer needed</span><br />
[server]$ rm -rf tmp/<br />
<span class="blue"># update server info, for "dumb" servers this is needed</span><br />
[server]$ cd MySuperProject/<br />
[server]$ git --bare update-server-info<br />
</code></p>
<p>Now clients can simple clone your repository and start working:<br />
<code><span class="blue"># use this for normal-read-only, or maybe you could use ssh://<br />
#   if you plan to upload data.</span><br />
[client] $ git clone <span class="green">http://your-server-url.com/git/MySuperProject</span><br />
</code></p>
<h2>Mirroring the subversion repository and keep subversion</h2>
<p>Here we want to keep the subversion repository like the main reference of the project, but let people (or ourselves) use git for development. The reason to mirror the subversion is just a matter of speed, it is much faster to clone an existing git repository than cloning from subversion each time. </p>
<p>Here we will need to do a bit more of work, but it&#8217;s a much smoother way to migrate from subversion to git. First what we need to do on the server:</p>
<p><code><span class="blue"># Create and initialize a bare git repository</span><br />
[server]$ mkdir MySuperProject[server]$ cd MySuperProject/<br />
[server]$ git --bare init<br />
Initialized empty Git repository in /home/pplux/.../MySuperProject/<br />
<br/><br />
<span class="blue"># set svn project to import</span><br />
[server]$ git --bare svn init -s <span class="red">http://your-server-url.com/svn/MySuperProject</span><br />
<br/><br />
<span class="blue"># fetch svn data (sloooow)</span><br />
[server]$ git --bare svn fetch --all<br />
    A   src/CMakeLists.txt<br />
        A   CMakeLists.txt<br />
        W: +empty_dir: trunk/include<br />
...<br />
<br/><br />
<span class="blue"># auxiliary files to help "dumb" servers</span><br />
[server]$ git --bare update-server-info<br />
</code></p>
<p>Now the client, here we will do much more work than before to setup both the origin from the git mirror and the subversion config to commit there future changes.</p>
<p><code><span class="blue"># Create and initialize our copy of the git repository</span><br />
[client] $ mkdir MySuperProject<br />
[client] $ cd MySuperProject/<br />
[client] $ git init<br />
Initialized empty Git repository in /Users/pplux/projects/MySuperProject/.git/<br />
<br/><br />
<span class="blue"># setup the server as the initial origin of data</span><br />
[client] $ git remote add origin <span class="green">http://your-server-url.com/git/MySuperProject</span><br />
<br/><br />
<span class="blue"># also tell git to fecth data from the remote origin(that case svn)</span><br />
[client] $ git config --add remote.origin.fetch '+refs/remotes/*:refs/remotes/*'<br />
<br/><br />
<span class="blue"># fetch data from the git mirror(takes a bit)</span><br />
[client] $ git fetch<br />
got 2c68737541f19685f667f601a502447425d1fcfe<br />
walk 2c68737541f19685f667f601a502447425d1fcfe<br />
got d4916373650b9bb636c0284dd501e6c7bfa8e304<br />
got 13af9568120f8e7771bd386d9b7dadf69f1181cb<br />
...<br />
<br/><br />
<span class="blue"># setup the original subversion as</span><br />
[client] $ git svn -s init <span class="red">http://your-server-url.com/svn/MySuperProject</span><br />
<br/><br />
<span class="blue"># rebuild data...</span><br />
[client] $ git svn fetch<br />
Rebuilding .git/svn/trunk/.rev_map.1a3bf6a2-ba3d-0410-9263-a3f888f14dcd ...<br />
r1 = 126490373bfbc2a770d762398b67fffeef73bead<br />
r2 = a2288725c8c68ef426b97cf2b28a9135a34734d3<br />
r3 = 4158b92a5c68489bb6ff2b4f4567cf8f830d7282<br />
<br/><br />
<span class="blue"># to start working create a master that will track "trunk"</span><br />
[client] $ git checkout -b master -t trunk<br />
</code></p>
<h2> Reasons for switching to git </h2>
<p>The post ends here you can safely stop reading now, but if you ask me, there are some good reasons to switch to git:</p>
<ul>
<li> it&#8217;s faster, not only faster when doing actual SCM work, it allows you to develop faster, no need to wait while the commit is transmitted to the server, you can work offline wherever you are&#8230; </li>
<li> it works well with subversion, you can use it even if the main project never moves from a subversion repository or you are the only one using git while everybody else is using subversion </li>
<li> you don&#8217;t need to develop a full feature before a commit, you can work on your own doing commits often without worrying about anybody else.</li>
<li> git is meant to work on branches, this is a different approach from the normal subversion use, with git you are supposed to work on branches, and it&#8217;s great! I like to develop different &#8220;features&#8221; on different branches, I can switch the branch, do several things at the same time&#8230; and so on.</li>
<li>you have the whole history, not just the last commit.</li>
<li>it&#8217;s secure, you don&#8217;t need several people to share the same repository, git &#8220;default&#8221; model works in a different way where each person has its own public git. But, everything in git is hashed, even branches, so you can easily check if your private git has the same things as the remote git (that&#8217;s difficult to achieve with subversion)</li>
<li> it&#8217;s like vim vs notepad! I like git because is fun, it can do many many things, and it&#8217;s always good to have something new to play with.</li>
<li> if CVS was for dinosaurs when you started using SVN, now SVN is for the Neanderthals&#8230; so start using git!</li>
<li> You don&#8217;t have to be a ruby developer to use git! git is another SCM&#8230; not the cool tool just for cool ruby developers&#8230; come on.</li>
<li> Because Linus Torvalds made it:<br/><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/4XpnKHJAok8&#038;hl=es&#038;fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/4XpnKHJAok8&#038;hl=es&#038;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object></li>
<li> &#8230; well, maybe Linus is not a good reason to use it&#8230; I don&#8217;t fancy calling people ugly and idiot, anyway git is great.</li>
</ul>
<p>And big thanks to <a href="http://slack.codemaniacs.com/">slack</a> for pointing me out git, if he says something is good stuff&#8230; believe him <img src='http://www.pplux.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Other good links about what we&#8217;ve talked here:</p>
<p><a href="http://www.gnome.org/~federico/news-2008-11.html#27">http://www.gnome.org/~federico/news-2008-11.html#27</a><br />
<a href="http://markmcb.com/tag/workflow/">http://markmcb.com/tag/workflow/</a><br />
<a href="http://utsl.gen.nz/talks/git-svn/intro.html#howto-track-rebuildmeta">http://utsl.gen.nz/talks/git-svn/intro.html#howto-track-rebuildmeta</a><br />
<a href="http://www.viget.com/extend/effectively-using-git-with-subversion/">http://www.viget.com/extend/effectively-using-git-with-subversion/</a><br />
<a href="http://techbase.kde.org/Development/Tutorials/Git#Interfacing_KDE.27s_SVN_repository_with_git-svn">http://techbase.kde.org/Development/Tutorials/Git#Interfacing_KDE.27s_SVN_repository_with_git-svn</a><br />
<a href="http://live.gnome.org/GitForGnomeDevelopers">http://live.gnome.org/GitForGnomeDevelopers</a><br />
<a href="http://tsunanet.blogspot.com/2007/07/learning-git-svn-in-5min.html">http://tsunanet.blogspot.com/2007/07/learning-git-svn-in-5min.html</a><br />
<a href="http://blogs.gnome.org/johncarr/2008/06/21/git-mirrorgnomeorg/">http://blogs.gnome.org/johncarr/2008/06/21/git-mirrorgnomeorg/</a><br />
<a href="http://markmcb.com/2008/09/17/migrating-a-subversion-svn-project-and-server-to-git/">http://markmcb.com/2008/09/17/migrating-a-subversion-svn-project-and-server-to-git/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.pplux.com/2008/11/26/from-subversion-to-git/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Snapshots automáticos de SVN</title>
		<link>http://www.pplux.com/2007/07/10/snapshots-automaticos-de-svn/</link>
		<comments>http://www.pplux.com/2007/07/10/snapshots-automaticos-de-svn/#comments</comments>
		<pubDate>Tue, 10 Jul 2007 15:44:03 +0000</pubDate>
		<dc:creator>PpluX</dc:creator>
				<category><![CDATA[recetas]]></category>
		<category><![CDATA[subversion]]></category>

		<guid isPermaLink="false">http://www.pplux.com/2007/07/10/snapshots-automaticos-de-svn/</guid>
		<description><![CDATA[Los repositorios de subversion tienen, además de una base de datos con toda la información, un directorio especial por repositorio llamado hooks donde podemos escribir scripts que se ejecutarán en diferentes situaciones. Estos scripts (bueno, o programas) pueden desde abortar un commit, a cambiar cosas, añadir información, cambiar propiedades, etc&#8230; En nuestro caso vamos a [...]]]></description>
			<content:encoded><![CDATA[<p>Los repositorios de subversion tienen, además de una base de datos con toda la información, un directorio especial por repositorio llamado <em><a href="http://svnbook.red-bean.com/nightly/en/svn.reposadmin.create.html#svn.reposadmin.create.hooks">hooks</a></em> donde podemos escribir scripts que se ejecutarán en diferentes situaciones. Estos scripts (bueno, o programas) pueden desde abortar un commit, a cambiar cosas, añadir información, cambiar propiedades, etc&#8230; En nuestro caso vamos a usar el <em> hook </em> de <em> post-commit</em> para generar un <em>snapshot</em> automático con cada nuevo <em>tag</em>.</p>
<p>Vamos a suponer que tenemos un repositorio con múltiples proyectos, cada uno de ellos con sus correspondientes &#8216;trunk&#8217;, &#8216;tags&#8217;, &#8216;branches&#8217; como dice el <a href="http://svnbook.red-bean.com/">libro  de subversion</a>. De algunos de ellos queremos hacer snapshots cuando se marque un nuevo tag, así que pondremos en el directorio <em>hooks</em> el siguiente script llamado post-commit ( se tiene que llamar así y además tiene que ser ejecutable, chmod +x):</p>
<p> <code><br />
<font color="#00ffff"><b>#!/bin/bash</b></font><br />
<font color="#ffff00"><b>export </b></font>PATH<font color="#ffff00"><b>=</b></font>/usr/bin<b>:</b>/bin<br />
REPOS<font color="#ffff00"><b>=</b></font><font color="#ff40ff"><b>&quot;</b></font><font color="#ff6060"><b>$1</b></font><font color="#ff40ff"><b>&quot;</b></font><br />
REV<font color="#ffff00"><b>=</b></font><font color="#ff40ff"><b>&quot;</b></font><font color="#ff6060"><b>$2</b></font><font color="#ff40ff"><b>&quot;</b></font><br />
PREFIXES<font color="#ffff00"><b>=</b></font><font color="#ff40ff"><b>&quot;/proyecto1 /proyecto2 /proyectoN&quot;</b></font><br />
OUTPUT_DIR<font color="#ffff00"><b>=</b></font>/path/donde/se/guardara/el/zip<br />
<font color="#ffff00"><b>for</b></font> PREFIX <font color="#ffff00"><b>in</b></font> $PREFIXES<font color="#ffff00"><b>;</b></font> <font color="#ffff00"><b>do</b></font><br />
   <font color="#ffff00"><b>for</b></font> tag <font color="#ffff00"><b>in</b></font> $<font color="#ffff00"><b>(</b></font>\<br />
         svn log -v <font color="#ffff00"><b>-r</b></font> <font color="#ff6060"><b>$REV</b></font> file://<font color="#ff6060"><b>$REPOS</b></font> <font color="#ffff00"><b>|</b></font> \\<br />
         awk <font color="#ff40ff"><b>'/^ *A */{if ($2~/'</b></font><font color="#ff6060"><b>${PREFIX//\\//\\\\/}</b></font><font color="#ff40ff"><b>'\\/tags\\/[^\\/]*$/) print $2;}/^$/{exit}'</b></font>\\<br />
         <font color="#ffff00"><b>);</b></font> <font color="#ffff00"><b>do</b></font><br />
      file<font color="#ffff00"><b>=</b></font><font color="#ff6060"><b>${tag##*/}</b></font><br />
      svn <font color="#ffff00"><b>-r</b></font> <font color="#ff6060"><b>$REV</b></font> <font color="#ffff00"><b>export</b></font> file://<font color="#ff6060"><b>$REPOS</b></font>/<font color="#ff6060"><b>$tag</b></font> <font color="#ff6060"><b>$file</b></font><br />
      zip -rm <font color="#ff6060"><b>$OUTPUT_DIR</b></font>/<font color="#ff6060"><b>$file</b></font>.zip <font color="#ff6060"><b>$file</b></font><br />
   <font color="#ffff00"><b>done</b></font><br />
<font color="#ffff00"><b>done</b></font><br />
</code><br />
<a href="/files/post-commit_v1.sh">(bajar) versión completa</a></p>
<p>Si tu repositorio sólo tiene un proyecto, se puede simplificar un poco más:</p>
<p> <code><br />
<font color="#00ffff"><b>#!/bin/bash</b></font><br />
<font color="#ffff00"><b>export </b></font>PATH<font color="#ffff00"><b>=</b></font>/usr/bin<b>:</b>/bin<br />
REPOS<font color="#ffff00"><b>=</b></font><font color="#ff40ff"><b>&quot;</b></font><font color="#ff6060"><b>$1</b></font><font color="#ff40ff"><b>&quot;</b></font><br />
REV<font color="#ffff00"><b>=</b></font><font color="#ff40ff"><b>&quot;</b></font><font color="#ff6060"><b>$2</b></font><font color="#ff40ff"><b>&quot;</b></font><br />
OUTPUT_DIR<font color="#ffff00"><b>=</b></font>/path/donde/se/guardara/el/zip<br />
   <font color="#ffff00"><b>for</b></font> tag <font color="#ffff00"><b>in</b></font> $<font color="#ffff00"><b>(</b></font>\<br />
         svn log -v <font color="#ffff00"><b>-r</b></font> <font color="#ff6060"><b>$REV</b></font> file://<font color="#ff6060"><b>$REPOS</b></font> <font color="#ffff00"><b>|</b></font> \\<br />
         awk <font color="#ff40ff"><b>'/^ *A */{if ($2~/\\/tags\\/[^\\/]*$/) print $2;}/^$/{exit}'</b></font>\\<br />
         <font color="#ffff00"><b>);</b></font> <font color="#ffff00"><b>do</b></font><br />
      file<font color="#ffff00"><b>=</b></font><font color="#ff6060"><b>${tag##*/}</b></font><br />
      svn <font color="#ffff00"><b>-r</b></font> <font color="#ff6060"><b>$REV</b></font> <font color="#ffff00"><b>export</b></font> file://<font color="#ff6060"><b>$REPOS</b></font>/<font color="#ff6060"><b>$tag</b></font> <font color="#ff6060"><b>$file</b></font><br />
      zip -rm <font color="#ff6060"><b>$OUTPUT_DIR</b></font>/<font color="#ff6060"><b>$file</b></font>.zip <font color="#ff6060"><b>$file</b></font><br />
   <font color="#ffff00"><b>done</b></font><br />
</code><br />
<a href="/files/post-commit_v2.sh">(bajar) versión simplificada</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.pplux.com/2007/07/10/snapshots-automaticos-de-svn/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>svn:externals re-utiliza tus repositorios.</title>
		<link>http://www.pplux.com/2007/02/28/svnexternals-re-utiliza-tus-repositorios/</link>
		<comments>http://www.pplux.com/2007/02/28/svnexternals-re-utiliza-tus-repositorios/#comments</comments>
		<pubDate>Wed, 28 Feb 2007 16:57:38 +0000</pubDate>
		<dc:creator>PpluX</dc:creator>
				<category><![CDATA[recetas]]></category>
		<category><![CDATA[subversion]]></category>

		<guid isPermaLink="false">http://www.pplux.com/2007/02/28/svnexternals-re-utiliza-tus-repositorios/</guid>
		<description><![CDATA[Los programadores con algo de experiencia tendemos a dar todas las vueltas del mundo necesarias antes de repetir código, por lo que también es normal que tengamos tendencia a separar un proyecto grande en varios más pequeños por aquello de reutilizar código. Por ejemplo, en un repositorio tengo una librería que utilizo para muchos de [...]]]></description>
			<content:encoded><![CDATA[<p>Los programadores con algo de experiencia tendemos a dar todas las vueltas del mundo necesarias antes de repetir código, por lo que también es normal que tengamos tendencia a separar un proyecto grande en varios más pequeños por aquello de  reutilizar código. </p>
<p>Por ejemplo, en un repositorio tengo una librería que utilizo para muchos de mis proyectos, llamada SLB, y en otro repositorio tengo mi proyecto killer-ap1. El proyecto de killer-ap1 utiliza activamente SLB, hasta el punto de que voy haciendo mejoras en SLB según veo que hacen falta en killer-ap1&#8230; por lo que suelo copiar SLB enterito dentro de killer-ap1 y compilarlo todo a la vez.</p>
<blockquote><p>
$ls proyectos/killer-ap1<br />
    src<br />
    include<br />
    SLB (mi copia particular)
</p></blockquote>
<p>El problema es que esta copia esta versionada una vez en el repositorio oficial y otras tantas en cada uno de los proyectos donde la uso, concretamente en killer-ap1. Además hay que acordarse de mantener actualizadas todas esas copias&#8230; por ello los de <a href="http://subversion.tigris.org/">subversion</a> idearon una solución mejor, los <a href="http://svnbook.red-bean.com/en/1.0/ch07s03.html">svn:externals</a>.</p>
<p>La propiedad svn:externals nos permite enlazar en un repositorio con otros externos a este, de forma que cuando se haga un checkout del nuestro automáticamente también se bajará los otros. Ejemplo (de la página del svnbook):</p>
<blockquote><p>
$ svn propget svn:externals calc<br />
third-party/sounds             http://sounds.red-bean.com/repos<br />
third-party/skins              http://skins.red-bean.com/repositories/skinproj<br />
third-party/skins/toolkit -r21 http://svn.red-bean.com/repos/skin-maker
</p></blockquote>
<p>Con esto estamos diciendo que el directorio calc tiene dentro tres directorios &#8216;thir-party/sounds&#8217; &#8216;third-party/skins&#8217; y &#8216;third-party/skins/toolkit&#8217; que hacen referencia a repositorios externos(y en el último caso una revisión concreta la 21). También le estamos diciendo a subversion que cuando pase por calc se baje automáticamente los repositorios externos, y que los mantenga sincronizados.</p>
<p>Para mi caso de killer-ap1 y SLB la cosa ha sido así:</p>
<blockquote><p>svn propset svn:externals &#8220;SLB http://svn.pplux.com/SLB/trunk&#8221; path/de/killer_ap1</p></blockquote>
<p>Esta línea dice: &#8220;en el raiz de killer-ap1 vas a poner un directorio &#8220;SLB&#8221; que está sincronizado con el repositorio http://&#8230;&#8221;</p>
<p>Si en vez de uno tienes varios, los separamos con &#8220;\n&#8221;, el ejemplo del svnbook hubiera sido algo como:</p>
<blockquote><p>svn propset svn:externals &#8220;third-party/sounds http://sounds.red-bean.com/repos\n third-party/skins http://skins.red-bean.com/repositories/skinproj\n third-party/skins/toolkit -r21 http://svn.red-bean.com/repos/skin-maker&#8221; calc
</p></blockquote>
<p>Un poco largo pero ilustra lo que se pretende, tener más de un external en un mismo directorio.</p>
<p>Y lo mejor de todo, que todas las copias siempre están sincronizadas, ya sean externals o no <img src='http://www.pplux.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.pplux.com/2007/02/28/svnexternals-re-utiliza-tus-repositorios/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

