Project and Portfolio Management Practitioners Forum

Combining File Chooser with "svn list" Subversion Command

Respected Contributor.

Combining File Chooser with "svn list" Subversion Command

I am trying to integrate PPM with Subversion. I want to be able to choose Subversion file(s) and/or folder(s) to add to a PPM package. The out-of-the-box Directory Chooser works only up to the parent SVN repository folder, since SVN's "directory structure" thereafter is virtual, in the database; and the out-of-the-box File Chooser only shows config & database files at that repository level. The only way to drill down inside the repository to view tags, files, etc., is to execute "svn list" from the command line and provide a URL.


I currently have a Subversion client installed on the PPM server. I am able to connect, and I can execute "svn list" via a PPM Special Command to list the folders within my current directory (as far as I can go with the out-of-the-box Directory Chooser).


How can I build a PPM File Chooser that leverages "svn list" so a user can drill down (with repetitive "svn list" executions) to find the desired files?


Keep in mind, in the end, Subversion will know what file(s) and/or folder(s) to promote based on a URL. So I will concatenate a [base SVN URL] with [the directory they chose] with [the file they chose] to give the full URL to the individual file in SVN's database structure.


Any help is appreciated. Thank you!

Respected Contributor.

Re: Combining File Chooser with "svn list" Subversion Command

I have gotten to the point where I can get the validation to show the list of values from "svn list." In case anyone else could benefit from this, the code for the special command is below. It includes examples of how to use "ksc_begin_script," "ksc_end_script," "ksc_capture_output," and "ksc_local_exec." The validation is an Auto Complete List using a "delimited output special command" of a comma.


## SVN_BASE_URL is Subversion Repository base URL
## SVN_PROJ is parameter from Directory Chooser (user chooses project folder)
## SVN_FULL_URL is where "svn list" can begin, restricting to "tags/" folder
## UID used for unique ID for script file so nobody overwrites anybody else
ksc_set SVN_BASE_URL="http://../svn/repos/"

## I want SVN_PROJ (below) to be parameterized from Directory Chooser's P_SUB_PATH object token (HOW?)
ksc_set SVN_PROJ="jms_knta/"
ksc_set SCRIPT_DIR="/u01/hpppm8/logs/temp/"


## AWK command duplicates line values, separating by comma for delimited output
ksc_begin_script [SCRIPT_DIR][UID]_[SYS.DATE]_svnlist.txt
svn list [SVN_FULL_URL] --username admin | awk -F "/" '{print $1 "," $1 "/"}'


ksc_capture_output sh [SCRIPT_DIR][UID]_[SYS.DATE]_svnlist.txt


ksc_local_exec rm [SCRIPT_DIR][UID]_[SYS.DATE]_svnlist.txt


I still do not know how to allow the user to "drill down" with multiple "svn list" executions so they can drill down to the individual file level within Subversion. I will leave this thread open until I figure it out (or someone provides a solution).

Jason Nichols K
Acclaimed Contributor.

Re: Combining File Chooser with "svn list" Subversion Command

I've been wanting to chime in on this for a while, but have been super swamped between rolling off a project and trying to get a house ready to sell.  I did a Subversion integration for a client about a year or so ago.  We didn't use the OOTB Directory Chooser for the Sub Path field.  We created a new validation that used the svn list command.  We created an SVN Environment that held the basics for the SVN server information and we also connected directly to it instead of installing an SVN client on the PPM server.  The APP_DIR token you'll see is a converted form of the APP_CODE.  When the client setup SVN, they lowercased the APP Codes, but the APP Codes are in  PPM in UPPER Case, except for AU_TOP, so we had a couple of steps to determine which App Code was selected and put the appropriate value into the APP_DIR temporary token.


ksc_connect_source_server SOURCE_ENV="SVN"

#Steps for setting APP_DIR go here (conditions used on two steps, one for AU_TOP, one for all others)

svnLines=`svn list -R file://[ENV="SVN".SERVER_BASE_PATH]/[APP_DIR]/ | grep "\/$" | wc -l`
ksc_capture_output if [ $svnLines == 0 ]; then echo ./; else svn list -R file://[ENV="SVN".SERVER_BASE_PATH]/[APP_DIR]/ | grep "\/$"; echo ./; fi


Once I have the Sub Path token, I have a new validation for getting the Filename.  This one also has the same App Code checks, but the import bit is this:


ksc_capture_output svn list file://[ENV="SVN".SERVER_BASE_PATH]/[APP_DIR]/[P.P_SUB_PATH]



Respected Contributor.

Re: Combining File Chooser with "svn list" Subversion Command


That is very good information, and a good starting point with a fresh perspective.


What did you have defined as your "SVN".SERVER_BASE_PATH? Did this enable you to access the SVN database structure, or the repository file structure?


If I understand it correctly, we have something similar, with "SERVER_BASE_PATH" being the base SVN URL with [APP_DIR] being the repository that can be chosen using Directory Chooser (last level before it turns to database format). Is that similar to what you are describing?

Jason Nichols K
Acclaimed Contributor.

Re: Combining File Chooser with "svn list" Subversion Command

The SERVER_BASE_PATH is the directory on the SVN server that the repository is located in (if memory serves).  We used the file:// protocol instead of http, so we it connected, it then translated the db directory structure into a file structure.  Not something that you can step down into, but it would give a complete list of all directories, e.g.







If you look at the code in the ksc_capture_output, I also put in an echo ./ so that it will allow for a file to be at the top level of the App Code directory structure.  That particular directory didn't show up in the svn list output.

Respected Contributor.

Re: Combining File Chooser with "svn list" Subversion Command

Your idea of not drilling down, but instead displaying recursive directories on a single line makes total sense (we actually do something very similar with our current setup). This was very helpful, and a real A-Ha moment!


Once I have completed our solution, I will post what I had to do. Still trying to resolve the issue of referencing the P_SUB_PATH token from the directory chooser (it seems way too cumbersome to have to go through APP_CODEs to accomplish this).


It feels like since the field in the object type has the token, we should be able to reference it in accompanying fields on the same object. Shouldn't be this hard, IMO.