<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Using Mercurial as a local repository for Team Foundation Server / Start Front’N</title>
	<atom:link href="http://lostechies.com/erichexter/2010/06/23/using-mercurial-as-a-local-repository-for-team-foundation-server-start-front-n/feed/" rel="self" type="application/rss+xml" />
	<link>http://lostechies.com/erichexter/2010/06/23/using-mercurial-as-a-local-repository-for-team-foundation-server-start-front-n/</link>
	<description></description>
	<lastBuildDate>Thu, 16 May 2013 09:01:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
	<item>
		<title>By: Ben</title>
		<link>http://lostechies.com/erichexter/2010/06/23/using-mercurial-as-a-local-repository-for-team-foundation-server-start-front-n/#comment-400</link>
		<dc:creator>Ben</dc:creator>
		<pubDate>Tue, 29 May 2012 14:59:00 +0000</pubDate>
		<guid isPermaLink="false">/blogs/hex/archive/2010/06/22/using-mercurial-as-a-local-repository-for-team-foundation-server-start-front-n.aspx#comment-400</guid>
		<description>Here is a powershell script I created with doesn&#039;t require the makewriteable.py and also pushs renames made in HG back into TFS....

hgtfs.ps1
----------------------------------------
param([parameter(Position=0, Mandatory=$true)][string] $action)$HGDirectory = Get-Location$TfsDirectory = @(hg paths &#124; where-object { $_.StartsWith(&quot;default = &quot;) })[0].SubString(10)# Pull from TFSfunction pull{    # Todo pull changes one by one brining who did it and the comment into HG    # tf history . /recursive /format:brief /noprompt /version:300~1000 /sort:ascending    # tf properties . /recursive    # Add the changes from TFS into the TFS HG repository    Set-Location $TfsDirectory    tf get . /recursive    hg commit -A -m &quot;Update from TFS&quot;          # Pull / merge the changes from TFS&#039;s HG repository    Set-Location $HGDirectory    hg pull    hg merge --tool internal:fail    hg commit -m &quot;Merged from TFS&quot;        &quot;&quot;    &quot;The you have the following conflicts which need resolving&quot;    hg resolve -l &#124; write-host -foregroundcolor &quot;red&quot;    #thg commit}# Push to TFSfunction push {    Set-Location $HGDirectory    hg push    Set-Location $TfsDirectory    $FilesModified = @()    $FilesRenamed = @{} # Key: old file name .... Val: new file name    $FilesRemoved = @()    $FilesAdded = @()    # Work out what changes have taken place    &quot;Calculating the changes which have been made in HG...&quot;    tfpt scorch /exclude:.hg,*.user &#124; out-null    $AllChanges = hg status --rev .:tip -A     for($i = 0; $i -lt $AllChanges.length ; $i++)    {        $type = $AllChanges[$i].SubString(0, 2)        $fileName = $AllChanges[$i].SubString(2)                    switch($type)        {            &quot;M &quot; # Modified files                  {                     $FilesModified += $fileName                }             &quot;A &quot; # New Files                {                      $nextType = $null                    $nextFileName = $null                    if($AllChanges.length -gt ($i+1))                    {                        $nextType = $AllChanges[$i+1].SubString(0, 2)                        $nextFileName = $AllChanges[$i+1].SubString(2)                                    }                                        if($nextType -eq &quot;  &quot;)                    {                        # we have a rename                        $FilesRenamed[$nextFileName]=$fileName                        $i++                    }                    else                    {                        # we&#039;re adding the file                        $FilesAdded += $fileName                    }                 }                             &quot;R &quot; # Removed                {                    if($FilesRenamed.ContainsKey($fileName))                    {                        continue                    }                                        $FilesRemoved += $fileName                }                        &quot;C &quot; # Same                 {                     continue                 }                             default                 {                     &quot;Unknown HG status line: &quot;+$AllChanges[$i]                     return -1                }        }    }    # perform the TFS operations     &quot;Renaming files in TFS...&quot;    foreach($file in $FilesRenamed.Keys) {           tf checkout $file &#124; out-null        tf rename $file $FilesRenamed[$file] &#124; out-null    }        &quot;Checking out for edit in TFS...&quot;    foreach($file in $FilesModified) { tf checkout $file &#124; out-null }        &quot;Removing files from TFS...&quot;    foreach($file in $FilesRemoved) { tf delete $file &#124; out-null }    # perform the Mercural update    &quot;Pulling changes out of HG....&quot;    hg update --rev .:tip --clean    # perform any POST TFS operations    &quot;Adding new files to TFS...&quot;    foreach($file in $FilesAdded) { tf add $file }        &quot;Cleaning up...&quot;    tfpt uu /noget    tf checkin}if ($action -eq &quot;push&quot;) { push }elseif ($action -eq &quot;pull&quot;) { pull }else { &quot;Unknown action ... please supply &#039;push&#039; or &#039;pull&#039;&quot; }# return to our starting pointSet-Location $HGDirectory</description>
		<content:encoded><![CDATA[<p>Here is a powershell script I created with doesn&#8217;t require the makewriteable.py and also pushs renames made in HG back into TFS&#8230;.</p>
<p>hgtfs.ps1<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
param([parameter(Position=0, Mandatory=$true)][string] $action)$HGDirectory = Get-Location$TfsDirectory = @(hg paths | where-object { $_.StartsWith(&#8220;default = &#8220;) })[0].SubString(10)# Pull from TFSfunction pull{    # Todo pull changes one by one brining who did it and the comment into HG    # tf history . /recursive /format:brief /noprompt /version:300~1000 /sort:ascending    # tf properties . /recursive    # Add the changes from TFS into the TFS HG repository    Set-Location $TfsDirectory    tf get . /recursive    hg commit -A -m &#8220;Update from TFS&#8221;          # Pull / merge the changes from TFS&#8217;s HG repository    Set-Location $HGDirectory    hg pull    hg merge &#8211;tool internal:fail    hg commit -m &#8220;Merged from TFS&#8221;        &#8220;&#8221;    &#8220;The you have the following conflicts which need resolving&#8221;    hg resolve -l | write-host -foregroundcolor &#8220;red&#8221;    #thg commit}# Push to TFSfunction push {    Set-Location $HGDirectory    hg push    Set-Location $TfsDirectory    $FilesModified = @()    $FilesRenamed = @{} # Key: old file name &#8230;. Val: new file name    $FilesRemoved = @()    $FilesAdded = @()    # Work out what changes have taken place    &#8220;Calculating the changes which have been made in HG&#8230;&#8221;    tfpt scorch /exclude:.hg,*.user | out-null    $AllChanges = hg status &#8211;rev .:tip -A     for($i = 0; $i -lt $AllChanges.length ; $i++)    {        $type = $AllChanges[$i].SubString(0, 2)        $fileName = $AllChanges[$i].SubString(2)                    switch($type)        {            &#8220;M &#8221; # Modified files                  {                     $FilesModified += $fileName                }             &#8220;A &#8221; # New Files                {                      $nextType = $null                    $nextFileName = $null                    if($AllChanges.length -gt ($i+1))                    {                        $nextType = $AllChanges[$i+1].SubString(0, 2)                        $nextFileName = $AllChanges[$i+1].SubString(2)                                    }                                        if($nextType -eq &#8221;  &#8221;)                    {                        # we have a rename                        $FilesRenamed[$nextFileName]=$fileName                        $i++                    }                    else                    {                        # we&#8217;re adding the file                        $FilesAdded += $fileName                    }                 }                             &#8220;R &#8221; # Removed                {                    if($FilesRenamed.ContainsKey($fileName))                    {                        continue                    }                                        $FilesRemoved += $fileName                }                        &#8220;C &#8221; # Same                 {                     continue                 }                             default                 {                     &#8220;Unknown HG status line: &#8220;+$AllChanges[$i]                     return -1                }        }    }    # perform the TFS operations     &#8220;Renaming files in TFS&#8230;&#8221;    foreach($file in $FilesRenamed.Keys) {           tf checkout $file | out-null        tf rename $file $FilesRenamed[$file] | out-null    }        &#8220;Checking out for edit in TFS&#8230;&#8221;    foreach($file in $FilesModified) { tf checkout $file | out-null }        &#8220;Removing files from TFS&#8230;&#8221;    foreach($file in $FilesRemoved) { tf delete $file | out-null }    # perform the Mercural update    &#8220;Pulling changes out of HG&#8230;.&#8221;    hg update &#8211;rev .:tip &#8211;clean    # perform any POST TFS operations    &#8220;Adding new files to TFS&#8230;&#8221;    foreach($file in $FilesAdded) { tf add $file }        &#8220;Cleaning up&#8230;&#8221;    tfpt uu /noget    tf checkin}if ($action -eq &#8220;push&#8221;) { push }elseif ($action -eq &#8220;pull&#8221;) { pull }else { &#8220;Unknown action &#8230; please supply &#8216;push&#8217; or &#8216;pull&#8217;&#8221; }# return to our starting pointSet-Location $HGDirectory</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jon Newbill</title>
		<link>http://lostechies.com/erichexter/2010/06/23/using-mercurial-as-a-local-repository-for-team-foundation-server-start-front-n/#comment-392</link>
		<dc:creator>Jon Newbill</dc:creator>
		<pubDate>Wed, 01 Jun 2011 21:07:00 +0000</pubDate>
		<guid isPermaLink="false">/blogs/hex/archive/2010/06/22/using-mercurial-as-a-local-repository-for-team-foundation-server-start-front-n.aspx#comment-392</guid>
		<description>This was most useful.  I found with VS2010 I had to add options /diff and /deletes to the tftp online command in the push script to get changed and deleted files to be checked in to TFS.  Even with this script I&#039;m getting an error from push when a file has been deleted that hg update is 
&quot;unable to remove &quot;FileXYZ&quot; : access  is denied&quot;.  I have the MakeWritable.py extension installed but apparently that is only used for modified files.  Here are my modified scripts.  

-----------------------FILE: push.ps1----------------------------------------------------

$projName = &quot;TicTacToeCMMI&quot;
$tftp = &quot;C:Program FilesMicrosoft Team Foundation Server 2010 Power ToolsTFPT.exe&quot;
$tf = &quot;C:Program FilesMicrosoft Visual Studio 10.0Common7idetf.exe&quot;

hg push
cd ..$projName-tfs

&quot;Syncing -tfs workspace with TFS server&quot;
&amp;$tftp scorch /noprompt /exclude:.hg&#039;,_Resharper*&#039;,*.user

hg update -C -y

&quot;Resyncing Mercurial changes with TFS Server&quot;
&amp;$tftp online /adds /deletes /diff /exclude:&#039;.hgignore,.hg,bin,obj,*.ps1,_Resharper*,*.lnk,*.user,*.suo,*.vspscc&#039;

&quot;Checkin&quot;
&amp;$tf checkin
cd ..$projName-working
cmd /c pause
------------------------------------------------------------------------------------------------ 

-----------------------FILE: pull.ps1----------------------------------------------------

$projName = &quot;TicTacToeCMMI&quot;

$tf = &quot;C:Program FilesMicrosoft Visual Studio 10.0Common7idetf.exe&quot;

$username = cmd /c set USERNAME

$username = $username.SubString($username.IndexOf(&quot;=&quot;)+1)



function pull {

    cd ..$projName-tfs

    &amp;$tf get

    hg commit -A -m &quot;from tfs&quot; --user $username

    cd ..$projName-working

    hg pull --rebase

}

pull

cmd /c pause

---------------------------------------------------------------------------------------------

 

</description>
		<content:encoded><![CDATA[<p>This was most useful.  I found with VS2010 I had to add options /diff and /deletes to the tftp online command in the push script to get changed and deleted files to be checked in to TFS.  Even with this script I&#8217;m getting an error from push when a file has been deleted that hg update is<br />
&#8220;unable to remove &#8220;FileXYZ&#8221; : access  is denied&#8221;.  I have the MakeWritable.py extension installed but apparently that is only used for modified files.  Here are my modified scripts.  </p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;FILE: push.ps1&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>$projName = &#8220;TicTacToeCMMI&#8221;<br />
$tftp = &#8220;C:Program FilesMicrosoft Team Foundation Server 2010 Power ToolsTFPT.exe&#8221;<br />
$tf = &#8220;C:Program FilesMicrosoft Visual Studio 10.0Common7idetf.exe&#8221;</p>
<p>hg push<br />
cd ..$projName-tfs</p>
<p>&#8220;Syncing -tfs workspace with TFS server&#8221;<br />
&amp;$tftp scorch /noprompt /exclude:.hg&#8217;,_Resharper*&#8217;,*.user</p>
<p>hg update -C -y</p>
<p>&#8220;Resyncing Mercurial changes with TFS Server&#8221;<br />
&amp;$tftp online /adds /deletes /diff /exclude:&#8217;.hgignore,.hg,bin,obj,*.ps1,_Resharper*,*.lnk,*.user,*.suo,*.vspscc&#8217;</p>
<p>&#8220;Checkin&#8221;<br />
&amp;$tf checkin<br />
cd ..$projName-working<br />
cmd /c pause<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; </p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;FILE: pull.ps1&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>$projName = &#8220;TicTacToeCMMI&#8221;</p>
<p>$tf = &#8220;C:Program FilesMicrosoft Visual Studio 10.0Common7idetf.exe&#8221;</p>
<p>$username = cmd /c set USERNAME</p>
<p>$username = $username.SubString($username.IndexOf(&#8220;=&#8221;)+1)</p>
<p>function pull {</p>
<p>    cd ..$projName-tfs</p>
<p>    &amp;$tf get</p>
<p>    hg commit -A -m &#8220;from tfs&#8221; &#8211;user $username</p>
<p>    cd ..$projName-working</p>
<p>    hg pull &#8211;rebase</p>
<p>}</p>
<p>pull</p>
<p>cmd /c pause</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeffrey Palermo</title>
		<link>http://lostechies.com/erichexter/2010/06/23/using-mercurial-as-a-local-repository-for-team-foundation-server-start-front-n/#comment-310</link>
		<dc:creator>Jeffrey Palermo</dc:creator>
		<pubDate>Wed, 23 Jun 2010 03:36:43 +0000</pubDate>
		<guid isPermaLink="false">/blogs/hex/archive/2010/06/22/using-mercurial-as-a-local-repository-for-team-foundation-server-start-front-n.aspx#comment-310</guid>
		<description>This is great.  By providing the scripts, you have made the solution much simpler to implement.</description>
		<content:encoded><![CDATA[<p>This is great.  By providing the scripts, you have made the solution much simpler to implement.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
