July 22, 2011

SVN - Who has created the branch?

I wanted to get the author name who has created a branch in our SVN. With some doco read, I was able to find the answer.
svn log -r 1:HEAD --limit 1 --stop-on-copy
With --limit we can limit the number of results we get from the query, in this case we need only one.

When creating a branch we copy from another SVN location, thus --stop-on-copy comes handy here.

SVN Sparse Directories (partial checkouts)

SVN 1.5 introduces a feature called sparse directories (or shallow checkouts or partial checkouts) that allows you to easily check out a working copy or a portion of a working copy.

How do we do it? On the command prompt use the following commands:
# svn co --depth empty
# pushd
(Assume: foo is a folder in SVN. With the following command you will not get any leaf folders or files.)
# svn up --depth empty foo
(Assume: bar is a sub-folder in foo. With this you will get all from foo/bar)
#svn up foo/bar
(With the following command, you get the only the latest copies of the checked out folders from SVN)
# popd
# svn up
(You can also perform a SVN commit at this level)

Performing SVN checkout (co) for each and every folder you require from SVN is not the way to go, since you cannot do a global SVN update or a commit.



July 21, 2011

HOWTO: Pass more than 10 arguments to a DOS batch file

Batch files can only handle parameters %0 to %9
%0 is the program name as it was called,
%1 is the first command line parameter,
%2 is the second command line parameter,
and so on till %9.

The batch file's limitation to handle parameters up to %9 only can be overcome by using SHIFT.

After NT 4, we do not need to use SHIFT...
FOR %%A IN (%*) DO (
      rem Now your batch file handles %%A instead of %1
)
%* will always expand to all original parameters, sadly. But you can use the following snippet of code to build a variable containing all but the first parameter:

:my_function
rem skip the first arag
shift
set args=%1
:my_loop
shift
if [%1]==[] goto my_end_loop
set args=%args% %1
goto :my_loop
:my_end_loop
rem Do somthing with the args 
goto :EOF

You can call this inside your batch file:
call :my_function %*

After a long silent...

After a long silent I am trying again to post blog posts. Wish me luck...