Upload your websites with bzr-upload

I was lucky enough to be able to attend the Bazaar Sprint back in March, mostly thanks to Canonical sponsoring my entire trip across the globe 🙂
The sprint was interesting in all sorts of ways, and it got me working on several projects (some of which I’ll talk about in future posts), but there was one in particular that amazed me how fast it was put together. Bzr-upload.
It all started one night, while sitting across the table from Vincent Ladeuil, the guy who basically wrote transports in Bazaar, and I started complaining about how I had to work around bazaar to make it fit into my daily work flow (doing web development).
The problem was simple: bzr doesn’t update the working tree (the actual files) remotely, so there was no simple way for me to upload the websites I worked on a daily basis.

Long story short, Vincent asked some questions, sat down, wrote tests, wrote code to work with those tests (TDD, FTW), and after some fiddling, we can now upload websites (and anything else, actually) using bzr’s knowledge of what we’ve changed, and it’s solid transport libraries (ftp, sftp).

So… how does this work? Simple.
Assuming you already have bzr installed, fire up a terminal and do:
bzr checkout lp:bzr-upload ~/.bazaar/plugins/upload

Now that we have the plugin installed, go to the branch containing your website, and with a simple:
beuno@beuno-laptop:/mywebsite$ bzr upload sftp://beuno@host/path/to/http
No uploaded revision id found, switching to full upload
Uploading bar
Uploading foo

Done!

Did more work?

beuno@beuno-laptop:/mywebsite$ bzr ci -m'Random bug fix'
Committing to: /mywebsite/
modified foo
Committed revision 2.
beuno@beuno-laptop:/mywebsite$ bzr upload
Using saved location: sftp://beuno@host/path/to/http
Uploading foo

That’s it!

bzr-upload will remember the last revision you uploaded, and make sure it only sends what you’ve changed.

Project’s page: https://launchpad.net/bzr-upload

Comments, feedback, patches, etc are very welcome.

17 responses to “Upload your websites with bzr-upload”

  1. Can you get bzr commit to automatically do the upload for you?

    AFAIR if you have a bzr checkout or use bzr bind, then bzr commit will push your changes to the remote repository (just not update the working dir). Is there any way to hook into that?

    Currently I maintain my “work” home page with Subversion, with a post-commit hook that updates a checkout the web server uses. IOW I can push all my changes online with a single command (svn commit).

    Like

  2. Fantastic, amazing and wonderful. Phenomenal and incredible. Happy Happy. Joy Joy.

    Like

  3. This sounds a lot like bzr-push-and-update, which is what I use now:
    https://launchpad.net/bzr-push-and-update

    Except that bzr-upload is entirely client side, from what I understand? The above plugin requires bzr to be installed on the computer you’re pushing to.

    Sounds great! It would mean I can use bzr for some other sites I manage too, ones that are on shared hosts that don’t have bzr.

    Like

  4. This looks very cool. Nice to not have to then log into the server and update bzr on that side.

    My one question though is how does this work in a distributed development team? If my co-worker updates and uploads, and I then update and upload, does it upload history as well as the changes?

    Like

  5. Does this upload a .bzr folder? Be nice if it didn’t for some places where I don’t want people seeing my code.

    Like

  6. Marius:

    It doesn’t upload on commit, but maybe you can open a bug requesting it 🙂

    Rick:

    It doesn’t upload history, just the last revision that was uploaded. This means that if you already uploaded that revision, it won’t upload anything for your co-worker. Of course, that means your repositories ahve to be more or less in-sync.

    Mez:

    It doesn’t. That was one of my main concerns, *just* uploading the files.

    Like

  7. […] no blog do Martin um plugin para o Bazaar chamado bzr-upload, que é uma mão na roda para manter sites atualizados, […]

    Like

  8. Hi Martin,

    Huge thanks and congratulations to both you and Vincent! This plugin is a great step in the right direction for web developers.

    I sometimes have to transfer working files to a remote host either through scp or even through Remote Desktop. I am not sure if it is in the spirit of this plugin, but I imagine the core algorithms would be the same, to have some kind of plugin that just exports the files between 2 revisions. I suppose it would be different than this because it would be more like “bzr export-files -r ..130 ../my-checkout-directory” or something like that.

    I unfortunately don’t know Pearl at all (used to try it a bit for some CGI scripts, but that’s it) so I am pretty useless at this. Maybe sometime I will learn but in the meantime, would you or Vincent be interested in taking on something like this? Perhaps you already know of something that does that?

    Again, great work! Thank You and Vincent for taking the time to actually write this plugin.

    Like

  9. Greg, you can’t currently upload individual files or tarballs, but it sounds like a nice thing to have.

    Could you file a bug on the project requesting it, with as much details as possible?

    Like

  10. Thank you so much for this plugin, it is going to make my life so much easier.

    Like

  11. […] De moment, encara no hem publicat res que sigui accessible. El que volem fer és, amb una simple comanda, publicar els fitxers que han estat modificats en una carpeta del servidor, la qual serà accessible des de l’exterior, però, en aquesta carpeta, no hi volem desar tot l’historial de versions. Per fermaixò, emprarem el plugin bzr-upload, tal com s’explica aquí. […]

    Like

  12. I have a question: how is

    bzr upload sftp://beuno@host/path/to/http

    different from

    rsync -av –delete beuno@host/path/to/http

    ??

    Is it just that you don’t need rsync server running remotely, and can use ftp?

    Like

  13. Yes, that’s exactly it.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: