TFS 2010: Seeing and comparing changes after getting latest - visual-studio-2010

When I get latest from TFS source control, I don't see the changes made to my workspace.
I know I can go to the Output window and see the changes, but this is just a text list with no context actions.
What I really want is to see a list of changes, with the ability to right-click a file and see differences straight away.
Is there a better, alternative way to see changes like this after getting latest?

Sounds like using the command line tool tf.exe with folderdiff command would achieve what you need.
Use the folderdiff command to display
and compare 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.

From the header toolbar click the "Find Chengsets" option (it is between History and Branch options), it will open a dialog box, on that fill your required attributes and click Find button on that dialog box.

Related

How to gray out items in Source Control Explorer?

I accidentally hit "Get Latest Version" on item in TFS with which I'm not currently working on. This made name of the item visible in black in Source Control Explorer, which is misleading to me since I'm used to identify objects which I'm working on visually. How can I reverse this operation?
To make the item in Source Control Explorer gray out again. You could try below workaround, get specific changeset 1.
Open team explorer
Click Source Control
Right click on you file/folder
Select Advanced Click on Get specific Version
Choose Changeset Type and enter 1
The item in Source Control Explorer will gray out again. This is due to:
Changeset 1 is a special changeset on your Team Foundation Server
instance. It was created as part of the setup routine and only
contains one thing - the root node ($/) in your source control tree.
If you do a get for Changeset 1 on any actual files then they will not
exist at that point in time on the system so will be deleted locally
and the server will know this.
Note: This will change the status of your files to "Not downloaded" and will remove the local copy of the file. It will only remove files that were put there by TFS.
Assuming you are using TFVC, you can also try cloaking the folders that you don't need. This will "remove" the any unchanged files locally and exclude the folders when you get latest in future.
In the Source Control Explorer, right click on the folders that you want to exclude and go to "advanced" then select "cloak".
To start using the files locally, you can go to the same place and select "uncloak".

Is there a way to have a global diff before doing a checkin in TFS

With Visual Studio and TFS, is there a way to have a diff showing in a single page changes for each file before doing a checkin ? Instead of having to do diff of each file one after the other.
Similar to the UI of GitHub for Windows when doing a commit:
file1
diff
file2
diff
...
Thanks,
Edit: as mentioned by Jehan33 the view I'm looking for looks like this (it's available on the web portal AFTER a commit):
This view is available after the check-in for the change sets where it will display all the file differences for a changeset in single page in web portal. Its not possible to do the same before the check-in.
Assuming your are using Team Foundation Version Control. If you right click on the folder where you have pending changes and click Compare. Select the options
"Show Items that exists only in source path", "Show Items that exists only in target path" and "Show items that are different", you will get the desired view.
The closest thing I've found was Diff All Files.
You can choose to combine all changed files into one and compare. Sadly there is no 'lines of context', however the code is open source and you can choose an external diff tool which may achieve this.

How can I see the change log of a directory with TFS?

I'm interested in seeing the latest changes that landed to a solution with TFS (I'm using Visual Studio). However, I can't seem to find the option: using View History on a solution or project brings up the history of the file itself. Am I missing something?
If you right click on folder the containing a solution in the Source Control Explorer window you'll see all changesets. It's obvious but I had to ask for it too. I am using TFS2010/VS2010.
Edit
Here are the steps:
Team/Connect to Team Foundation Server / select Team Project/ in Team Explorer dblclick on Source Control and in Source Control Explore right click folder containing your solution select View History and here you are.
The View History command will list you all the changesets where the file/directory was changed (add/move/content changed, deleted, etc.).
So if you do a View History on a .sln or .csproj file you'll see only the changes that were made inside the file's content, not on the "Visual Studio Item" and its related item.
To sum up, the View History command is only a File System history, there's not a smarter logic out there.
EDIT
The only way to know what changed inside a solution or project is to do a View History on the common denominator (i.e. the directory that contains everything you want to view history). But it'll still be a File System kind of History.
There's not Logical History for Solution and Projects in Visual Studio. For instance you can't know what files where added to a given project your viewing the history from two given versions. Or what projects were added/removed in the solution.
All the pieces are there (because all the changes are stored in the .csproj or .sln), but the feature itself that parses the content and retrieve the logic you want to see doesn't exist. (by the way, it's a great feature and I agree it should be there).
Bottom line: TFS/Visual Studio gives you two history system:
Based on the source control/file system, by displaying changesets.
Based on the source control/file system, by displaying labels.
That's all...
Right click on folder in solution explorer, and choose View History. Then you can see all the Changesets listed that apply to that directory. Then right click a particular changeset and choose Changeset details... to see what changes occurred in that changeset.

How do I get Visual Studio Team Foundation Server to see I moved code to a different folder?

I moved some code from my c drive to my d drive. When I opened the solution, it told me that:
The solution appears to be under source control, but its binding
information cannot be found. Because it is not possible to recover
this missing information automatically, the projects whose bindings
are missing will be treated as not under source control.
So I tried permanently removing the bindings and downloaded the latest version. Now my changes don't register as pending changes.
I've tried selecting the solution in the Solution Explorer and File => Source Control => Change Source control, but it does not let me bind. Server Name and Server Binding columns have "".
Generally speaking, the location of code on your machine is dependent upon where your workspace is located.
If you move your workspace to the D: drive, then there shouldn't be an issue.
However, if you simply used Explorer to copy the files to the new location, then VS isn't going to be able to maintain the bindings.
From the Workspace Editor you can map the entire tree, solutions or even individual projects to a new location.
First off, put it back and undo the changes.
Then, Go to File | Source Control | Workspaces.
Click on the work space name and then the "Edit..." button.
In the working folders area select the source control folder you want to move and give it a new local folder location.
You will need to edit your Workspaces for TFS Server to know the change that has happened at your local machine. To edit your workspace, in Visual Studio:
ensure you have no pending changes; also copy your source code folder to some location temporarily, just to be safe (you can remove after you are all set)
go to Source Control Explorer
locate the "Workspace:" dropdown
select the item "Workspaces" from the dropdown list (you will get a dialog titled "Manage Workspaces"
if you have multiple Workspaces, select the appropriate one from the list in the dialog
click on "Edit" button (you will get an "Edit Workspace..." dialog)
down below in the dialog, you will see "Working folders" grid
click on appropriate row from the grid and modify the "Local folder" path to set to your new folder location
Sometimes TFS and Visual Studio have issues in getting these workspace changes synchronized. I would always close Visual Studio and re-launch it to get my changes synchronized anytime after I make Workspace related changes.
Hope this helps.
the most crude way here (I don't know if there is any other way)
is to put the folder back to its old location , Check in your changes
then remap the project to the new folder
When you move files/folders to make the moves pending changes you need to use a TFS client to do the moves.
For one or two files the Team Explorer UI is OK, for more the command line is easiest.
See tf.exe rename on MSDN (tf move is an alias for rename). There is also step by step help on using the GUI: Move, Rename, and Delete Version-Controlled Files and Folders.

How easy is it to roll back a file that has been checked-in in TFS?

I've (apparently) checked-in (added) a file that shouldn't have been added to a branch. I need to revert this, but since then, 20 or so changesets have been added to the repository.
I'm used to working with Subversion, where it's only a few clicks and it's out. How easy is it in TFS?
TFS is a pain to use in general (personal and biased opinion). Here's a how-to article from Microsoft on how to proceed to revert changes back (warning: more than a few clicks away).
As given in that article, the steps to revert to a prior version of (a) file(s) are:
In Source Control Explorer, right-click the file whose changeset you want to roll back, and then click Get specific version on the
context menu.
In the Get dialog box, select the prior version of the file, and then click Get. For more information, see How to: Retrieve
Old Versions of Files from
Changesets.
After this file is in your workspace, right-click the file, and then click Check Out for Edit on the context menu.
Right-click the file again, and then click Check In Pending Changes.
In the Check In - Source Files dialog box, select the file, and then click Check in.
The Resolve Conflicts dialog box appears.
Click Resolve to open the Resolve version conflict dialog box.
Select Discard server changes.
Click OK.
NOTE: To review your decision before discarding the server changes, you can click Compare to view the server and local copies
simultaneously.
In the Resolve Conflicts dialog box, click Close.
In Source Control Explorer, right-click the file, and then click Check In Pending Changes.
In the Check In - Source Files dialog box, click Check in.
As #Darin has posted, you can simply Get the state of the previous version/changeset onto your PC and then check it in as a new version, thus undoing the effect of the check in. This is dead easy and can be done from the GUI, but does involve a fair bit of faffing around.
If you're happy to use the command line, you can also command TFS to rollback the changeset for you. This does all the "work" of the above option, leaving you with a changeset in your pending changes that will undo the checkin's effect, but hopefully with a bit less effort.
If it is added by mistake, you don't want to roll back. Instead, you want to tf destroy (from the command line) that file in each of the branches.
TFS can be a bear to work with if you add a file, delete it, then re-add a new file with the same name. It makes merging much more difficult.

Resources