VSS How To: Safely Rollback a Project to a Specific Date and Time


If you’re like me, you don’t necessarily label your
Visual SourceSafe* project folders as methodically or as often as you
should. My failure to do so recently found in me in a pickle. Here’s what I did
and how I worked around it:


Over the course of three or four months, I built a simple  href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vbtchtopquestionsaboutaspnetdatagridservercontrol.asp">ASP.NET
DataGrid library app for an extended team. I wrote it in href="http://msdn.microsoft.com/vcsharp/">C# using Visual Studio .NET
2003 * and added it to my favorite
VSS database before writing a single line of code (as I try to do
with all projects). My teammates can easily add their books to the online library. They
simply enter an ISBN, click Go, and boom, all other fields (author,
pubdate, pages, price, rating, etc) are autopopulated in the
DataGrid by a little href="http://www.occultopedia.com/m/menehune.htm">menehune librarian in the
Web Services department over at Amazon.  If you haven’t
investigated the href="http://aspalliance.com/shark/articles/amzws/amzdoc.aspx">Amazon Web
services development kit yet, I recommend you do.  But I digress.


One day, I decided to change my library’s backend from
>>lib.xml<< to a slightly more manageable, secure, reliable,
redundant, and extensible data store: a SQL Server* database.  Like most
adhoc coders with more desire than brains, I planned for a few seconds and then
started hacking at my aspx file. After two days, I found myself swimming
in version-mismatched files and broken build after broken build. My source
files were more comment than code, my task list looked like a Mozart symphony
put to words, and I was on the brink of a buffer overrun.  I know
you’ve been there… hair in fists, chips on floor, pop or coffee on the wall,
mouse and keyboard dangling from your desk, monitor about to fall off its
stand–looking at you sideways like a disapproving parent.  Yes, I was
ready to destroy my source files and START FRESH.  And then a
little voice, a calm, quiet little voice–perhaps that of an Amazon
menehune–spoke to me from afar. ‘C’mon dude, you work on the VSS team,’ the
voice said. ‘You know how to return your project to the last known
good version, even though you haven’t kept check-in comments or maintained
labels as you should have!’


And I thought, ‘Sure. I can do a Virtual Rollback (for lack of a better
term) in VSS, promote versions of all project files from a certain
date and time to the top of the version stack, and the next time I
check out, I can then rebuild the project as it worked two days ago when
everything was simple and XML was king.’  So I did and here’s how you can
do it if you ever find yourself in a similar situation:


Method #1, VSS Command Line, non-Destructive Rollback. This is
a little arcane, but some of the switch combinations I used have not been
documented very well.



  1. SS CHECKOUT $/library -R -GF -Ykorbyp,*foo_pwd#21
    This command
    recursively (-R) checks out the latest database version of all items in
    $/library and its subprojects and places them in their pre-ordained
    working folders by force (-GF temporarily sets
    the Force_Dir ini variable to Yes but I recommend you do so
    permanently).
  2. SS GET $/library -R -VD2-2-2002 -GWR -Ykorbyp,*foo_pwd#21
    This
    command recursively gets all files by version date (-VD)
    and replaces the writable (-GWR) files that are already in the working
    folder (from step #1).
  3. SS CHECKIN $/library -R -Ykorbyp,*foo_pwd#21.
    This command eplaces the
    latest database version of all files in the project with the files from their
    working folders.

Method #2, VSS Explorer Virtual Rollback.



  1. style="MARGIN: 0in 0in 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; mso-list: l0 level1 lfo1; tab-stops: list .5in"
    >Select the file in VSS Explorer.
  2. style="MARGIN: 0in 0in 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; mso-list: l0 level1 lfo1; tab-stops: list .5in"
    >Check
    out the file using the Check Out command on the SourceSafe menu.
  3. style="MARGIN: 0in 0in 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; mso-list: l0 level1 lfo1; tab-stops: list .5in"
    >On
    the Tools menu, click Show History to display the History
    Options
    dialog box.
  4. style="MARGIN: 0in 0in 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; mso-list: l0 level1 lfo1; tab-stops: list .5in"
    >Click
    OK to display the History of File dialog box.
  5. style="MARGIN: 0in 0in 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; mso-list: l0 level1 lfo1; tab-stops: list .5in"
    >Select
    a previous version of the file, then click Get.

The Get dialog box appears.



  1. style="MARGIN: 0in 0in 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; mso-list: l0 level1 lfo1; tab-stops: list .5in"
    >In
    the Get dialog box, click OK.

A message asking whether to replace the checked
out file appears.



  1. style="MARGIN: 0in 0in 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; mso-list: l0 level1 lfo1; tab-stops: list .5in"
    >In
    reponse to the message, click Replace.
  2. style="MARGIN: 0in 0in 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; mso-list: l0 level1 lfo1; tab-stops: list .5in"
    >Click
    Close to quit the History of File dialog box.
  3. style="MARGIN: 0in 0in 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; mso-list: l0 level1 lfo1; tab-stops: list .5in"
    > style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"
    >Check
    the file back into VSS Explorer using the Check In command on the
    SourceSafe menu.

*Visual SourceSafe, Visual C# .NET,
and MSDE, the UI-less version of SQL Server are all included in the
Enterprise Developer, Enterprise Architect, and
MSDN Universal editions of Visual Studio .NET along with a lot of
other cool toys. I like to think of these tools as upward mobility
vehicles for the opportunistic coder.

 

This posting is provided “AS IS” with
no warranties, and confers no rights.
size=2> Microsoft kann für die Richtigkeit und Vollständigkeit der Inhalte
in dieser Blog keine Haftung übernehmen.
size=2>Este mensaje se proporciona “como está” sin garantías de ninguna clase, y
no otorga ningún derecho.

Comments (7)

  1. Nicolas says:

    Can I rollback a entire project to a specific label? It seem the rollback only work on one file.

    Ok I can use the trick: checkout, delete, get old version, check-in. But the history (and comment) are not updated. (and btw its not a real rollback, just a trick to lull VSS)

    The only problem of this trick is you dont update the history of the project.

    Thanks

  2. Hari says:

    But how do i rollback on project level instead of file level..

    I hv version 1.0 files and then updated VSS project with version 2.0

    Now i want entire project to rollback to version 1.0.

    how can i achieve this on entire project and not file by file..

    Thnx

    hari

  3. method says:

    Hello, good site and interesting design!

    <a href=" http://xanaxsale.tdfsf.info/xanax-sales.html ">xanax sales</a>
    <a href=" http://xanaxsale.tdfsf.info/xanax-sales.html ">xanax sales</a>

    Thanks!