<?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>Jetpack Flight Log &#187; svn</title>
	<atom:link href="http://jetpackweb.com/blog/tags/svn/feed/" rel="self" type="application/rss+xml" />
	<link>http://jetpackweb.com/blog</link>
	<description>Rock{et}ing the interweb</description>
	<lastBuildDate>Wed, 19 May 2010 22:21:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Pimp your $PS1 with source control information</title>
		<link>http://jetpackweb.com/blog/2010/01/08/pimp-your-ps1-with-source-control-information/</link>
		<comments>http://jetpackweb.com/blog/2010/01/08/pimp-your-ps1-with-source-control-information/#comments</comments>
		<pubDate>Sat, 09 Jan 2010 02:17:09 +0000</pubDate>
		<dc:creator>Brian Racer</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[cvs]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[hg]]></category>
		<category><![CDATA[mercurial]]></category>
		<category><![CDATA[svn]]></category>
		<category><![CDATA[zsh]]></category>

		<guid isPermaLink="false">http://jetpackweb.com/blog/?p=623</guid>
		<description><![CDATA[I recently found a useful tip of appending source control information of the current working directory to your shell&#8217;s $PS1 line. It might look something like the following image: The method I saw suggested using vcprompt, a small program that outputs a short string basic version control info. Although it worked well, there were a [...]]]></description>
			<content:encoded><![CDATA[<p>I recently found a useful tip of appending source control information of the current working directory to your shell&#8217;s $PS1 line. It might look something like the following image:</p>
<p><img src="http://jetpackweb.com/blog/wp-content/uploads/2010/01/Screenshot-Terminal.png" /></p>
<p> The method I saw suggested using <a href="http://vc.gerg.ca/hg/vcprompt/" target="_blank">vcprompt</a>, a small program that outputs a short string basic version control info. Although it worked well, there were a couple issues I had with it. First, it&#8217;s subversion support was somewhat lacking. Second, it was written in C which made it more of a pain to modify, and I wasn&#8217;t a huge fan of keeping the binary in version control. </p>
<p>After a little searching I stumbled across <a href="http://github.com/xvzf/vcprompt">vcprompt.py</a>, a python script that did the same thing. This version also had wider support for source control systems, and being a standard python text script it was something I could easily modify and put into my <a href="http://github.com/anveo/dotfiles" target="_blank">dotfiles</a> git repo. I wasn&#8217;t happy with how this one displayed subversion information either(just a revision number which I didn&#8217;t find very helpful), so I <a href="http://github.com/anveo/dotfiles/blob/master/scripts/vcprompt.py" target="_blank"><strong>made my own modification</strong></a> to display the branch you are in. Please pardon my lacking Python skills. </p>
<p>Anyway, on to pimping your prompt. Before we modify the PS1 variable, we need to make sure the vcprompt.py is in your $PATH. I like to put scripts like this in a custom  <i>bin</i> directory in my homedir. One way to accomplish that might be the following:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family: Monaco, monospace;">$ <span class="kw2">mkdir</span> <span class="re5">-p</span> ~<span class="sy0">/</span>bin
$ <span class="kw3">cd</span> ~<span class="sy0">/</span>bin
$ <span class="kw2">wget</span> http:<span class="sy0">//</span>github.com<span class="sy0">/</span>anveo<span class="sy0">/</span>dotfiles<span class="sy0">/</span>raw<span class="sy0">/</span>master<span class="sy0">/</span>scripts<span class="sy0">/</span>vcprompt.py
$ <span class="kw2">chmod</span> +x vcprompt.py
$ <span class="kw3">export</span> <span class="re2">PATH</span>=~<span class="sy0">/</span>bin:<span class="re1">$PATH</span></pre></div></div>

<p>Displayed next is the PS1 line I use &#8211; it takes up two lines: the first line contains the current user, hostname,  current working directory, and possibly version control info, and the second is just a nice looking arrow for my input. Your terminal will need to support Unicode if you want to use that symbol.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family: Monaco, monospace;"><span class="co0"># .bashrc</span>
<span class="re2">PS1</span>=<span class="st0">&quot;<span class="es1">\n</span>\u@\h:\w \[\e[1;30m\]<span class="es4">$(vcprompt)</span>\[\e[0m\] <span class="es1">\n</span>→&quot;</span>
&nbsp;
<span class="co0"># If you are using zsh you may also need the following in .zshrc</span>
setopt prompt_subst</pre></div></div>

<p><small>If you use the colors specified, you may need to <a href="http://github.com/anveo/dotfiles/blob/master/bash/config" target="_blank">define those too</a>.</small></p>
<p>You should now have a prompt similar to the image above! For more shell customizations checkout the rest of my <a href="http://github.com/anveo/dotfiles" target="_blank">dotfiles</a>, and consider buying Peepcode&#8217;s <a href="http://peepcode.com/products/advanced-command-line" target="_blank">Advanced Command Line screencasts</a> for more productive tips!</p>
]]></content:encoded>
			<wfw:commentRss>http://jetpackweb.com/blog/2010/01/08/pimp-your-ps1-with-source-control-information/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Useful PHP Subversion Commit Hook</title>
		<link>http://jetpackweb.com/blog/2009/07/19/useful-php-subversion-commit-hook/</link>
		<comments>http://jetpackweb.com/blog/2009/07/19/useful-php-subversion-commit-hook/#comments</comments>
		<pubDate>Sun, 19 Jul 2009 18:02:26 +0000</pubDate>
		<dc:creator>Brian Racer</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://jetpackweb.com/blog/?p=71</guid>
		<description><![CDATA[Here is a subversion pre-commit hook script we use on PHP projects to make sure the developer making the commit is providing a meaningful description, and then PHP lint is run on each PHP script to make sure it will compile correctly. #!/bin/bash &#160; REPOS=&#34;$1&#34; TXN=&#34;$2&#34; &#160; PHP=&#34;/usr/bin/php&#34; SVNLOOK=&#34;/usr/bin/svnlook&#34; AWK=&#34;/usr/bin/awk&#34; GREP=&#34;/bin/egrep&#34; SED=&#34;/bin/sed&#34; &#160; CHANGED=`$SVNLOOK changed [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a subversion pre-commit hook script we use on PHP projects to make sure the developer making the commit is providing a meaningful description, and then PHP lint is run on each PHP script to make sure it will compile correctly.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family: Monaco, monospace;"><span class="co0">#!/bin/bash</span>
&nbsp;
<span class="re2">REPOS</span>=<span class="st0">&quot;$1&quot;</span>
<span class="re2">TXN</span>=<span class="st0">&quot;$2&quot;</span>
&nbsp;
<span class="re2">PHP</span>=<span class="st0">&quot;/usr/bin/php&quot;</span>
<span class="re2">SVNLOOK</span>=<span class="st0">&quot;/usr/bin/svnlook&quot;</span>
<span class="re2">AWK</span>=<span class="st0">&quot;/usr/bin/awk&quot;</span>
<span class="re2">GREP</span>=<span class="st0">&quot;/bin/egrep&quot;</span>
<span class="re2">SED</span>=<span class="st0">&quot;/bin/sed&quot;</span>
&nbsp;
<span class="re2">CHANGED</span>=<span class="sy0">`</span><span class="re1">$SVNLOOK</span> changed <span class="re5">-t</span> <span class="st0">&quot;<span class="es2">$TXN</span>&quot;</span> <span class="st0">&quot;<span class="es2">$REPOS</span>&quot;</span> <span class="sy0">|</span> <span class="re1">$AWK</span> <span class="st_h">'{print $2}'</span> <span class="sy0">|</span> <span class="re1">$GREP</span> \\.php$<span class="sy0">`</span>
&nbsp;
<span class="kw1">for</span> FILE <span class="kw1">in</span> <span class="re1">$CHANGED</span>
<span class="kw1">do</span>
    <span class="re2">MESSAGE</span>=<span class="sy0">`</span><span class="re1">$SVNLOOK</span> <span class="kw2">cat</span> <span class="re5">-t</span> <span class="st0">&quot;<span class="es2">$TXN</span>&quot;</span> <span class="st0">&quot;<span class="es2">$REPOS</span>&quot;</span> <span class="st0">&quot;<span class="es2">$FILE</span>&quot;</span> <span class="sy0">|</span> <span class="re1">$PHP</span> -l<span class="sy0">`</span>
    <span class="kw1">if</span> <span class="br0">&#91;</span> <span class="re4">$?</span> <span class="re5">-ne</span> <span class="nu0">0</span> <span class="br0">&#93;</span>
    <span class="kw1">then</span>
        <span class="kw3">echo</span> <span class="nu0">1</span><span class="sy0">&gt;&amp;</span><span class="nu0">2</span>
        <span class="kw3">echo</span> <span class="st0">&quot;***********************************&quot;</span> <span class="nu0">1</span><span class="sy0">&gt;&amp;</span><span class="nu0">2</span>
        <span class="kw3">echo</span> <span class="st0">&quot;PHP error in: <span class="es2">$FILE</span>:&quot;</span> <span class="nu0">1</span><span class="sy0">&gt;&amp;</span><span class="nu0">2</span>
        <span class="kw3">echo</span> <span class="sy0">`</span><span class="kw3">echo</span> <span class="st0">&quot;<span class="es2">$MESSAGE</span>&quot;</span> <span class="sy0">|</span> <span class="re1">$SED</span> <span class="st0">&quot;s| -| <span class="es2">$FILE</span>|g&quot;</span><span class="sy0">`</span> <span class="nu0">1</span><span class="sy0">&gt;&amp;</span><span class="nu0">2</span>
        <span class="kw3">echo</span> <span class="st0">&quot;***********************************&quot;</span> <span class="nu0">1</span><span class="sy0">&gt;&amp;</span><span class="nu0">2</span>
        <span class="kw3">exit</span> <span class="nu0">1</span>
    <span class="kw1">fi</span>
<span class="kw1">done</span>
&nbsp;
<span class="co0"># Make sure that the log message contains some text.</span>
<span class="re2">SVNLOOKOK</span>=<span class="nu0">1</span>
<span class="re2">SVNLOOK</span>=<span class="sy0">/</span>usr<span class="sy0">/</span>bin<span class="sy0">/</span><span class="kw2">svnlook</span>
<span class="re1">$SVNLOOK</span> log <span class="re5">-t</span> <span class="st0">&quot;<span class="es2">$TXN</span>&quot;</span> <span class="st0">&quot;<span class="es2">$REPOS</span>&quot;</span> <span class="sy0">|</span> \
   <span class="kw2">grep</span> <span class="st0">&quot;[a-zA-Z0-9]&quot;</span> <span class="sy0">&gt;</span> <span class="sy0">/</span>dev<span class="sy0">/</span>null <span class="sy0">||</span> <span class="re2">SVNLOOKOK</span>=<span class="nu0">0</span>
<span class="kw1">if</span> <span class="br0">&#91;</span> <span class="re1">$SVNLOOKOK</span> = <span class="nu0">0</span> <span class="br0">&#93;</span>; <span class="kw1">then</span>
  <span class="kw3">echo</span> Empty log messages are not allowed. Please provide a proper log message. <span class="nu0">1</span><span class="sy0">&gt;&amp;</span><span class="nu0">2</span>
  <span class="kw3">exit</span> <span class="nu0">1</span>
<span class="kw1">fi</span>
&nbsp;
<span class="co0"># Make sure text might be meaningful</span>
<span class="re2">LOGMSGLEN</span>=$<span class="br0">&#40;</span><span class="re1">$SVNLOOK</span> log <span class="re5">-t</span> <span class="st0">&quot;<span class="es2">$TXN</span>&quot;</span> <span class="st0">&quot;<span class="es2">$REPOS</span>&quot;</span> <span class="sy0">|</span> <span class="kw2">grep</span> <span class="br0">&#91;</span>a-zA-Z0-<span class="nu0">9</span><span class="br0">&#93;</span> <span class="sy0">|</span> <span class="kw2">wc</span> -c<span class="br0">&#41;</span>
<span class="kw1">if</span> <span class="br0">&#91;</span> <span class="st0">&quot;<span class="es2">$LOGMSGLEN</span>&quot;</span> <span class="re5">-lt</span> <span class="nu0">6</span> <span class="br0">&#93;</span>; <span class="kw1">then</span>
  <span class="kw3">echo</span> <span class="re5">-e</span> <span class="st0">&quot;Please provide a meaningful comment when committing changes.&quot;</span> <span class="nu0">1</span><span class="sy0">&gt;&amp;</span><span class="nu0">2</span>
  <span class="kw3">exit</span> <span class="nu0">1</span>
<span class="kw1">fi</span>
&nbsp;
<span class="co0"># All checks passed, so allow the commit.</span>
<span class="kw3">exit</span> <span class="nu0">0</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://jetpackweb.com/blog/2009/07/19/useful-php-subversion-commit-hook/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SVN autobackup restore</title>
		<link>http://jetpackweb.com/blog/2008/11/04/svn-autobackup-restore/</link>
		<comments>http://jetpackweb.com/blog/2008/11/04/svn-autobackup-restore/#comments</comments>
		<pubDate>Tue, 04 Nov 2008 19:02:32 +0000</pubDate>
		<dc:creator>Brian Racer</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[backups]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://blog.jetpackllc.com/?p=7</guid>
		<description><![CDATA[I have been using Doug Hellman&#8217;s useful svnautobackup script for our subversion backups. I think it is a pretty useful script, but it only focuses on backups and not restoration. During a recent server upgrade I needed to restore a large amount of repositories from our dumpfiles. I made the following shell script in php [...]]]></description>
			<content:encoded><![CDATA[<p>I have been using <a href="http://blog.doughellmann.com/">Doug Hellman&#8217;s</a> useful <a href="http://code.google.com/p/svnautobackup/" target="_blank">svnautobackup</a> script for our subversion backups. I think it is a pretty useful script, but it only focuses on backups and not restoration.</p>
<p>During a recent server upgrade I needed to restore a large amount of repositories from our dumpfiles. I made the following shell script in php that will loop through all of the backup dumps and restore them. There is a <a href="http://blogs.law.harvard.edu/hoanga/2008/07/03/svnbackup-restorerb-svnbackups-handy-companion-tool/" target="_blank">similar tool</a> that uses ruby, but it can only restore one repository and I do not know enough ruby to modify it <img src='http://jetpackweb.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family: Monaco, monospace;">#!/usr/bin/php -q
<span class="kw2">&lt;?php</span> 
<span class="co1">// edit this</span>
<span class="re0">$repo_dir</span> <span class="sy0">=</span> <span class="st_h">'/svn/'</span><span class="sy0">;</span>
<span class="re0">$backup_dir</span> <span class="sy0">=</span> <span class="st_h">'/home/backup/svn/'</span><span class="sy0">;</span>
&nbsp;
<span class="co1">// don't edit this</span>
<span class="kw1">foreach</span><span class="br0">&#40;</span><span class="kw2">new</span> DirectoryIterator<span class="br0">&#40;</span><span class="re0">$backup_dir</span><span class="br0">&#41;</span> <span class="kw1">as</span> <span class="re0">$file</span><span class="br0">&#41;</span>
<span class="br0">&#123;</span> 
  <span class="kw1">if</span><span class="br0">&#40;</span>isDir<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="sy0">&amp;&amp;</span> <span class="sy0">!</span><span class="re0">$file</span><span class="sy0">-&gt;</span><span class="me1">isDot</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>
  <span class="br0">&#123;</span>
    <span class="co1">// get files</span>
    <span class="re0">$dumpfiles</span> <span class="sy0">=</span> <span class="kw3">glob</span><span class="br0">&#40;</span><span class="re0">$backup_dir</span><span class="sy0">.</span><span class="re0">$file</span><span class="sy0">.</span><span class="st_h">'/dumpfile*.bzip2'</span><span class="br0">&#41;</span><span class="sy0">;</span>
    <span class="co1">// sort them</span>
    <span class="kw3">natsort</span><span class="br0">&#40;</span><span class="re0">$dumpfiles</span><span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
    <span class="co1">// create the repo if not exists</span>
    <span class="kw1">if</span><span class="br0">&#40;</span><span class="sy0">!</span><span class="kw3">is_dir</span><span class="br0">&#40;</span><span class="re0">$repo_dir</span><span class="sy0">.</span><span class="re0">$file</span><span class="br0">&#41;</span><span class="br0">&#41;</span>
    <span class="br0">&#123;</span>
      <span class="re0">$cmd</span> <span class="sy0">=</span>  <span class="st0">&quot;svnadmin create <span class="es4">{$repo_dir}</span><span class="es4">{$file}</span>&quot;</span><span class="sy0">;</span>
      <span class="kw3">system</span><span class="br0">&#40;</span><span class="kw3">escapeshellcmd</span><span class="br0">&#40;</span><span class="re0">$cmd</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span>
    <span class="br0">&#125;</span>
&nbsp;
    <span class="co1">// restore dump files</span>
    <span class="kw1">foreach</span><span class="br0">&#40;</span><span class="re0">$dumpfiles</span> <span class="kw1">as</span> <span class="re0">$dumpfile</span><span class="br0">&#41;</span>
    <span class="br0">&#123;</span>
      <span class="re0">$cmd</span> <span class="sy0">=</span> <span class="st0">&quot;bzcat <span class="es4">{$dumpfile}</span> | svnadmin load <span class="es4">{$repo_dir}</span><span class="es4">{$file}</span>&quot;</span><span class="sy0">;</span>
      <span class="kw3">system</span><span class="br0">&#40;</span><span class="kw3">escapeshellcmd</span><span class="br0">&#40;</span><span class="re0">$cmd</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span>
    <span class="br0">&#125;</span>
  <span class="br0">&#125;</span>
<span class="br0">&#125;</span></pre></div></div>

<p>For reference, here is the script that runs nightly though cron</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family: Monaco, monospace;"><span class="co0">#!/bin/bash</span>
&nbsp;
<span class="re2">files</span>=<span class="sy0">`</span><span class="kw2">ls</span> <span class="sy0">/</span><span class="kw2">svn</span><span class="sy0">`</span>
<span class="kw1">for</span> <span class="kw2">file</span> <span class="kw1">in</span> <span class="re1">$files</span>
<span class="kw1">do</span>
  <span class="kw1">if</span> <span class="br0">&#91;</span> <span class="re5">-d</span> <span class="sy0">/</span>svn<span class="sy0">/</span><span class="re1">$file</span> <span class="br0">&#93;</span>
  <span class="kw1">then</span>
    <span class="kw2">mkdir</span> <span class="re5">-p</span> <span class="re1">$file</span>
    <span class="sy0">/</span>home<span class="sy0">/</span>backup<span class="sy0">/</span>scripts<span class="sy0">/</span>svnautobackup<span class="sy0">/</span>svnbackup.sh <span class="re5">-v</span> <span class="re5">-i</span> <span class="nu0">100</span> <span class="re5">--history-file</span> <span class="sy0">/</span>home<span class="sy0">/</span>backup<span class="sy0">/</span>svn<span class="sy0">/</span><span class="re1">$file</span>-hist <span class="re5">--out-dir</span> <span class="sy0">/</span>home<span class="sy0">/</span>backup<span class="sy0">/</span>svn<span class="sy0">/</span><span class="re1">$file</span> <span class="sy0">/</span>svn<span class="sy0">/</span><span class="re1">$file</span>
  <span class="kw1">fi</span>
<span class="kw1">done</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://jetpackweb.com/blog/2008/11/04/svn-autobackup-restore/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
