<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Sync often</title><link>http://blogs.msdn.com/chrisid/default.aspx</link><description /><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Undoing "Get Latest Version"</title><link>http://blogs.msdn.com/chrisid/archive/2007/06/12/undoing-get-latest-version.aspx</link><pubDate>Tue, 12 Jun 2007 23:42:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3258372</guid><dc:creator>chrisid</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/chrisid/comments/3258372.aspx</comments><wfw:commentRss>http://blogs.msdn.com/chrisid/commentrss.aspx?PostID=3258372</wfw:commentRss><description>&lt;P&gt;To start off my blog, I'm going to talk about a feature I've&amp;nbsp;occasionally wished TF Version Control had, and some alternatives that you may find acceptable.&lt;/P&gt;
&lt;P&gt;From the &lt;A class="" href="http://msdn2.microsoft.com/en-us/library/fx7sdeyf(vs.90).aspx" mce_href="http://msdn2.microsoft.com/en-us/library/fx7sdeyf(vs.90).aspx"&gt;documentation for "tf.exe get"&lt;/A&gt;:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;"If you work in a team development environment, &lt;B&gt;Get&lt;/B&gt; is the command you use most frequently because getting every file in the current project synchronizes with your team and makes sure that you have the very latest copy of shared work."&amp;nbsp;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;What that doesn't mention is sometimes the very latest copy of some code in a&amp;nbsp;dark corner of your workspace will fail to build - horribly.&amp;nbsp; You just&amp;nbsp;did a&amp;nbsp;full sync, built&amp;nbsp;and regret it.&amp;nbsp; You're unwilling or unable to resolve the build issues.&amp;nbsp;If only you could have your old workspace back - you know &lt;EM&gt;that &lt;/EM&gt;built.&amp;nbsp; But how do you get it back?&amp;nbsp; "tf undo" undoes pending changes, not&amp;nbsp;the last sync you performed.&lt;/P&gt;
&lt;P&gt;If you didn't plan for this, there may not be anything&amp;nbsp;you can do after the fact.&amp;nbsp; If you have an idea of when you last sunc, you can use "Get Specific Version..." with a date or changeset estimate.&amp;nbsp; Maybe you can find a recent successful build on your builds drop share and relate that back to a changeset/date.&amp;nbsp; If syncing and building doesn't take long, maybe you can use trial and error.&lt;/P&gt;
&lt;P&gt;Here are some ideas&amp;nbsp;on preparing for&amp;nbsp;a sync in case you've been bitten by this and are now wary:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Use "tf get /preview" to see what&amp;nbsp;changes a&amp;nbsp;full sync will make.&amp;nbsp; Maybe that will help you decide if you're willing to risk syncing.&lt;/LI&gt;
&lt;LI&gt;While your workspace is in a good state, figure out when you last sunc.&amp;nbsp; If your workspace has a single root,&amp;nbsp;you can use&amp;nbsp;"tf history /r /version:C1~W /stopafter:1 D:\my\workspace\root" and&amp;nbsp;note the changeset number.&amp;nbsp; This is the changeset number you'll want to return to if you don't like tip.&amp;nbsp;(If you have several roots to your workspace&amp;nbsp;you'll have to run it several times and remember the highest number.) There are some cases where this will be inaccurate because there's no one changeset number or point in time&amp;nbsp;that lines up with&amp;nbsp;the file versions&amp;nbsp;you have in your workspace.&amp;nbsp; For example, you've checked in more recently than you've sunc, you've performed gets that were less than full workspace gets, or you or your team project have "Get Latest on Checkout" turned on.&amp;nbsp; (Credit to Chandru for the tip.)&lt;/LI&gt;
&lt;LI&gt;Label all the files in your current workspace. This gets around the limitation of trying to represent your workspace state&amp;nbsp;with a single changeset. (Delete a label before re-using it for this, because file deletions don't get labeled.)&lt;/LI&gt;
&lt;LI&gt;If you always sync from the command-line, write a tf.bat wrapper to log tf calls with the date, time, current directory and arguments.&amp;nbsp; You can refer to this log to figure out when you previously sunc.&amp;nbsp; Here's my attempt:&lt;/LI&gt;&lt;/UL&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;@echo off&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;rem Only log Gets&lt;BR&gt;if /i "%1" neq "get" goto :RUNTF&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;rem log to internal\tf_invokes.log, relative to this script's path.&lt;BR&gt;set LOG=%~dp0internal\tf_invokes.log&lt;BR&gt;echo.&amp;gt;&amp;gt;%LOG%&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;rem format the date in .Net's SortableDateTimePattern.&amp;nbsp; Like UTC but using the local timezone.&lt;BR&gt;for /f "tokens=1,2,3,4 delims=/ " %%a in ("%DATE%") DO set SDTDATE=%%d-%%b-%%c&lt;BR&gt;set SDTTIME=%TIME%&lt;BR&gt;if "%SDTTIME:~0,1%" == " " set SDTTIME=0%SDTTIME:~1%&lt;BR&gt;set BEGIN=%SDTDATE%T%SDTTIME%&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;echo //[%BEGIN% ::&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ] [%CD%] [%*]&amp;gt;&amp;gt;%LOG%&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;:RUNTF&lt;BR&gt;rem actually run the command&lt;BR&gt;tf.exe %*&lt;BR&gt;set TFERRORLEVEL=%ERRORLEVEL%&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;rem Only log Gets&lt;BR&gt;if /i "%1" neq "get" goto :end&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;for /f "tokens=1,2,3,4 delims=/ " %%a in ("%DATE%") DO set SDTDATE=%%d-%%b-%%c&lt;BR&gt;set SDTTIME=%TIME%&lt;BR&gt;if "%SDTTIME:~0,1%" == " " set SDTTIME=0%SDTTIME:~1%&lt;BR&gt;set END=%SDTDATE%T%SDTTIME%&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;rem log the end time as well in case its a long running operation.&lt;BR&gt;echo &lt;A href="file://[%25begin%25/"&gt;\\[%BEGIN%&lt;/A&gt; :: %END%] [%CD%] [%*]&amp;gt;&amp;gt;%LOG%&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;:END&lt;BR&gt;exit /b %TFERRORLEVEL%&lt;BR&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=3258372" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/chrisid/archive/tags/undo/default.aspx">undo</category><category domain="http://blogs.msdn.com/chrisid/archive/tags/get/default.aspx">get</category><category domain="http://blogs.msdn.com/chrisid/archive/tags/sync/default.aspx">sync</category></item></channel></rss>