Keyword Expansion in Visual SourceSafe

Keyword expansion is a cool feature that automagically plants metadata from an external source in a file--typically between two pre-defined characters or strings--when some event occurs. In SourceSafe, there are twelve standard keywords to which various types of metadata are appended when a file in which they reside is checked in[1].

The online documentation provides a pretty good overview of SourceSafe keyword expansion and some interesting tips and tricks to help you maximize the utility of the feature. It also explains how to enable keyword expansion in VSS. Please note that there is a minor documentation bug in this topic.  The code that appears below "If no keyword comments are specified, the following comments are assumed:" should begin with "[Keyword Comments]". More details in the FAQs below.

IMO, the most useful Visual SourceSafe keyword is $history: $. In conjunction with SourceSafe's Shadow Folder feature, the $history:  $ keyword is really nifty because it allows you to know when the file was last edited and by whom even when you're not accessing it from the database. $history: $ tells SourceSafe to add something like the following to a file when you check it in:

'$History: Form1.vb $
'
'*****************  Version 24  *****************
'User: Guest        Date: 10/13/03   Time: 12:49p
'Updated in
'$/WindowsApplication8.root/WindowsApplication8

FAQs and Gotchas:
Q: How do you turn on VSS keyword expansion?
A: See how to enable keyword expansion in VSS.

Q: I enabled keyword expansion but it is still not working. Why?
A: Before using this feature, you must close and all database clients that are connected to the database.
...
Keywords are case-sensitive, so confirm that they are properly capitalized.
...
Keyword expansion is disabled by default. Use VSS Admin to make sure that the feature is enabled for files of the type to which you have added keywords (eg, "*.cs").

Q: How can I automatically add comments to keyword expanded text in my source files (*.vb, *.cs, etc)?
A: Insert the following into either your personal Ss.INI file or into the
database-wide Srcsafe.INI:
[Keyword Comments]
*.cs = "//"
*.vb = "'"

[1]Q: Can I create custom VSS keywords, such as $assembly_version: $ ?
A: No. But that would be a JAW DROPPING extensibility feature, wouldn't it?

Gotcha #1: Keyword Expansion can adversely affect performance.
Gotcha #2: Don't enable keyword expansion for binary files.  Just don't.

Additional Resources:

++++++++++++
Ce message est fourni en l état, sans garantie d aucune sorte, et ne vous confère aucun droit. Vous assumez tous les risques liés à son utilisation.This posting is provided "AS IS" with no warranties, and confers no rights.

Published 13 October 03 08:53 by KorbyP

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# AsbjornM said on October 15, 2003 7:23 AM:
Excellent! But from time to time I observe that the expansion does'nt work well always when using VS.NET, i.e. the $Archive tag will only expand when it's empty, so when I rename a file, or copy (god forbid) it to another project it doesn't change, I have to empty it, and check in to get it expanded correctly? $revision seems okay, but there is possible some that are alway expanded and some not?
# AsbjornM said on October 15, 2003 7:27 AM:
BTW, I found this one übercool: Private m_version As String = "$Header: $" Very useful to determine the correct revision for that class/module when things go bad..
# Chris Kennedy said on May 10, 2004 11:25 AM:
If your keyword expansion seems not to be working, check the codepage of the file. If it isn't in the windows standard codepage, then it doesn't work. I just changed about 50 database scripts from unicode. Keyword expansion works now...
# degt said on April 12, 2007 5:35 AM:

Keyword expansion on SQL files is tricky. If you put them at the top the whole thing gets stripped out. Apparently you have to put them AFTER the CREATE/ALTER statements for them to be kept but that ADVERSELY affects readability and appearance.

Perhaps putting them at the end but the idea is that that is the first thing you look at.

# Korby Parnell s Social Software Wunderkammer Keyword Expansion in | Portable Greenhouse said on June 1, 2009 6:06 AM:

PingBack from http://portablegreenhousesite.info/story.php?id=4712

# Korby Parnell s Social Software Wunderkammer Keyword Expansion in | Portable Greenhouse said on June 1, 2009 4:02 PM:

PingBack from http://portablegreenhousesite.info/story.php?id=14335

# Korby Parnell s Social Software Wunderkammer Keyword Expansion in | garden decor said on June 19, 2009 3:13 AM:

PingBack from http://gardendecordesign.info/story.php?id=5487

Leave a Comment

(required) 
(optional)
(required) 

  
Enter Code Here: Required

Search

This Blog

Syndication

Page view tracker