2009-07-23 26 views
1

最近、TFSのバージョン管理に追加された多くのレガシープロジェクトがあります。今私たちが持っている問題は、それぞれのプロジェクトに共通のコードのコピーが含まれていることです。このコードは、互いに別々に変更され維持されています。TFSプロジェクトのソースコードを比較する方法

TFSのあるソリューションのソースと、同じTFSサーバーの別のソリューションのソースを比較する方法はありますか? - 比較するフォルダとファイルを指定できます。

解決策のサイズと性質により、リポジトリの再構築やsolutiosnの主要なリファクタリングの実行は選択できません。

私はこのプロセスを自動化する可能性のあるAPIも興味があります。

ありがとうございます!

答えて

3

c:\ temp> tf folderdiff /?

TF - Team Foundation Version Control Tool 
Copyright (c) Microsoft Corporation. All rights reserved. 

Displays a visual representation of the differences between files in two server 
folders, in a server folder and a local folder, or in two local folders. 

tf folderdiff [sourcePath] targetPath [/recursive] [/noprompt] 
       [/server:serverName:port] [/filter:filter] 
       [/filterLocalPathsOnly] 
       [/view:same,different,sourceOnly,targetOnly] 

C:\ TEMP> TF folderdiff 1 2/

=========================================================================== 
Items That Exist Only in C:\temp\1 
=========================================================================== 

C:\temp\1\baz 

=========================================================================== 
Items That Exist Only in C:\temp\2 
=========================================================================== 

C:\temp\2\bar 

=========================================================================== 
Show Items That Have Different Contents 
=========================================================================== 

C:\temp\1\quux - 
    C:\temp\2\quux 

=========================================================================== 
Summary: 1 folders, 4 files, 1 source, 1 target, 1 different, 0 with errors 
=========================================================================== 

NOPROMPT編集:それは明らかではなかった場合、デフォルトのビューが異なるsourceOnly + targetOnly +です。両方のフォルダに同じ内容の "foo"という名前のファイルがありました。

私は、コマンドラインツール自体がAPIではないことを認識していますが、残念ながらここでは最適なオプションです。それ以外の場合は、自分でツリーをクロールする必要があります。バージョンコントロールAPIにはフォルダの差分はありません。あなたが得るのは、個々のアイテムを操作する15以上の混乱する方法です。

プラスの面では、比較したいすべてのファイルをチェックインする場合、コストのかかるディスクI/Oなしで計算を実行できます。 (TFSはすべてのファイルの内容のハッシュを格納します)。クイックPowerShellは、例:サーバー差分対ローカルサポートする必要がある場合

function Compare-TfsDir([string] $dir1, [string] $dir2, [switch] $includeEqual) 
{ 
    $dir1 = $dir1.ToLower() 
    $dir2 = $dir2.ToLower()  
    filter Decorate($dir) 
    { 
     $_ | add-member noteproperty RelativePath $_.ServerItem.ToLower().Replace($dir, "") -passthru | 
      add-member noteproperty HashString ($_.HashValue | %{ "{0:X2}" -f $_ } | join-string) -passthru 
    } 

    $items1 = $tfs.vcs.GetItems($dir1, $tfs.VCS_RecursionType::Full).Items | Decorate $dir1 
    $items2 = $tfs.vcs.GetItems($dir2, $tfs.VCS_RecursionType::Full).Items | Decorate $dir2 

    $dirComp = compare -IncludeEqual -Property RelativePath $items1 $items2  
    "---Tree Comparison---" 
    $dirComp | ? { $_.SideIndicator -ne "==" } | ft -auto RelativePath, SideIndicator 

    $both = $dirComp | ? { $_.SideIndicator -eq "==" } | % { $_.RelativePath } | Linq-ToSet  
    filter InBoth { if ($both.Contains($_.RelativePath)) {$_} } 
    $contentComp = compare -inc:$includeEqual -Property HashString, RelativePath ` 
          ($items1 | InBoth) ($items2 | InBoth) 

    "---Content Comparison---" 
    $contentComp | ? { $_.SideIndicator -ne "<=" } | ft -auto RelativePath, SideIndicator 
}  

残念ながら、このような何かを行うと、コードの行数として5Xを取るだろう。

+0

コードが機能しません。例:linq-ToSetはコマンドレットではありません。 – pabrams

関連する問題