Implementing the SourceSafe "Get Latest Version" Using Automation

Implementing the SourceSafe "Get Latest Version" Using Automation

Post by Hamid Mohand » Sun, 06 Jan 2002 05:04:31



Hi,
I need some help to do the "Get Latest Version" of the whole project using
SourceSafe automation through Visual C++?  I am a little confused  by the
SourceSafe Object Model.

1- Is there a ready predefined function to do straightly the job or do I
have to step recursively the project tree searching for each file (Item) the
right version to get?

2- What is the "pinned version"? Is it the "latest version" of an item
(loaded when doing the "Get Latest Version")?

Thanks.

 
 
 

Implementing the SourceSafe "Get Latest Version" Using Automation

Post by William H. Bloodwort » Sun, 06 Jan 2002 09:16:53


Hamid,

First, if you think the SourceSafe API is confusing, take a look at the PVCS
API... it's a royal pain.

Anyway, in answer to Question # 1:

You need to call the "Get" method on the IVSSItem interface.  You can get
the VSSItem object you need from the IVSSDatabase method "GetVSSItem" by
passing the complete VSS filename of the file you want to get.  For example,
here's some pseudocode to get the item called foo.cpp. (I'm going to assume
you have a valid IVSSDatabase pointer named spIVSSDatabase)

//...
try
{
   // Create the VSSItem object for "foo.cpp" - will throw a _com_error if
this method fails.
   // VARIANT_FALSE means you don't want deleted files to be considered.
   IVSSItemPtr spIVSSItem =
spIVSSDatabase->GetVSSItem("/$/SomeProject/foo.cpp", VARIANT_FALSE);

   // Pull the latest version of the file... but make sure we have a working
directory first
   // GetLocalSpec returns the entire local path to the file of interest
   CComBSTR localSpec = (const TCHAR *)m_spIVSSItem->GetLocalSpec();
   if (localSpec.Length() > 0)
      m_spIVSSItem->Get(&localSpec, VSSFLAG_TIMEMOD);
   else
   {
      // Do something about not having a working directory...
   }

Quote:}

catch (_com_error & ex_) {  // handle it! }

Question # 2:

It is not the latest version of the file.  It is the version of the file was
"pinned".  You can pin [almost] any version of the file in its history.
When you do a history on the item, you'll see the little pushpin icon to the
left of the version number that is pinned.  If you need that information
programmatically, you'll need to deal with the "GetLinks" method on the
IVSSItem interface.

I hope that is the information you're looking for.  Happy New Year!

- William *worth

*** Great Success REQUIRES Great Effort ***


Quote:> Hi,
> I need some help to do the "Get Latest Version" of the whole project using
> SourceSafe automation through Visual C++?  I am a little confused  by the
> SourceSafe Object Model.

> 1- Is there a ready predefined function to do straightly the job or do I
> have to step recursively the project tree searching for each file (Item)
the
> right version to get?

> 2- What is the "pinned version"? Is it the "latest version" of an item
> (loaded when doing the "Get Latest Version")?

> Thanks.


 
 
 

1. Running a script after "checkout" (or "get latest version")

Hi,
I'm new to SS.  We're developing on a linux server.  I'd
like to be able to checkout or get from the archive, and
then run a script to set file attributes (*nix files have
an executable attribute that is not supported in DOS).  Is
there any way to do this in SS?  If I am bucking the SS
way of doing things, what should my approach be?

Thx in Advance,
-Jeff

2. Programming for Children?

3. Getting Latest Version using Ole automation...

4. Sun PPP

5. """"""""""""""""""""""

6. Problems with SFC

7. Best profile for closure""""""""""Windows Server Engineer""""""""" @ Sacramento CA for 1year project

8. Need Sr. .NET Developer

9. Can I get "Get Latest Version" in context menu?

10. "Store only latest version" checkbox

11. Automating VSS - I just need "get latest version"

12. File's property "Store only latest version" option

13. Can't "Get Latest Version"