simple svn project repository migration steps

Tuesday, March 29, 2011

Migrate repositories using the eclipse subclipse plugin.
Note this method will not bring revision history into the new repository, so assumes you will still have ongoing access to the old respository. This technique is useful if the history isn't that rich, and you want a quick switch over, or if you don't directly manage the repositories, so svnadmin commands aren't available (like our case, we use a hosted JIRA solution).

Steps:

  1. Create the new project top-level folder in the new repository. Eg: /NEWREPO/projectA/trunk. Using 'new remote folder' in SVN repositories view is the easiest.
  2. Open the existing project in eclipse
  3. Choose team> switch to another branch/tag/revision.
  4. Choose intended top-level project folder (eg /NEWREPO/projectA/trunk). Note this folder name doesn't have to become the eclipse project name
  5. team> revert the project to remove local changes
  6. team> merge (Install into eclipse the fantastic CollabNet Merge client, if haven't already)
  7. Untick best-practices check and choose 'Merge range of revisions', then Next
  8. Select, then under Root, browse to the exisiting project folder (original repo) (eg /OLDREPO/projectA/trunk)
  9. Commit the project

Linux swap space - real usage

Wednesday, January 19, 2011

Using top, ps aux, etc etc gives all kinds of memory usage with lots of blog posts and forum questions explaining how difficult they are to understand, and how typically aren't actually that useful.

As of kernel 2.6.14, smaps has been introduced which means each process reports its own memory usage breakdown.

smaps detail for a process can be seen by:

sudo cat /proc/PID/smaps
where PID is the process ID of the process you're interested in. Note you won't see any content if not the process owner or root.

So, use top, find the big memory hoggers first. Then look at the smaps file for the swap usage. You can use, for example:
sudo grep Swap /proc/30888/smaps | cut -d" " -f 10-20 | grep -v ' 0 kB'
where 30888 is an eg PID.

For more advanced smaps analysis, try the smaps.pl tool. Not sure at this stage, though, whether that tool gives separate swap values.

In Debian at time of this post, the pmap tool has been patched to use smaps, which may then offer swap values in its output.

fitnesse - find disabled tests

Thursday, September 23, 2010

FitNesse suites can grow enormous, so managing them becomes tough. Here's a simple script to find all pages in a given suite that are not marked as either a Test or as a Suite:


#! /bin/bash

if [ $# -eq 0 ]; then
echo "Shows fitnesse tests that aren't enabled as either Test or Suite"
echo 'Usage: ./find_disabled_tests.sh {parent_dir}'
echo 'Eg: ./find_disabled_tests.sh /var/local/fitnesse/FitNesseRoot/SitTests/RichTests'
exit 0
fi


cd $1

find -name properties.xml -print | xargs egrep -L '(Test/|true|Suite/|true)' | sed -e 's,/properties.xml,,'

python stdio in osx launchd

Monday, August 16, 2010

Running Python scripts via launchd doesn't seem to flush stdout print statements (ie. using the basic 'print' command). This can be confirmed by importing sys and calling sys.stdout.flush() after the print statements to see them actually output.

The solution? Add the -u flag to tell python not to buffer its stdio.

In an OSX launchd plist file, your solution may include:


<key>ProgramArguments</key>
<array>
<string>/usr/bin/python</string>
<string>-u</string>

use old laptop as monitor and terminal

Monday, May 31, 2010

I have just had a new Mac Mini arrive that I want to use for mostly automated and headless tasks. But I also want to use this as a home computer for my wife, but it has no screen and no mic, plus not much room on the bench where it lives to fit a keyboard and mouse. My wife has a decrepit (no battery; no harddrive) laptop she's been using, so hey, why not use that as a terminal?

Laptop is running puppy linux (4.3.1). Great little lightweight distro. It boots off CD and uses a USB key for storage.
- Installed tightvnc-client
Mac is running Snow Leopard

So by setting up the script below as a menu option (add to ~/.jwmrc), all she has to do is click it, and the connection begins, including sending all mic input sound (via dd with /dev/dsp) through an audio cable from laptop's headphone jack to Mac's input jack, registering as input on the Mac (Skype-ho!).

Beauty

[caveat: I cannot be held responsible for damage to hardware caused by plugging hardware into each other. Headphone jacks are pretty low voltage though, as I understand it, and it's worked for me]


#!/bin/sh

echo 'Hi, this is how to connect to the Mac Mini'
echo
echo 'Testing for network connection'
if ping -w 2 192.168.1.1 > /dev/null; then
echo ":) Found the router, we're connected already"
else
echo 'Here comes the Network Wizard to connect to the network. You know what to do...'
echo
echo -n 'Press enter once the network is done...'
net-setup.sh > /dev/null 2>&1
read resp
fi
echo
if ping -w 2 192.168.1.9 > /dev/null; then
echo ":) Mac is on, we're ready to connect"
else
echo 'Check the Mac is on. Look for the little white light on the front'
echo -n "Press enter when happy it's on. If only just turned on then wait a minute before continuing..."
read resp
fi
echo
if ps -ef | grep "[d]d if"; then
echo ':) Sound loopback for mic already running'
else
echo 'Ok, starting the sound loopback so we can send the mic to Mac'
dd if=/dev/dsp | dd of=/dev/dsp &
fi
echo
echo 'Right, about to start the connection'
echo "Enter '***' below as the password and you're good to go!"
echo

vncviewer 192.168.1.9:5900 -fullscreen

command line access to hosted JIRA files

Friday, May 28, 2010

Currently I'm on a project that uses an Atlassian-hosted JIRA Studio. We put scripts and config files as wiki page (confluence) attachments, then needed to access them from remote machines via the command line, even as part of a script. JIRA has it's own security methods, not simple http auth, which would be a piece of cake. So, another solution was needed.

A page in the JIRA Community Space describes how to do this using wget with cookies. But it didn't work for me. Whether this is because we are using the hosted variant, or due to changes since that page was written, I found we had to access a different url to log in.

So here's a current working solution that firstly interactively prompts for username and password to log in and creates a cookie:

echo -n "username: "; read uname; echo -n "password: "; stty -echo; read pass; stty echo; wget --save-cookies ~/jira_cookie.txt \
--post-data "os_username=$uname&os_password=$pass&os_cookie=true" -O /tmp/login 'http://OURDOMAIN.jira.com/rest/gadget/1.0/login'; uname=''; pass=''

Replace OURDOMAIN to make the url relevant for your site. This needs to be run only once per machine, at least until the cookie expires. The cookie file will be saved in your home dir.

Next, to retrieve any files, use:
echo -n "file url: "; read url; wget --load-cookies ~/jira_cookie.txt "$url"

Again replacing OURDOMAIN. Run this for each file, pasting the full url to the file to retrieve when prompted.

From these you should be able to see how to strip out the interactivity to make them scriptable, too.

change svn commit comment

Thursday, September 10, 2009

It happens sometimes, committing something in svn then realising the comment was wrongly for something completely different, or the main thing was missed out. Here's how to change it.

If you don't have the repo configured to allow post-commit changes (as per; it is off by default), then you can easily do it on the server as admin with no config changes:

sudo svnadmin setlog --bypass-hooks /path/to/repo /path/to/text-file-with-new-comment.txt -r ##

This command is documented in svn versions 1.4 to 1.6.


Trac
If Trac is being used on the project, then prompt it to re-read the repo and pick up the change by:
trac-admin /path/to/trac-project resync ##

where ## is the revision number to resync. If it is left out then all revisions will be resynchronised.

netbeans - matisse - fix invalid components

Saturday, May 23, 2009

Netbeans' Matisse Swing editor is a great tool. Keeping it running is the challenge. That is, carefully ensuring that .form files are kept in sync with the .java files, and no external editing gets too trigger-happy. The other challenge, it turns out, can be when migrating to a different dev box / dev environment.
I was getting an error when trying to open forms that had opened fine in my previous environment, and I knew they were committed to my version control.

The error:

Error in loading component xxxx... no such property exists.

And then if you carry on to view the form, in navigator you get [invalid component] instead of classnames next to those components.

Infuriating when you know it should work. But I've found it to be only caused by one of 2 reasons:

  1. Compile the class! Ensure that every one of the beans that the form is trying to load is currently compiled (do 'clean and build' on the whole project if in doubt).
  2. Netbeans' JRE incompatible For example, my current project is in Java 6, and the projects were configured fine in Netbeans to use Java 6. However, Netbeans itself was launching in Java 5, which is fine, except that you then get the above error. It would be so easy for the Netbeans team to add this compatbility check one would think, but oh well. So, if Netbeans' JRE (tools> Java Platforms) is lower than your project JRE, change Netbeans' default runtime by either (as of NB 6.5):
    • running the IDE with the --jdkhome switch on the command line
    • or by entering the path to the JDK in the netbeans_jdkhome property of your INSTALLATION_DIRECTORY/etc/netbeans.conf file.


If these don't help, check out [user directory]/var/log/messages.log (eg. for OSX, user dir is '~/.netbeans/[version]/'), and your answer should lie in an exception thrown in there.

netbeans - matisse - convert panel to form

Friday, April 17, 2009

The Swing GUI editor in NetBeans is great. It has a number of samples to build from as well, one of which is the Master/Detail template. That's an example of one that generates a JPanel, and I wanted to convert to a JFrame. Here are the steps, assuming a form named NewForm (with NetBeans 6.5):

  1. In NewForm.java:
    1. Change extends JPanel to extends JFrame.
    2. Change the static void main.. method content to be:
      java.awt.EventQueue.invokeLater(new Runnable() {
      public void run() {
      new NewForm().setVisible(true);
      }
      });

  2. In NewForm.form (may need to edit this outside of NetBeans):
    1. Change the type attribute of Form (near the top) from type="org.netbeans.modules.form.forminfo.JPanelFormInfo" to type="org.netbeans.modules.form.forminfo.JFrameFormInfo".


  3. In the graphical editor, select the Frame and choose the Code tab. Under Form Size Policy, change to Generate pack().


That should be it, good to go. May need to recompile, and/or open close the form to get NetBeans to recognise the changes.

checkpoint secureclient for mac

Thursday, April 09, 2009

It's great that CheckPoint has a SecureClient for the Mac. It works really well. What doesn't work, is making it stop.

There is no way to prevent it booting at startup. Oh, there are ways referred to by CheckPoint's docs, but as they say in the fine print, that just stops the gui from starting - any security policies (read: complete firewall lockdown) will still be in place. And if you do have the gui up and choose 'Stop VPN-1 SecureClient', again it's only the gui that goes, and you go mad like me having lost your svn, http, etc server, not knowing why. There are ways to control it via the command line which you could script, but your admins have to have allowed it to allow that via some centralised settings at their end.

So, if you do need SC, always launch the gui. If you need access to services on that box, then always choose 'Tools>Disable Security Policy' in SC. And if you don't need it anymore, then say goodbye to it, like I'm about to do.