TFS Detailed history in csv format - tfs

When i generate a tfs detailed history output, i get it in the below format. is there a possiblity to convert this to csv format? anyone who has an idea of writing a conversion script please help on how it can done.
-------------------------------------------------------------------------------
Changeset: 241
User: 52476
Date: Saturday, May 31, 2014 3:54:49 AM
Comment:
Merged the changes from Integration branch to Main branch
Items:
merge, edit $/Ace/Main/sWFA/cWFA/Form1.cs
merge, edit $/Ace/Main/sWFA/cWFA/Program.cs
merge, edit $/Ace/Main/sWFA/cWFA/Rama.txt
merge, edit $/Ace/Main/sWFA/cWFA/Properties/AssemblyInfo.cs
merge, edit $/Ace/Main/sWFA/cWFA/Properties/Settings.Designer.cs
merge, edit $/Ace/Main/sWFA/cWFA/Test/Ramatest.txt
Check-in Notes:
Code Reviewer:
Prasad
Manager_approval:
Done
Performance Reviewer:
Mano
Security Reviewer:
Akhil
-------------------------------------------------------------------------------

Related

How to find who last changed am file with perforce?

I have an idea but I'm not sure how it can be implemented. I use Jira/Perforce/Swarm, and I want to automatically include the name of the engineer who last changed a file. The name of the engineer should be included to the generated bugs/crashes in Jira.
Here is an example: Tod changed file TestFile.cpp. Tod's work has been merged into master branch. Assertion occurred and a bug in Jira was created with reference to the file.
How can we let the system know that Tod was the engineer who changed this file last?
Thank you in advance.
You can get this information from the p4 changes and/or p4 filelog commands:
C:\Perforce\test>p4 filelog TestFile.cpp
//stream/child_stream/TestFile.cpp
... #2 change 290 edit on 2022/03/29 by Tod#Samwise-dvcs-1509687817 (text) 'Tod's awesome change'
... #1 change 289 add on 2022/03/29 by Samwise#Samwise-dvcs-1509687817 (text) 'added file'
C:\Perforce\test>p4 changes -m1 TestFile.cpp
Change 290 on 2022/03/29 by Tod#Samwise-dvcs-1509687817 'Tod's awesome change'
If your automation is able to identify specific lines of code that introduced bugs, you might also find p4 annotate useful for tracing those lines of code to specific Perforce revisions/users:
C:\Perforce\test>p4 annotate -Tu TestFile.cpp
//stream/child_stream/TestFile.cpp#2 - edit change 290 (text)
1: Samwise 2022/03/29 asdfasdf
2: Tod 2022/03/29 "tod"

TFS Rollback Renamed File Without Manual Intervention to Rename It (TFVC)

In TFS 2012 (TFVC), how might I rollback a renamed file to the original filename and contents--without having to manually rename the file (?)
Trying to see if possible just using TFS rollback functionality (e.g., tf rollback), not a combination of tf commands or scripted solution.
SITUATION
Four steps: 1) Add a file; 2) Check it in; 3) Rename the file and edit the contents; and 4) Check it in:
Changeset: 2
Items:
rename, edit $/b.txt
Changeset: 2
Items:
delete, source rename $/a.txt
Changeset: 1
Items:
add $/a.txt
I want to rollback to Changeset 1 (a.txt).
WHAT I'VE TRIED
Source Control Explorer Rollback:
In Microsoft Visual Studio 2017 Professional's Source Control Explorer: right-click b.txt > Rollback... > Rollback to a specific version. Specify Changeset 1, then select button Rollback.
This produces the following pending change:
Items:
delete, rollback $/b.txt
Additionally, a warning appears in Output window:
TF203066: The rename from $/a.txt to $/b.txt could not be rolled back
because you did not provide the source name. To roll back the rename,
undo any pending changes to $/b.txt, and then repeat the operation,
but this time include both the source name ($/a.txt) the target name
($/b.txt).
Note: "Rollback to a specific version" doesn't seem to have fields for source and target names.
This seems to indicate rollback doesn't support this scenario (?)
tf.exe Rollback:
Command tf rollback also doesn't seem to have parameters for source and target names:
tf rollback /toversion:VersionSpec ItemSpec [/recursive]
[/lock:none|checkin|checkout] [/version:versionspec]
[/keepmergehistory] [/login:username,[password]] [/noprompt]
When I run the following command, I get the same results as in Visual Studio:
C:\test>tf vc rollback /toversion:C1 "$/b.txt"
delete, rollback:
$/b.txt;C2~C2 -> $/b.txt;C2
as well as the same warning as before:
TF203066: The rename from $/a.txt to
$/b.txt could not be rolled back because you did not provide the
source name. To roll back the rename, undo any pending changes to
$/b.txt, and then repeat the operation, but this time include both the
source name ($/a.txt) the target name ($/b.txt). C:\test>
Note: tf rename has parameters olditem and newitem, which seems to imply warning TF203066 comes from an incomplete call to tf rename.
This seems to imply manual intervention will always be required to rename the file (?)
SOFTWARE VERSIONS
Microsoft Team Foundation Server 2012 CU4 v11.0.61030.0 (TFVC)
Microsoft Visual Studio 2017 Professional 15.9.13
LINKS
Rollback Command (Team Foundation Version Control)
Rename Command (Team Foundation Version Control)

Tf Command Line utility - Determine previous file path after a rename

Is there any way to do this? I know that I can do tf changeset xxx and it will tell me which files were "delete, source rename" for the old file paths but if there are multiple renames, there is no way to be sure which file goes with which.
Also if the change is local and has not yet been committed, I do not see a way to make this work.
For local changes:
C:\Users\JesseHouwing\Source\Workspaces\vsts-tfvc-tasks-test>tf rename "changes.122204,old" "changes.122204.new"
changes.122204.new
C:\Users\JesseHouwing\Source\Workspaces\vsts-tfvc-tasks-test>tf status /format:detailed
$/vsts-tfvc-tasks-test/changes.122204.new;C29
User : Jesse Houwing
Date : Friday, 15 September 2017 11:10:29
Lock : none
Change : rename
Workspace : SNAPPIE
Source item: $/vsts-tfvc-tasks-test/changes.122204,old
Local item : [SNAPPIE] C:\Users\JesseHouwing\Source\Workspaces\vsts-tfvc-tasks-test\changes.122204.new
File type : Windows-1252
1 change(s)
For remote changes, when you know the changeset number, use the changeset option to see:
C:\Users\JesseHouwing\Source\Workspaces\vsts-tfvc-tasks-test>tf changeset 29 /noprompt
Changeset: 29
User: Jesse Houwing
Date: Thursday, 14 September 2017 20:02:54
Comment:
Items:
delete, source rename $/vsts-tfvc-tasks-test/changes.122204;X2
rename $/vsts-tfvc-tasks-test/changes.122204,old
use /itemmode and history to track a specific file, here you can see the previous name of that specific file:
C:\Users\JesseHouwing\Source\Workspaces\vsts-tfvc-tasks-test>tf vc history "changes.122204,old" /noprompt /format:detailed /itemmode
-----------------------------------------------------------------------------------------------------------------------
Changeset: 29
User: Jesse Houwing
Date: Thursday, 14 September 2017 20:02:54
Comment:
Items:
rename $/vsts-tfvc-tasks-test/changes.122204,old
-----------------------------------------------------------------------------------------------------------------------
Changeset: 11
User: Jesse Houwing
Checked in by: Project Collection Build Service (jessehouwing-dev)
Date: Saturday, 2 April 2016 20:46:32
Comment:
***NO_CI***
Items:
add $/vsts-tfvc-tasks-test/changes.122204
If the rename wasn't done through Visual Studio or through the tf rename command it may show up as a delete and an add and the relationship between those changes would have been lost. Visual Studio provides a UI to fix those kinds of changes before check-in, but once checked in, that information won't come back

Microsoft Team Foundation Server Express 2012 - How to clean up in tbl_TestResult (old test results)

I have installed a Microsoft Team Foundation Server Express 2012.
The table tbl_TestResult is using up 7000 MB of my Database space.
I tried to find information on how to clean up this Table but found no way to do so.
When I want to check in new files into TFS I get the Error TF30042: The database is full...
Over the Visul Studio I deleted all visible Tests but still the size of tbl_TestResult just decreased very little.
Can anyone explain to me how I can cleanup all test results in a proper way?
I am using the TFS client API to delete old test runs. Here's some sample code:
TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(new Uri("http://tfs2012:8080/tfs/DefaultCollection/"));
TestManagementService testManagementService = tpc.GetService<TestManagementService>();
ITestManagementTeamProject teamProject = testManagementService.GetTeamProject("MyProject");
int totalRuns = teamProject.TestRuns.Count("SELECT * FROM TestRun");
// Limit by date, so the query doesn't take too long.
string query = "SELECT * FROM TestRun WHERE CreationDate < '2013/07/01'";
int numTotalToDelete = teamProject.TestRuns.Count(query);
if (numTotalToDelete == 0) { return; }
// Only delete 500 at a time, to give SQL Server time to breathe (don't ask).
var runsToDelete = teamProject.TestRuns.Query(query, false)
.Take(500);
teamProject.TestRuns.Delete(runsToDelete);
Query syntax comes from here: http://blogs.msdn.com/b/duat_le/archive/2010/02/25/wiql-for-test.aspx
We had the same issue for our on prem TFS. This is how we did it for TFS 2015 up to TFS 2017.
Install Microsoft Visual Studio Team Foundation Server 2015 Power Tools to get access to Test Attachment Cleaner(TAC), tcmpt.exe.
It installs to c:\Program Files (x86)\Microsoft Team Foundation Server 2015 Power Tools
Sample settings for TAC is located in the installation folder, at <INSTALL_DIR>\TestAttachmentCleaner_samples_settingsfile
Create your own settings file, for example, all-100mb.xml file:
<DeletionCriteria>
<TestRun>
<Created Before="2016-01-01" />
</TestRun>
<Attachment>
<Extensions>
<Include value="wmv" />
<Include value="xesc" />
<Include value="trmx" />
</Extensions>
<!-- size in MB -->
<SizeInMB GreaterThan="100" />
</Attachment>
<LinkedBugs>
<Exclude state="Active" />
</LinkedBugs>
</DeletionCriteria>
The above config file removes test attachments of inactive test runs which are larger than 100MB with extensions: wmv, xesc, trmx.
Perform a test attempt to find out the outcome with this command: tcmpt.exe AttachmentCleanup /settingsfile:"all-100mb.xml" /mode:preview /collection:"https://tfs.contoso.com/DefaultCollection" /teamproject:"TeamProjectName" /outputfile:all-100mb.log"
This produces a very detailed log file that includes key information you needed, like:
------------ Summary ------------
Number of attachments affected: 339
Total size of attachments: 39646,7 MB
Elapsed time was 247,94 seconds
When you are satisfied with the result, do this:
Turn off transaction logs for your TFS database, if you use MSSQL server.
If you don't, you may grow your transaction logs faster than you can remove the test attachments.
Run tcmpt.exe command above without the /mode:preview parameter to delete test attachments.
When done, run these 2 stored procedures from the TFS database:
EXEC dbo.prc_DeleteUnusedContent 1
EXEC dbo.prc_DeleteUnusedFiles 1, 0, 1000
The stored procedures removes emptied rows from the database.
If the stored procedures last less than 1 second each, wait some time and re-run them again.
Then you can choose to shrink your database.
Good luck with it.
if you delete unwanted builds then you will be presented with the option to delete test results associated with the build when you delete it.
You may find that the test attachments are consuming a lot of space as well, you can use the test attachment cleaner provided with TFS power tools to remove these.
TFPT can be found here

TFS: How can I select one of my previous commit comments?

Often I'd like to use a previous commit comment (and edit e.g. just one word) for check-in.
I'm used to eclipse, where this feature works quite well.
Is it also available for TFS? I didn't find it yet (despite quick Web search), am I blind?
(I'm currently using TFS 2010 with VisualStudio 2010)
Best regards, Mayoares
I don't think there is anything in VS to help here (except cut and paste via change history).
However a little PowerShell with PSCX (PowerShell community Extensions) and the TFS PowerToys PowerShell snapin will do this, with the current folder set to the solution root:
(Get-TfsItemHistory . -recurse -stop 1).Comment | Set-Clipboard
will put the comment in the clipboard. Using the NuGet powershell session in TFS, this could likely be automated completely (left as exercise).
Not to take away from #Richard for providing the crux to the solution--I have already upvoted his answer--but there is just a bit more to say here.
The OP was just slightly ambiguous: the title leaned toward the capability of selecting some recent commit message while the body was more suggesting to retrieve the most recent commit message. Richard addressed the latter perfectly, but I think it is worth commenting on the former as well.
Consider this function, which uses the same Get-TfsItemHistory from TFS 2013 Power Tools that Richard mentioned:
function Get-TfsComment([string]$pattern = ".*", [string]$Path = ".")
{
Get-TfsItemHistory $Path -Recurse | ? { $_.Comment -match $pattern }
}
With that in place try:
# Get all comments
Get-TfsComment
# Get 10 latest comments
Get-TfsComment | Select -First 10
# Get all comments containing "bug" and "fix"
Get-TfsComment "bug.*fix"
# Get all comments in your tests folder containing "support"
Get-TfsComment -path .\tests -pattern support
The output of this function produces a collection of Microsoft.TeamFoundation.VersionControl.Client.Changeset objects; the list of default properties it displays are typically all you need:
Changes Owner CreationDa Comment
etId te
------- ----- ---------- -------
1187 MYDOMAIN\fred 3/13/2014 Bug fixes for xyz...
1118 MYDOMAIN\wilma 3/7/2014 New features 139 and 448
1076 MYDOMAIN\barney 2/28/2014 Who remembers this...?
. . .
(Note that if you pipe the output to FormatTable -AutoSize that will take care of the poorly optimized line-wrap in the column headers.)

Resources