Sep 19 2008

Visual Studio & SVN integration

Category: Programming, toolsMaciek Talaska @ 2:29 pm

SVN is nowadays one of the most popular version control systems. There is a great tool for Windows called TortoiseSVN – it is very popular, easy to use and has a lot of features. But… it is not very convenient while developing. The need to switch from Visual Studio just to check-in, resolve conflicts… well it is definitely not what I want. I wanted to have a tool that integrates with Visual Studio just like Microsoft’s Visual Source Safe or TFS does. Quite a while ago I tried AnkhSVN, but it didn’t work as good as I wanted – it had a heavy impact on my Visual Studio (sometimes I had to wait very long to be able to do anything – because VS tended to freeze).

Few months ago I found out that many people praise VisualSVN. It is not a plugin (just like the old AnkhSVN) – it uses SCC interface, so it behaves just like VSS/TFS. Some people says that the only thing they dislike is that they feel it just a wrapper for TortoiseSVN (VisualSVN just launches TortoiseSVN’s dialogs for most of the operations). I think it is not a disadvantage – TortoiseSVN is a great client, so if there is a way to use not, and not be forced to switch from Visual Studio to Explorer / Total Commander / any other shell… that’s just great (for me). The only disadvantage of VisuaSVN is that one have to pay for it. In the past it was very cheap (19$) but after gaining popularity it became much more expensive – now it costs 50$ (but there is a way to get it for free – one just have to be active developer involved in open source project).

Well… I wanted to find a free alternative, and that’s how I found Garry Bodsworth’s special settings, that integrates TortoiseSVN with Visual Studio. It is free. It is fast (there is no impact on Visual Studio performance). It contains both: version for VS2008 and VS2005. Perfect? Well… almost ;) It is just a setting file, so ‘Pending Checkins’ won’t work, there is no mechanism showing new files or changed files in projects / solutions…

All those things that Garry’s settings lacks are provided by the latest, totally rewritten version of AnkhSVN! Now AnkhSVN works not as a plugin, but as SCC package – the integration is done the way it should be. The impact on Visual Studio performance is not noticeable. ‘Pending Checkins’ works just like with VSS / TFS, managing newly added, changed or deleted files in solutions / projects is much simpler – thanks to showing all the changes right in the solution view. Personally I think that TortoiseSVN’s dialogs are better ;) so at the moment I am using both – Garry’s settings and AnkhSVN. Garry’s settings allows me to use very well known by me mechanisms provided by TortoiseSVN, and AnkhSVN shows me all the changes I have made recently – it saves me a lot of time, and I am sure I won’t miss any file while doing heck-in.

Tags: , ,


Sep 05 2008

Automatic system backups

Category: WindowsMaciek Talaska @ 12:10 am

The need of creating backups is obvious. Data is the most important thing on everyone’s PC. But how about all the environment? What about system, it’s configuration, configuration of all installed applications? A while ago a new idea was presented – image creating software. The first was (I think) Norton Ghost. At the very begging the app was very, very small (just a little bit bigger than 100 kilobytes) and run under DOS (so yes, you did have to have a DOS bootable diskette, or ability to boot into plain old DOS environment). This kind of software became more and more popular, and nowadays there are dozens of applications you may choose from. There is, however, one I would like to present – special version of Acronis True Image available under the name of “MaxBlast” at Seagate’s site. This software is free for everyone who has Maxtor or Seagate hard drive installed in their PC. I am not sure which version of Acronis True Image is being available under the label of MaxBlast, but as far as I remember it is version 10.0 (there is version 11.0 of Acronis True Image available). So what is so great about this software except it’s price? Well, it suits my needs very good: it creates really small images (although it takes a lot of time, if you choose the maximum compression level), and allows to restore images in a very convenient way – you just decide what you want to do, and if you choose to restore whole system partition (the one you actually work on) the software boots before windows, and makes all operations necessary to restore your previous environment.

There is one thing, I think would be very handful for a lot of people. Possibility of storing configuration on-line. I imagine it should work like this: all applications will use the same way of storing all its settings (for example somewhere in Applications Data). Zipping those files should not be a problem. And of course it should be possibile to restore the configuration in only few clicks. I would like it to be connected with one of the free file storing services (Dropbox, Microsoft’s SkyDrive or any other). Advantage of such a behavior is obvious – one could save a lot of time in case of reinstalling system and all applications (and it is not always possible to restore previously created system image – sometimes you just install your system from scratch, for example after acquiring new machine…).

Anyway… going back to system backups. They are really important, but what I have learned while working with Windows is that registry files are crucial. Sometimes you may wonder what happened, and after deep investigation you realize that one (or more) of registry files is broken. So… what to do? Creating system backup everyday is not convenient (and as I said before – it takes a lot of time. Personally I create full system backup once a week only). But there is a way to keep those vulnerable files in safe place in case something happens. There is even a small and handy application written that does this task for you – Erunt. I started using this small tool a while ago, and after a couple of weeks I have spotted an interesting article that shows how to configure Erunt using task scheduler, so it is being run every time your Windows starts. It is great, but… those backup files are a bit too big (registry backup on my Vista based laptop takes about 80MB for each day – for me it is definitely too big). I started to create a small batch, that you may find useful. So, here it is:

@echo off
set root=AutoBackup
set maxfiles=5
"eruntAUTOBACK.EXE" %root%#Date# sysreg otherusers /noconfirmdelete /noprogresswindow

rem setting date variables
set day=%DATE:~7,2%
if %day:~0,1% == 0 (set shortday=%DATE:~8,1%) else (set shortday=%DATE:~7,2%)
set month=%DATE:~4,2%
if %month:~0,1% == 0 (set shortmonth=%DATE:~5,1%) else (set shortmonth=%month%)
set year=%DATE:~-4%

rem setting archive and folder names...
set archive_name=%year%-%month%-%day%
set folder_name=%shortmonth%-%shortday%-%year%

rem compress the registry backup files...
cd %root%

rem backup command: "c:program files7-Zip7z.exe" a -r -t7z -mx9 <archive name> <directory>
"c:program files7-Zip7z.exe" a -r -t7z -mx9 %archive_name%.7z %folder_name%
cd ..

rem ...removing folder...
rd /S /Q %root%%folder_name%

rem ...checking if there are some old-registry backup files that should be deleted

@if exist files.txt ( del files.txt )
cd %root%
@set filenum=0
@dir *.7z /b /o:-n > ..files.txt

for /f %%f in (..files.txt) do (
call ..autorun-del.cmd %%f )
cd..
if exist files.txt ( del files.txt )

and (thanks to the limitations of batch files) the second, very small batch:

set /a filenum=filenum+1
if %filenum% GTR %maxfiles% ( del /F /Q %1 )
How does it work? The idea is simple. After creating folder that contains backup of all registry files – the folder and its’ content is being compressed. Then, the folder is being deleted. At the end the script checks if there are too many backup files (i.e. if amount of backup files is greater than the one you set in ‘autorun.cmd’) – if so, the oldest file(s) are deleted. I have set the script to run before logging into Windows, but you can of course run the script manually (if using Vista with UAC remember to give it proper privileges). Archives containing backups of registry files are created per-day – if the script is being run more then once – it updates the content of the archive. I assumed that:
  • the folder where Erunt is stored is named ‘Erunt’; both batch files should be located in the Erunt’s parent folder
  • archives with registry backup files are stored in Erunt’s sibling-folder. The folder’s name is ‘AutoBackup’ (you may change it – folder name is stored in %root% variable)
  • default amount of backup archives is 5 – it may be changed by editing %maxfiles% – thanks to compression one archive is only about 11MB, so even storing backups of last two weeks is not a big-deal.
After struggling with windows batch files, I solemnly promised myself not to use it any more. Next time I will have to create anything like this, I will use PowerShell or Python ;) Batch files are a real pain. Hope someone finds it a bit helpful. For me it is a way to be more confident that in case of system damage I will be able to recover my environment very fast.

Tags: , ,