I'm trying to use the Checkout manager to checkout (duh) :) the
files.
Not all the code is relevant, but here is the code that I've got (so
far) that isn't working quite right.
public static void Checkout(BuildCycle buildCycle)
{
Borland.StarTeam.View view = null;
Borland.StarTeam.Folder folder = null;
try
{
LogOn();
CheckoutOptions checkoutOptions = new CheckoutOptions
(buildCycle.Build.StView);
checkoutOptions.EOLConversionEnabled = false;
if (buildCycle.Build.StLabel != null) // label
provided, so use it, label has high priority than an as of time
{
checkoutOptions.CheckoutLabelID =
buildCycle.Build.StLabel.ID;
view = new View(buildCycle.Build.StView,
ViewConfiguration.CreateFromLabel(checkoutOptions.CheckoutLabelID));
}
else if (!buildCycle.CheckoutTimeStamp.Year.Equals
(DateTime.MaxValue.Year)) // not maximum date, so must want a dt
checkout
{
checkoutOptions.CheckoutDate =
buildCycle.CheckoutTimeStamp;
view = new View(buildCycle.Build.StView,
ViewConfiguration.CreateFromTime
(checkoutOptions.CheckoutDate));
}
else // no special configuration, so use tip revisions
{
checkoutOptions.SetTips();
view = new View(buildCycle.Build.StView,
ViewConfiguration.CreateTip());
}
if (view == null)
throw new RBuilder.Library.BuildException
(BuildExceptionCode.InvalidView);
CheckoutManager coMgr = new CheckoutManager(view,
checkoutOptions);
CheckoutEventSource eventSource =
coMgr.NewCheckoutEventSource();
eventSource.OnNotifyProgress += new
CheckoutEventSource.Handler(eventSource_OnNotifyProgress);
if (view.RootFolder.Name.Equals("Source"))
folder = view.RootFolder;
else
folder = StarTeamFinder.FindSubFolder
(view.RootFolder, "Source");
if (folder == null)
throw new BuildException
(BuildExceptionCode.StarTeamException);
fileCollection = new FileCollection(); // populated
by OnNotifyProgress if checkout of a file fails
buildCycle.Log.Write(view.ToString());
buildCycle.Log.Write(view.Configuration.ToString());
coMgr.Checkout(folder, ALL_DESCENDANTS);
buildCycle.Log.Write(coMgr.ToString());
if (fileCollection.Count > 0)
{
String s = "Checkout on the following files was
not successfull:\n";
foreach (Borland.StarTeam.File f in
fileCollection)
s += String.Format("File: {0}\n", f.FullName);
throw new Exception(s);
}
}
catch (Exception ex)
{
buildCycle.Log.Write(String.Format("Checking out files
for build id {0} ({1}) failed.", buildCycle.Build.Id,
buildCycle.Build.Project.Name));
throw new BuildException
(BuildExceptionCode.CheckoutFailed, ex);
}
}
So on to the problem.
The above works fine in the default view. I can set a datetime value
and check out the code and when I change the configuration in the GUI
to match that time value (offset by local time) the files all show a
correct status of current. The problem arises when I want to do a
check out of a non default (sub) view. Everything -appears- to work
ok, but when I go to the derived view, change the view configuration
to match the requested time to validate, the result shown are not
correct. Many files have an incorrect status.
I'm obviously missing something, but I'm not sure what. I have tried
adding a view.Refresh() and a folder.Refresh() before calling the
coMgr.Checkout function, but that didn't appear to be of any help.
Suggestions?