Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Listing All Changesets and Releated Work Items Belongs to Specific Project Between Specified Dates

I am trying to write a small Relase Notes program with C#. I need to fetch all changesets and related work items belongs to specified project between specified dates.

I tried to use QueryHistory method but i couldn't find how could i give date filter.

like image 507
bahadir arslan Avatar asked Dec 08 '11 11:12

bahadir arslan


2 Answers

You can set

VersionSpec versionFrom = GetDateVSpec(date);
VersionSpec versionTo = GetDateVSpec(DateTime.Now);

Then with

IEnumerable results = versionServer.QueryHistory(sourceControlPath, VersionSpec.Latest, 0, RecursionType.Full, null, versionFrom, versionTo, int.MaxValue, true, true);
List<Changeset> changesets = results.Cast<Changeset>().ToList();

you get the changesets you 're after.

GetDateVSpec goes as follows:

private static VersionSpec GetDateVSpec(DateTime date)
{
   string dateSpec = string.Format("D{0:yyy}-{0:MM}-{0:dd}T{0:HH}:{0:mm}", date);
   return VersionSpec.ParseSingleSpec(dateSpec, "");
}

I use this in one of my own tools, originally I had found the core for this here (a great post by Robaticus)

like image 162
pantelif Avatar answered Nov 24 '22 06:11

pantelif


Just found out that there are several classes that inherit from VersionSpec and will do the work for you and are very easy to use. For example, there is a DateVersionSpec which accepts a DateTime. The full list of specific VersionSpec classes is:

WorkspaceVersionSpec LatestVersionSpec LabelVersionSpec DateVersionSpec ChangesetVersionSpec

Hope this helps.

like image 36
Milan Nankov Avatar answered Nov 24 '22 07:11

Milan Nankov