Merging a Subversion branch back into trunk

Posted on November 4th, 2009 by Simen – Be the first to comment

Subversion isn’t exactly renowned for graceful handling of branches, so naturally merging is a pain in the ass. However after smashing my head in the desk more than a couple of times doing this I thought I’d write a small tutorial on what might seem like voodoo bereft of logic.

Note: I’m using Terminal in OSX throughout the example but it should be perfectly doable in cmd on Windows as well

Requirements

  • Subversion command-line utilities (somehow the fancy merge dialogs of Subversive/Subclipse make things even more confusing)
  • A subversion repository containing a branch and a trunk

Better safe than sorry

Before we start the actual merging I should mention there are ways to merge two Subversion URLs directly without staging the final commit, I just like to play it safe.

Now fire up Terminal (in Applications/Utilities) and let’s get cooking.

We start by checking out a copy of our trunk (to which our branch changes will be applied) so we have a clean working copy to work with.

$ svn co http://svn.test.com/client.project/flash/trunk staging
$ cd staging

Now we need to figure out the “base” of our branch, this is the revision where we first created our branch.

$ svn log -v --stop-on-copy http://svn.test.com/client.project/flash/branches/cool_feature

The last part of the output will read something like this.

------------------------------------------------------------------------
r155 | simen | 2009-10-12 11:37:52 +0200 (Mon, 12 Oct 2009) | 1 line
Changed paths:
  A /flash/branches/cool_feature (from /flash/trunk:116)

Now we know that the branch was created in revision r155. If your are asking yourself “why doesn’t SVN know this itself” the answer is “because it is really bad at branching and merging”.

Now for the actual merge.

$ svn merge -r 155:HEAD http://svn.test.com/client.project/flash/branches/cool_feature

Again a bunch of text will rush by and probably stop a number of times with the conflict prompt.

Conflict discovered in 'src-external/ui.fla'.
Select: (p) postpone,
        (mf) mine-full, (tf) theirs-full,
        (s) show all options:

For human-readable files like source-code, SVN will attempt to merge the two revisions automatically or you can merge the differences by hand in a normal-text editor.

For binary files you only have two choices, mine-full which tells SVN to use the existing file (the one in trunk), and theirs-full to use the file from the branch we are merging from.

Once the merge is complete we’re back at the command-line, but before committing the changes, let’s make sure everything went as it should.

$ svn diff

After you’ve looked over the changes, it’s time to finalize the merge by committing.

$ svn commit -m "Merged cool_feature branch back into trunk"

You can now update your existing working copy of trunk and see the fruits of your merge.

Image size trick in css

Posted on October 30th, 2009 by Thomas – Be the first to comment

In a css layout of a webpage where the whole site is created using em, images often ends up “destroying” the layout when a user increases or decreases the text-size. This can easily be fixed by a simple cms trick.

     <img class="list-image" src="/path-to-your-image.jpg" width="100" height="200" />

If you want the image to scale coherently to the em size, do the following:

. list-image {
      width: 10em !important;
      height: 20em !important;
}

Precepts from our JavaScript dictator

Posted on October 30th, 2009 by Thomas – Be the first to comment

Always declare your variables and functions:
Variables which are not declared will be global. This can result in many bugs hard to detect.

Always declare your variables in top of your block:
JavaScript does not have block scope, and it is better to always declare all variables at the top of each function.

read more »

Setting up a Symfony project - the official way, and then some

Posted on October 7th, 2009 by Erland – Be the first to comment

After having tried several different ways of installing/setting up Symfony projects, I have settled for what is more or less the official “best practice”, as suggested by the makers of Symfony. For the purpose of clarity, I will use the example c:\demosite in the following explanation. The example is based on an installation on Windows XP, but can be adapted to suit OSX.

  1. Create the project folder c:\demosite
  2. Create the subfolder(s) c:\demosite\lib\vendor
  3. In the vendor folder, do a SVN checkout http://svn.symfony-project.com/branches/1.2/ => c:\demosite\lib\vendor\symfony. You should now have a single symfony folder in your vendor folder
  4. From the project root c:\demosite, run the following command: lib\vendor\symfony\data\bin\symfony generate:project demosite. You may or may not have to prefix this command with php, depending on your setup.
  5. From now on, you can use the command short cut symfony from the project’s root folder.

TIP#1:

Copy the file c:\demosite\lib\vendor\symfony\data\bin\symfony.bat to the project’s root folder, and rename it sf.bat. You now have an even shorter command sf at your disposal. Test it by typing sf -V.

TIP#2:

Change the following in the project’s configuration class:

//c:\demosite\config\ProjectConfiguration.class.php
require_once dirname(__FILE__).'/../lib/vendor/symfony/lib/autoload/sfCoreAutoload.class.php';

TIP#3

If you use SVN to maintain your project, you can use svn:externals to embed the Symfony library in your lib\vendor folder, thus benefiting from the updates to this particular branch.

For more information, visit the official Symfony site

So.. Flash on the iPhone?

Posted on October 6th, 2009 by Thomas H – Be the first to comment

Yes, so it seems. Flash Professional CS5 will enable you to build applications for iPhone and iPod touch using ActionScript 3. These applications can be delivered to iPhone and iPod touch users through the Apple App Store.

And according to the guy in the video its supposed to be as fast as your other applications as well. iPhone applications built with Flash Platform tools are compiled into standard, native iPhone executables, just like any other iPhone application.

How it all works

We enabled this by using the Low Level Virtual Machine (LLVM) compiler infrastructure. LLVM is a modular, flexible compiler system that is used widely in a variety of projects. The key reason we choose LLVM is its flexibility and applicability to iPhone development.

We created a new compiler front end that allowed LLVM to understand ActionScript 3 and used its existing ARM back end to output native ARM assembly code. We call this Ahead of Time (AOT) compilation—in contrast to the way Adobe Flash Player and Adobe AIR function on the desktop using Just in Time (JIT) compilation. Since we are able to compile ActionScript to ARM ahead of time, the application gets all the performance benefits that the JIT would offer and the license compliance of not requiring a runtime in the final application.

By doing the compilation step, we allow developers to create applications using their Flash skills and their knowledge of ActionScript 3. In the process, we also expose the APIs that developers are familiar with so they can not only use the ActionScript language but follow the customary app-building model. When you build your application for the iPhone, there is no interpreted code and no runtime in your final binary. Your application is truly a native iPhone app.

http://labs.adobe.com/technologies/flashcs5/appsfor_iphone/#resources
http://www.youtube.com/watch?v=kusXgPAmMLw
http://www.adobe.com/devnet/logged_in/abansod_iphone.html

So now lets go and build an app for that!

SWFUpload - a nice widget for multiple file uploads

Posted on October 2nd, 2009 by Erland – Be the first to comment

Get your fix here

Smooth scaling of bitmapData objects

Posted on September 16th, 2009 by Thomas H – Be the first to comment

If scaling bitmapData objects are making your head ache because it looks jagged and all shitty, why don’t you add a BlurFilter before scaling? Works really well for downsampling large bitmaps to really small sizes too. Just remember to add sufficient blur values.

var newSource:BitmapData = new BitmapData(source.width,source.height)
newSource.applyFilter(source, source.rect, new Point(), new BlurFilter(scaleRatio,scaleRatio))
source = newSource
target.draw(source,new Matrix(scale,0,0,scale,0,0),null,null,null,true)

Focus on key listeners

Posted on August 31st, 2009 by Knut – Be the first to comment

Being a master at getting odd bugs that nobody else gets I just discovered a little issue with adding and removing KeyboardEvents to an application.

My app has a series of forms arranged in steps. The design of one of the forms required keyboard input to be useful. Every form section is added to stage, showed, verified submitted, hidden and then removed from stage before the next one is displayed.

Two steps into this sequence I required key input and could not get it to work without clicking somewhere first. I first thought it was the old focus security fix that was playing up but since I had already clicked a button to show the form I knew the app had focus.

I found that the stage.focus property was set to the last button clicked. This button was the “next” button in the previous form. Since this button no longer was on stage its button events obviously could not bubble to stage.  Doh! So when setting key listeners: always set focus to the item you want to listen to. Or at least something that’s on stage.

stage.addEventListener(KeyboardEvent.KEY_UP, keyHandler);
stage.focus = stage;

Nature is math.

Posted on August 27th, 2009 by hp. – 1 Comment

And a great reference when you want to create natural curves.
Found Functions

How about a bell-curve?

How about a bell-curve?

How Google can save your ass!

Posted on August 26th, 2009 by Knut – Be the first to comment

analytics

On a recent project we were having server performance issues when the load was high. The server usually performed well, but occasionally the server did not respond as fast as we wanted. Locating the culprit was hard since it was fairly sporadic.

To try and locate the issue we added event tracking using Google analytics to every remoting call. One just before the call, one just after the call completed as well as tracking any errors that might occur. The event tracking at the end of the remoting call included the time the remoting call had taken in milliseconds. Voila! A few hours later and Google Analytics located the bugger for us. Google’s event tracking displays the average time for the call to complete. One of the calls took a lot longer than all the others and was quickly blamed.

ExternalInterface.call("pageTracker._trackEvent", "Remoting", "remotingCallName", "complete", time);

Google Analytics is the dog’s bollocks!