Subversion Update Tips

Tags:

Subversion has been an excellent tool for version control, but certainly with its own frustrations.

One of these has been knowing where you are (or, rather, your working copy is) in relation to what is what's on the server's repository.

Version 1.5, approximately, introduced a few changes which make this much simpler. At least with v1.6 you can do this, assuming you are in a subdirectory under one in svn control:

$ <strong>svn ls ^/tags</strong>
1.5/
[...]
3.0/
3.0.1/
3.0.2/
3.0.3/
$

Huzzah! Subversion replaces the caret with "the root URL of the repository for this checkout" -- I sure wish I had known this a lot earlier. Now I can see what other tagged versions are available.

Some of you may have guessed my working copy was of Wordpress. Here's how we can see exactly what's going on in a particular tagged version, without actually checking it out:

$ <strong>svn ls ^/tags/3.0.3/wp-includes/ -v</strong>
 16803 westi                 Dec 08 10:50 ./
 13211 nacin                 Feb 18  2010 Text/
 8149 westi           10928 Jun 20  2008 atomlib.php
 15148 nacin           11549 Jun 05  2010 author-template.php
 12525 ryan             9624 Dec 23  2009 bookmark-template.php
[...]

Ah, you say, but I have the tagged version I want... I just want to know what will happen if I type svn update ...? Well try this:

$ <strong>svn diff -r HEAD</strong>

That will show you the differences between your current working copy and the latest edition (head) of the currently checked out version... which is the differences that will be applied if you did an update.

OK, now I'm ready to switch my version... this used to be a bit of a pain, having to copy the URL... but now we can just do:

$ <strong>svn sw ^/tags/3/0.3</strong>
<em>or maybe</em>
$ <strong>svn sw ^/trunk</strong>

Firebug 1.6 favorite features

Tags:

Firebug 1.6, the plugin for Firefox, is newly released; for debugging or developing web apps, like Wordpress, it is simply indispensable.

A few of my favorite features:

  1. Scrollable breadcrumbs, solves the one biggest thing that always drove me nuts, in dealing with Real World css.

  2. Copy CSS from the inspection window by right-clicking on the declaration:

Mass Template change for children of a page

Tags:

Wordpress users, if you have created a site with a large number of pages ... and then decided to create a template that you would like to use for every page in a section of a site, you might find this useful.

Here is a bit of MySQL that changes the template of every child-page of the page with id=4:

update wp_postmeta set meta_value = "station.php"
  where meta_key="_wp_page_template" and 
        post_id in (select id from wp_posts where post_parent=4);

We use a sub-select to determine all the pages we want to change, and then set all those child-pages to have the 'station.php' template. That value, of course, will change -- you probably want to copy it from a page whose template you have set through the regular administration interface.

Resizing a Large Number of Images

Tags:

Try this little trick with 'bash' when you need to resize a large number of pictures. Here we use a for-loop, and variable substitution.

We have created a subdirectory called 800/ under the current directory. All the original files are in the current directory, and we want the reduced images in the 800/ subdirectory.

This is all on one line:

for AA in *.jpg; do echo $AA; convert -size 800x600 -resize 800x600 $AA 800/$AA; done

WP E-commerce plugin: Variation weight patch

Tags:

The wp-e-commerce plugin -- http://wordpress.org/extend/plugins/wp-e-commerce/ -- works very well but has the annoying property that if you define variations on a product, the Product Weight you set in the main configuration for that product is ignored and the weight taken from each variant... except that weight is on the "More" screen which by default is hidden next to the variation name and price!

This little patch corrects that annoyance by using the main product's weight, if the variant's weight is zero. NOTE if you really want a variant that makes the product weigh nothing, this patch is not for you!

<div id="_mcePaste">*** wp-content/plugins/wp-e-commerce/wpsc-includes/cart.class.php~      2010-11-17 08:36:55.000000000 -0700
--- wp-content/plugins/wp-e-commerce/wpsc-includes/cart.class.php       2010-11-17 09:26:53.000000000 -0700
***************
*** 1718,1724 ****
--- 1726,1738 ----
                        $priceandstock_values = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_VARIATION_PROPERTIES."`
WHERE `id` = '{$priceandstock_id}' LIMIT 1", ARRAY_A);                                                               

                        $price = $priceandstock_values['price'];
+
+                       // PATCH -- wl 2010-11-17
                        $weight = wpsc_convert_weights($priceandstock_values['weight'], $priceandstock_values['weight_unit']);
+                       if ($weight == 0) { // Use weight of main product without the variant.
+                         $weight = wpsc_convert_weights($product['weight'], $product['weight_unit']);
+                       }
+
                        $file_id = $priceandstock_values['file'];                                                    

                } else {</div>