<rss version="2.0">
    <channel>
        <title>andrew.puzzling.org: diary</title>
        <link>http://andrew.puzzling.org/diary/</link>
        <description>Updates to andrew.puzzling.org: diary</description>
        <language>en</language>
        <webMaster>andrew-puzzling@puzzling.org</webMaster>
        <ttl>1440</ttl>
        <item><title>Using Bazaar to hack on Twisted</title><link>http://andrew.puzzling.org/diary/2008/April/6/twisted-bzr</link><guid isPermaLink="true">http://andrew.puzzling.org/diary/2008/April/6/twisted-bzr</guid><pubDate>Sun, 06 Apr 2008 14:58:03 GMT</pubDate><description><![CDATA[<p>At PyCon, I helped several Twisted developers to use Bazaar to work on
Twisted, even though the repository is still SVN.  Here's how to do it.</p>

<p>First, install bzr and the <a
href="http://bazaar-vcs.org/BzrForeignBranches/Subversion">bzr-svn</a> plugin.
I strongly recommend using the latest release of bzr-svn, 0.4.9, as Jelmer is
fixing bugs and improving the speed at an impressive rate.  0.4.9 is in Ubuntu
Hardy.</p>

<p>Then make a shared repository for your Twisted branches:</p>

<pre>
bzr init-repo --rich-root-pack Twisted
</pre>

<p>(Forgetting <code>--rich-root-pack</code> is a common gotcha: the default
repository format in bzr 1.3 doesn't have a feature bzr-svn needs.)</p>

<p>Then checkout the SVN trunk into the repository.  You could do this
direct from SVN, but it's much faster to use an already converted copy:</p>

<pre>
cd Twisted
bzr checkout http://www.twistedmatrix.com/users/spiv/bzr/twisted/trunk/
cd trunk
bzr switch svn://svn.twistedmatrix.com/svn/Twisted/trunk
</pre>

<p>To work on a branch already in SVN, you can just checkout or branch
(depending on which workflow you prefer) it directly into your local
repository.  Checkouts will be more familiar to SVN users than independent
branches, but if you want to make commits you'll need write access to Twisted's
SVN repository.</p>

<pre>
cd ..
bzr checkout svn://svn.twistedmatrix.com/svn/Twisted/branches/feature-branch-1
cd feature-branch-1
<i>hack hack hack...</i>
bzr commit
</pre>

<p>(Don't worry too much about branches vs. checkouts.  You can always use
<code>bzr reconfigure</code> to change a checkout into a branch and vice versa
if you change your mind later.)</p>

<p>To make a new branch in the SVN repository it's best to just use svn
cp as before, then make a checkout/branch of that with bzr. (See <a
href="https://bugs.launchpad.net/bzr-svn/+bug/203368">bug 203368</a>)</p>

<pre>
svn cp svn://svn.twistedmatrix.com/svn/Twisted/trunk svn://svn.twistedmatrix.com/svn/Twisted/branches/new-branch
bzr checkout svn://svn.twistedmatrix.com/svn/Twisted/branches/new-branch
</pre>

<p>If you can't commit to Twisted SVN you can still use bzr.  Just make
independent branches rather than checkouts.  To share your branches with
other people you can simply <code>bzr push</code> them to anywhere you
like, including Launchpad.</p>

<p>And that's really it.  Everything else is just regular bzr, including
the excellent merging and offline commits.</p>

<p>For example, here's how you'd merge a branch to trunk and commit it:</p>

<pre>
bzr checkout svn+ssh://svn.twistedmatrix.com/svn/Twisted/trunk
cd trunk
bzr merge ../my-branch   # or you could use an SVN url!
bzr commit
</pre>

]]></description></item><item><title>Re: Dangerous Merging</title><link>http://andrew.puzzling.org/diary/2007/August/15/re-dangerous-merging</link><guid isPermaLink="true">http://andrew.puzzling.org/diary/2007/August/15/re-dangerous-merging</guid><pubDate>Wed, 15 Aug 2007 06:28:47 GMT</pubDate><description><![CDATA[<p>Matthew Palmer <a
href="http://www.hezmatt.org/~mpalmer/blog/general/dangerous_merging.html">argues
against</a> “having your revision control system assume that patches which are
the same text is the same”:</p>

<blockquote>If you think this is right, "think about two different patches each
adding a new keyword and also changing the line ``#define NUM_OF_KEYWORDS 17''
to ``#define NUM_OF_KEYWORDS 18''." (example taken from the <a
href="http://www.darcs.net/manual/node6.html#SECTION00635000000000000000">darcs
manual</a>, because I'm not going to come up with a better example than
that).</blockquote>

<p>In the example he cites, there <em>will</em> most likely be a conflict,
assuming the added keywords are different (and depending on what the source
changes to add keywords look like, but the obvious schemes would cause a
conflict).  The conflict will be at the point where the different keywords are
added, rather than at the “#define NUM_OF_KEYWORDS”, but the human resolving
that conflict would, if your source is clear, know that they need to check the
NUM_OF_KEYWORDS value too.  (Although if your source code has the property that
you need to update multiple places to register one new thing, it's violating
“Don't Repeat Yourself” principle, but that's another discussion...)</p>

<p>But more significantly, there are plenty of ways that two patches that don't
conflict textually can conflict semantically.  One patch might change the
signature of a function, and another may add a new caller of that function that
assumes it has the old signature.  And there's lots of more subtle ways that
they could conflict.</p>

<p>If you want to ensure your code is correct in the face of changes, then the
tool for the job isn't a Version Control System.  It's a Test Suite, preferably
an automated one.  Version Control Systems help you collaborate and manage
changes, but it's your Test Suite that tells you if the code still works.</p>

]]></description></item><item><title>On computer programming</title><link>http://andrew.puzzling.org/diary/2007/August/12/on-computer-programming</link><guid isPermaLink="true">http://andrew.puzzling.org/diary/2007/August/12/on-computer-programming</guid><pubDate>Sun, 12 Aug 2007 10:23:35 GMT</pubDate><description><![CDATA[<p><a href="http://wzdd.livejournal.com/6017.html">Nicholas describes</a> the
process and results of computer programming:</p>

<blockquote>“It's sort of like you're a combination architect / builder, but
you're a really terrible one. Someone asks you to build a new bathroom for their
house, so you do, but despite all your careful planning the finished product is
just shite.  For example, the shower wall is made out of soap, because you
thought it would be convenient — now nobody needs to buy soap, because they can
just rub up and down against the wall for a bit and then hose themselves off
(you installed a hose instead of a shower head for greater
flexibility).”</blockquote>

<p>It's worth reading the full piece.</p>

]]></description></item><item><title>Making sure tests pass with PQM</title><link>http://andrew.puzzling.org/diary/2007/July/22/enforcing-tests-pass-with-pqm</link><guid isPermaLink="true">http://andrew.puzzling.org/diary/2007/July/22/enforcing-tests-pass-with-pqm</guid><pubDate>Sat, 21 Jul 2007 15:19:07 GMT</pubDate><description><![CDATA[<p>Wouldn't it be nice if tests <em>always</em> passed on the trunk of your
project?</p>

<p>(I spoke about this a little at my <a
href="http://www.osdc.com.au/2006.html">OSDC</a> <a
href="http://osdcpapers.cgpublisher.com/product/pub.84/prod.26">talk</a> last
year, but I recently remembered that I ought to blog about it to get a wider
audience.)</p>

<p>The benefits are pretty obvious: it saves people time.  Bleeding edge
users/testers can always be confident that a checkout of your project will build
and work.  Developers can start new feature branches confident that nothing is
seriously broken before they've even started.  Test coverage hopefully is
improving over time, so you can be fairly sure that the quality of the trunk is
also improving.  And so on.</p>

<p>So how hard is it?  Many projects have a policy that requires developers to
run tests before checking in, and if it turns out they forgot and broke the test
suite, their commit will be reverted.  Well, it'll be reverted as soon as
someone notices.  And hopefully no-one checked in while you were running tests,
which might easily happen if you have slow test suite.</p>

<p>Here's what the <a href="https://launchpad.net/">Launchpad</a> and <a
href="http://bazaar-vcs.org/">Bazaar</a> developers do: use <a
href="http://launchpad.net/pqm">PQM</a> (Patch Queue Manager) to guard commits
to the trunk.  No developer has direct write access to the trunk branch, only
the PQM instance.  To merge a branch to trunk, developers submit a merge request
to PQM.  We configure PQM to run &ldquo;<code>make check</code>&rdquo; before
committing a merge, and only if the tests pass (and the merge had no conflicts)
will the change be committed.</p>

<p>You could configure your revision control system to use a pre-commit hook,
but that doesn't tend to work very well unless the checks are instantaneous.
It's nice to finish your work, send the merge request, and then be able to
disconnect your laptop from the network and hop on a train without interrupting
the processing of your branch.  PQM accepts requests via GPG-signed email, and
also sends the results via email (although in principle it could just as easily
use something like XML-RPC).  PQM will simply queue requests if they arrive
while it is busy with an existing request.  It's an asynchronous workflow, which
works well when the checks can take some time.</p>

<p>If you have a bunch of inter-dependent projects, you can even configure PQM
to run a command to check all of them every time someone tries to commit to any
one of them.  We do this with Launchpad, so we know that upgrading a
dependency of the main Launchpad project won't cause problems in Launchpad
itself.</p>

<p>It's not a perfect process, and PQM isn't a perfect tool.  PQM in some ways
is still quite simple and has rough edges, but it's worked very well for us.
Our tests always pass on trunk.  Occasionally there's a crisis like
tests that normally pass but intermittently fail, but these would still be a
problem without PQM, assuming you really do care about making sure tests
<em>always</em> pass on your trunk.</p>

<p>This process can be complementary with the post-commit testing that many
projects already do with <a href="http://buildbot.net/">BuildBot</a> or <a
href="http://www.mozilla.org/tinderbox.html">Tinderbox</a>.  You could have PQM
run tests on one or two key platforms, and then after the commit is done let
BuildBot run tests on every other platform the community has buildslaves for.
For instance, you may have a buildslave that tries to run your latest code with
the latest development version of Python: failures there are worth knowing
about, but not necessarily a reason to stop a branch from landing.</p>  

<p>There's already a <a href="https://launchpad.net/bzr-pqm">Bazaar plugin for
sending requests to PQM</a>, but you could pretty easily write plugins or
scripts for other systems too.</p>



]]></description></item><item><title>Linux.conf.au 2007, day 3</title><link>http://andrew.puzzling.org/diary/2007/January/17/lca2007-day3</link><guid isPermaLink="true">http://andrew.puzzling.org/diary/2007/January/17/lca2007-day3</guid><pubDate>Thu, 18 Jan 2007 03:04:53 GMT</pubDate><description><![CDATA[<p>The main part of the conference started today.  Dr. Andrew S. Tanenbaum's
keynote was excellent — I found myself involved in several conversations about
it over the course of the day, a sure sign that he's provoked some thought.  In
his opinion computers fail ridiculously often compared to many other everyday
objects like TVs and cars, and we ought to be striving for zero “lifetime
failures” for the average computer (just as the average TV never fails).  He
then described a fault-tolerant operating system design, basically keeping as
many drivers in user space as possible, and simply restarting them when they
fall over.  There's a performance penalty, but he argues that the improved
reliability is definitely worth the cost.  It can't cope with all possible
faults, but it sounds like it could probably recover from a significant fraction
of them, so perhaps it would be worth the effort.  Oh, and he encouraged people
to take a look at Minix, of course.</p>

<p>Jonathan Corbet's <a href="http://lca2007.linux.org.au/talk/139">Kernel
Report</a> was fairly interesting.  I think I would have found it much more
interesting if I hadn't been regularly reading LWN's kernel page every week, but
even though I'd read about most of it before it was an enjoyable overview.</p>

<p>Dave Airlie's <a href="http://lca2007.linux.org.au/talk/154">Nouveau</a> talk
was interesting, it was a project I'd heard of but actually knew very little
about.  In brief: they're doing some very clever things to reverse engineer the
driver, but don't expect it to be ready any time soon (alpha quality by the end
of 2007 is the current plan).</p>

<p>I actually got a chance to ride around on Geoffrey Bennett's <a
href="http://lca2007.linux.org.au/talk/185">Open Source Segway™</a> yesterday,
but was still enjoyed his talk about it today.  I'm not really an electronics
geek, but the fact that he could monitor the readings from the components with a
cute GTK app (via bluetooth) was very nifty.  Even more nifty was that he was
casually tuning the settings of the controller on the fly from the same simple
GTK app.  His description of the development and testing process for it was
quite similar to the way software that is built from scratch is developed and
tested, although I've never had to worry about my software throwing me off and
then running me over if I screw it up.</p>

<p>I'm glad the organisers programmed a break between each session, so that
people have time to move to a different room for the next talk, and perhaps
strecth their legs.  OSDC would have benefitted from this.  I just wish that the
organisers were stricter about making sure speakers actually finish on time so
that the breaks don't evaporate.</p>

]]></description></item>
    </channel>
</rss>