Wednesday, March 26, 2008

Dev : CVS History

I know everyone of us used to have the problem of finding what file we have updated to CVS recently and our current tortoise CVS doesn't allow to view history by project (I think so), so normally we will manually find the file and check the history 1 by 1. gosh... that's tiring...

I've found a cool software that might help us to do the job and cut down the time we wasted on checking files, and yes, it is free. Please goto
http://www.download.com/CVS-Logger/3000-2383_4-10411357.html?tag=lst-1
or goto download.com to find a software called "CVSLogger", download and unzip the application into your pc.

Steps To Open A Project (or specific folder, or specific file) History
1. Upon running the application, goto View --> Options.
2. Change the CVS executable path to your tortoise CVS home. Eg: C:\Program Files\TortoiseCVS
3. Click OK to save the changes.
4. Click File --> Open.
5. Locate the Project/Folder/file that you want to view the history.
6. Click OK to load the history.
7. Wait... It might take a long time to load all the history.

And there you are. With this, you can even filter the history by user basis. Enjoy with the new toy. Thanks alot to Sergey Zozulya for the cool application!

Tuesday, March 11, 2008

Dev : Skipping CVS Folder In WinMerge

WinMerge is quite a powerful tool to compare text document and folders, and I am currently using WinMerge 2.4 for quite some time. Comparing folders content couldn't be easier.

But when it comes to comparing development folders with CVS, it could mean just one thing, a hell lot of files. If you have 100 subfolders, then you will see 200 CVS folders, and 200x6=1200 CVS config files. Add on with your original files, you could end up with 2000-3000 files at least.

So what other alternatives do I have to reduce the file compared and viewed? Yes you do. Firstly, use the WinMerge to compare 2 simple folder. After doing that, clickView. Uncheck "Show Identical Files" and "Show Skipped Files". Other than this, I have no idea how to show this menu without comparing anything, it wont even show if just comparing a file.

You wouldn't want to view identical files if you are to use WinMerge in the first place right?

Unchecking the "Show Skipped Files" need you to actually do this second step. Else, it will not take effect on anything. The second step is to create a filter. Click Open and a small window will appear as below.



Click Select beside the filter dropdown, and another window will appear to let you create your own filter. Click New. It will prompt you to choose whether the new filter will be used personally or share. Anyone will do. It doesn't matter. Create a new filter file name called "CVS Filter", and inside the filter file, edit it to look something like this (most importantly is the bolded part) :

## This is a directory/file filter template for WinMerge
name: CVS Filter
desc: CVS Filter

## Select if filter is inclusive or exclusive

## Inclusive (loose) filter lets through all items not matching rules
## Exclusive filter lets through only items that match to rule
## include or exclude
def: include

## Filters for filenames begin with f:

## Filters for directories begin with d:
## (Inline comments begin with " ##" and extend to the end of the line)

d:
\\CVS$ ## CVS

Save it and there you go. Your new CVS filter is ready to be used with the unchecked of "Show Skipped Files".

Now, you will only see those files you really wish to see.

Monday, March 10, 2008

Dev : Java Code Exception, Getting Error Details

In java coding, we used to have try-catch statement mainly for capturing unforeseen code errors such as SQL query error, parsing a non number to number and as such.

Normally within the catch, we will either throw it back to the method that calls it, or print it out using printStackTrace(). If we were to print it to a string or a log file, we will use toString(). But then, printing to a log file using toString() method might not be sufficient for a developer.

[12:34:56] java.lang.NullPointerException

What does this means? I know the application is hitting some variables which had not been assigned to any value, but where is it? I had a thousand lines of code, which is hitting the error? My current catch is as such:

catch (Exception e) {
log.error(e.toString());
throw e;
}

Well, to get a better description on the log file, I would recommend to use these code instead of just e.toString():


catch (Exception e) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
pw.close();
log.error(sw.toString());
throw e;
}

These code will actually write the more descriptive printStackTrace() to a buffer, and we print the buffer out instead of writing it somewhere else. With these code, I am able to get better description, including which line and what class as such:

[12:34:56] java.lang.NullPointerException
at a.class.package.anotherMethod(NewClass2.java:87)
at a.class.package.newMethod(NewClass.java:890)
at a.class.package.main(NewClass.java:60)
Exception in thread "main"

Isn't it better than a single line printout?

Saturday, March 01, 2008

Dev : Replace CVS Files, All Files

Windows file REPLACE command is something very useful that every person should know, esspecially for developers. Let me try elaborate using a scenario.

Using Tortoise CVS in windows to backup as well as managing source code versioning is a life saving attemped. It can help you to know who commited what and most of all, it is free.

But then, what if one day, your source code administrator sends all developers an email :
"Hi,

From today onwards, all CVS source code in SUN server will be moved to MOON server due to disk space issue. Please change your workstation's settings accordingly.

Thanks.

From,
Admin."

For the time being, I wouldn't know if there is any other ways to make life easier on this matter. All my source code are pointing towards SUN and now you say MOON? Yeah right, easy for you to say... But first of all, how?

By knowing the behaviour of Tortoise CVS, like every developer knows, there will be a hidden folder called "CVS" in each folder that is using CVS for versioning control in your workstation. But what you should really know is that is what's in it. For the time being, lets get straight to the point.

In each hidden CVS folder, there will be a file called Root. The content of Root might appear differently depending on what CVS authentication you use. As example, ":sspi:mydomain\cksgary@sun:/cvs". Notice that the word "sun" behind "@"? This is the keyword. Just replace the sun with moon. But yet, that is not enough. Because there are more than 2 thousand subfolders that contain this Root file. It is not possible for me to change one by one even if I sacrifice my whole day doing this.

And here comes the real life saver. Using windows REPLACE command really helped out. Just follow the steps below :

1. Ok, lets say your working folder is "D:\work". Make a copy of this Root file in "D:\". Please make sure that it is renamed exactly the same as in the working one. Change the content accordingly.
2. Go to "START --> RUN --> type CMD". This will open a command prompt console for you.
3. Type "REPLACE D:\Root D:\work /s". This will then start replacing all files with the name of Root in all folders and subfolders in "D:\work" with the "d:\Root" file.

3 steps, and you're done. This could be used in any other scenarios if there is a need to replace all files with the same name.