Wednesday, September 17, 2008

Get List of File Associated with multiple Changesets

I wrote a cmdlet for powershell by which you can get list of file associated with list of changesets.
param(
[string] $changesets = $(throw 'Usage: Get-Changeset-Files 'changesets')
)

process
{
# get TFS object
$tfs = get-tfs ;

# build up list of file items
$fileItems = @();

$changesets.Split(',') | foreach {
$tfs.vcs.GetChangeset($_).Changes | foreach {
if($fileItems -notcontains $_.Item.ServerItem) {
$fileItems += $_.Item.ServerItem;
}
}
}
return $fileItems | Sort-Object;
}


Steps:
1. Create a file Get-Changeset-Files.ps1 and copy above code in the file (preferably where get-tfs resides). Also add this directory into your $path
2. Open Powershell, go to Directory where above file recides
3. Run 'Set-ExecutionPolicy unrestricted' so that you can run above cmdlet
4. Everything is ready.. just run for example: Get-Changeset-Files('10, 20, 30')

See here for get-tfs.ps1

not-my get-tfs

#This is very popular file you may get at many places. Change $serverName's default value

param(
[string] $serverName = 'http://tfs-server:port/'
)

begin
{
# load the required dll
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Client")

$propertiesToAdd = (
('VCS', 'Microsoft.TeamFoundation.VersionControl.Client', 'Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer'),
('WIT', 'Microsoft.TeamFoundation.WorkItemTracking.Client', 'Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore'),
('CSS', 'Microsoft.TeamFoundation', 'Microsoft.TeamFoundation.Server.ICommonStructureService'),
('GSS', 'Microsoft.TeamFoundation', 'Microsoft.TeamFoundation.Server.IGroupSecurityService')
)
}

process
{
# fetch the TFS instance, but add some useful properties to make life easier
# Make sure to "promote" it to a psobject now to make later modification easier
[psobject] $tfs = [Microsoft.TeamFoundation.Client.TeamFoundationServerFactory]::GetServer($serverName)
foreach ($entry in $propertiesToAdd) {
$scriptBlock = '
[System.Reflection.Assembly]::LoadWithPartialName("{0}") > $null
$this.GetService([{1}])
' -f $entry[1],$entry[2]
$tfs | add-member scriptproperty $entry[0] $ExecutionContext.InvokeCommand.NewScriptBlock($scriptBlock)
}
return $tfs
}

Tuesday, September 16, 2008

Idiotic Software (TFS)

User Experience is where Microsoft TFS loses the ground. Here was a day when I struggled to merge around 30 changesets across branches. The user interface doesn't have any filter by which I can see only my changeset (out of 40 membered team's chagesets from the day we separated the branch). I cannot merge multiple changeset at once untill the are in sequence (no CTRL + select). It seems Team Foundation Server assumes the team is made of 1 person.

What NHibernate Lacks

There were situations when I had to make sure that I Get (or Load) fresh entity object from database. But with NHibernate, until I change configuration forever, there is no other way to do so except to use UnitOfWork.Refresh method.
This is expensive when I the object is not in cache at frist place. It makes 2 database hit.
What I need is something like this,

UnitOfWork.GetFresh(object pk)

OR

if(UnitOfWork.IsCached(object pk) && !UnitOfWork.IsDirty(object pk)
{
//Refresh
}
else
{
//Get
}

Tuesday, September 02, 2008

Vertical Text Selection

You may need to do sometime vertical selection. For example, in example below, I want to select and remove all “SolidX”.


I need to do vertical selection for this. Selecting text vertically not commonly used but an excellent functionality provided by all serious text editors.

This is how to do it (Windows specific): Hold ALT and SHIFT key and select the text vertically and horizontally. It is not important whether you select first vertically or horizontally but you MUST press and hold ALT key before SHIFT key.

You can do this on all modern Code editors, good text editors like Scintilla based SciTE, TextPad etc. Once you know about vertical text selection selection, you will find its use at more places than what you can think about when unaware.