Wrote a single-line batch program to add the sources of NetBeans Platform to the local working copy at my system. Recently, I had downloaded the sources for NetBeans Platform 6.0, 6.1, 6.5 and 6.7. Now, I want to commit and tag these sources at PrayogShala. So, I extracted the zip files and checkout the project’s root (let it be denoted by SVNROOT_DIR) on my system.
As I have SVN repository, so I can add any file/folder locally using svn add to become part of the working copy (SVNROOT_DIR). This way, when I will commit using svn commit, I will be able to commit all the locally added files.
This is easily done using IDE’s like NetBeans IDE. However, I was in no mood to run the IDE and open 50+ projects. Then, individually commit them. So, I thought of creating a batch program for this purpose. The batch program should be run from within the working copy, as the svn add command will work only under working copy.
for /d %%X in (%1\*) do svn add %%X
Look simple, isn’t it? Well, it isn’t for a newbie like me. I had to refer internet to learn some batch programming for the purpose. Hence, I was able to code the above. You can refer to one more batch program, I wrote last month for different purpose. Although, its still related to NetBeans IDE.
This program loops (for … in … do) through the immediate sub-directories (%%X) of the root passed as runtime argument (%1). Then, each sub-directory is added (svn add) to the working copy.
For instance, I extracted the zip file for NetBeans Platform 6.5 under C:\nb65 directory. Then, this directory will be passed as runtime argument to the batch program. As, this directory would have sources for all the netbeans module projects. Now, svn add command will automatically scan and add any files/folders found under each module project’s directory.
Well, one can tweak the above batch program to create a text file, that will list full-path-name of all the files, under those directories.
for /d %%X in (%1\*) do echo %%X >> list_of_files.txt
Update (July 18th)
I have created another batch file, named it nbsvn.bat
svn add %1
svn commit -m "Tagging %1 of NB 6.5" %1
When I tried to commit all the added folders at one go, I had problems. So, I changed the method, I have created the SVNROOT_DIR and added all the modules once again. Now, I will run the above script for every module found inside the SVNROOT_DIR.
for /d %%X in (%1\*) do call nbsvn %%X
Hope this helps..