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
Related
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"
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)
Foll. is my understanding re. TFS rollback.
Assuming I have the foll. scenario:
Changeset
200
199
198
197
196
195
Couple of options to do rollback:
Solution Explorer -> Rt click -> Get specific version, checkout/checkin
Solution Explorer -> View History -> Rt click -> Rollback Entire Changeset
Solution Explorer -> View History -> Rt click-> Rollback selection of changesets
Source Explorer (Visual studio -> View -> Other windows -> Source explorer) -> Rt click file -> Rollback
Option 1 - Solution Explorer -> Get specific version, checkout/checkin: If I want to undo all the changes from changeset 200 to 197 and roll back to what the file was after changset 196 was checked-in, I can use this option - Get specific version (changeset 196) and then checkout and checkin the file.
Option 2 - Solution Explorer -> View History -> Rollback Entire Changeset: This option can be used if you want to rollback that specific changeset. Note that any other file associated with that changeset will also get rolledback. Example if you want to roll back changes made in changeset 197 while still keeping every other following (>197) changeset intact.
Option 3 - Solution Explorer -> View History -> Rollback selection of changesets: Same as option 2, but can be used to roll back multiple changesets. Example to undo changsets 200 to 197 and get the file to what it was when changeset 196 was checked-in
Option 4 - Source Explorer (Visual studio -> View -> Other windows -> Source explorer) -> Rt click file -> Rollback: This brings a dialog box to do either of the foll.:
The first radiobox from below is same as option 2 from above
Second radiobox is same as option 3 from above
Third radiobox is very important and only available from this dialog box which allows us to roll back to specific changeset.
Question: In option 4, do other files from the same changeset get impacted as a result of rollback? Or is this rollback specific to this file only unlike the option 2, 3 counterparts?
Useful Link for Rollback examples
When you right click on a file and Rollback... you got the pop-up, in the top you have the field Items to Rollback, by default the value there will be the server path to the file.
So when you do rollback from there the rollback will be only to this file and not impact other files.
When you click on a file View History and Rollback Entire Changeset all the files of the changset will be rollbacked.
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
-------------------------------------------------------------------------------
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.)