Discussion:
Using the "stcmd" utility, working folder best practices
(too old to reply)
Rob Ries
2006-03-06 21:41:00 UTC
Permalink
I'm new to StarTeam. I'm trying to come up with the "right way" to use stcmd - our shop is command-line-centric. Here's the issue [writeup may seem a bit long-winded - it's because I submitted the question to our internal StarTeam folks, who may not be as well-versed with the stcmd options as you are]:

In short, the question is something like: "What is the recommended best practice for getting the most out of this command-line utility?" The longer version goes as follows:

Most of the stcmd actions request that you include the following as one of the options to the command:

-p "userName:***@hostName:endpoint/projectName/viewName/folderHierarchy/"

For example, the checkout, checkin, and list stcmd commands all need that "project identifier" option in order to tell StarTeam who you are and what StarTeam project to access when taking whatever action you are directing it to take (via other parameters on the same line - for example, checkout, checkin, list...).

My immediate reaction was: set an environment variable like "$P" so that you don't have to keep entering this info every time you ran a StarTeam command. So I did (using cygwin here):

export P="myusername:***@100.100.100.200:49201/PointOfSale/prototype"

By doing the above, you can then do things like:

stcmd list -p "$P" "build.properties"

and it'll dump a listing of the status of, say, your "build.properties" file in your top level directory named "prototype".

So that's all fine and dandy. My question arises when I want to perform actions on files that are NOT in that top level directory. For example, down in a src/com/nasd/blah/blah sub-directory, I have a .java file. I want to do stcmd stuff (checkout, checkin, list) THAT file. I certainly do not want to have to reset the "$P" environment variable every time I change directory.

But my experiments have not come up with the right answer here. I have tried:

1. remain in that top "prototype" directory and use a relative path down to the source file:

stcmd list -p "$P" "src/com/nasd/blah/blah/source.java"

...but that gives a "No file matching src/com/nasd/blah/blah/source.java were found..." message.

2. cd down into that directory that holds source.java, and then try:

stcmd list -p "$P" "source.java"

...again - "No file matching source.java were found..." message.

What DOES work, but which I think is unusable, is the following:

cd back up to that top directory (prototype), and use the "-is" (recursive) option:

stcmd list -p "$P" -is "source.java"

That one DOES find the source.java file, but what if I had 2 of them in my tree - the recursive approach does not give me an exact way to refer to a specific instance of a given filename.

Clearly I am missing something here. What is the right way to do this?
Matthew Daniel
2006-03-07 15:30:24 UTC
Permalink
Post by Rob Ries
So that's all fine and dandy. My question arises when I want to perform actions on files that are NOT in that top level directory. For example, down in a src/com/nasd/blah/blah sub-directory, I have a .java file. I want to do stcmd stuff (checkout, checkin, list) THAT file. I certainly do not want to have to reset the "$P" environment variable every time I change directory.
Using bash as my shell, so caveat shellator.

The trick, in my world, is to update the StarTeam project URL based on
your location within the working copy.

I have found the "##" shell interpolation to do that for me. In case one
is not familiar with that, it deletes the longest substring found after
the ## from the string found before the ##. In theory, one could use sed
or expr to achieve the same result.

The bad news is that if one has multiple working copies, they'll need to
determine for themselves how to get the project URL and root of the
working copy.

HTH,
-- /v\atthew

#! /bin/sh
BIN=/opt/Borland/StarTeam-8.0.0/bin/stcmd
URL="***@star:49201/proj1"
WORKDIR=$HOME/working/path
MODPATH=${PWD##$WORKDIR}
P_ARG=$URL$MODPATH
PWDFILE_ARG=$HOME/.starbase/passwd
CMD=$1
if [ -n "$CMD" ]; then
shift
fi
OPTS="-p $P_ARG"
OPTS="$OPTS -pwdfile $PWDFILE_ARG"
OPTS="$OPTS -fp $PWD"
OPTS="$OPTS -stop"
$BIN $CMD $OPTS "$@"
David Hegland
2006-03-07 15:29:45 UTC
Permalink
Rob,

Think like this
stcmd list -p "$S/PointOfSale/prototype/folder/folder/folder...."
"build.properties"
:) dave

Loading...