How to compare local file with shelf file - visual-studio

I have shelved my file, test.cpp and continued working on it. Now I would like to see what additional changes I've made to test.cpp since I made my shelf.
Let's say that after I checked out test.cpp, Bob checked into tfs an update to test.cpp.
Let's make some nomenclature to help:
source_version: the original version I checked out and started working from
latest_version: the test.cpp Bob checked into tfs, the latest version after I started working on test.cpp.
shelf_version: the test.cpp in my shelf, a modification of source_version, lacking Bob's addtions (i.e. not merged).
local_version: the test.cpp that I have on my local disk "local_version", that started from source_version, and has addtional work beyond shelf_version.
Using this set of labels my question reworded would be:
How do I compare local_version with shelf_version.
My options:
In Pending Changes pane, I can
Compare with Workspace Version
This is wrong, this compares local_version with source_version
Compare with Latest Version
This is wrong, this compares local_version with latest_version
In 'Shelveset Details' pane view of the my shelf
Compare with Unmodified Version
This is wrong, this appears to be the same as comparing shelf_version with source_version. Which is odd, this function is already handled in the next compare
Compare with Workspace Version
This is wrong, this compares shelf_version with source_version.
Compare with Latest Version
This is wrong, this compares shelf_version with latest_version.
Thanks

It is really irritating that MS hasn't fix this yet. A workaround that I am currently using is an external diff app and doing the following:
Open your external diff app.
Go to your VS environment and go to the Team Explorer pane and bring up your Shelveset Details.
Bring up the context menu on the file you want to compare (right click or menu key).
Select Open. This'll DL the file to your local system as a temporary file.
Bring up the context menu on the window tab right above the file contents which states the filename and select Copy Full Path.
Go back to your external diff app and paste that file path as the first one you wish to diff.
Go back to your VS environment and open your copy of the same file.
Bring up the context menu on the window tab right above the file contents which states the filename and select Copy Full Path.
Go back to your external diff app and paste that file path as the second one you wish to diff.
Now diff the two files.
I know this is a lot of steps to do something that should be a simple (maybe 1 or 2 click) operation.
If you want MS to get off their ass and implement this feature, you might want to vote for this feature here.

I repro all you steps and you correct that you can't compare the shelf_version with the local_version with the VS compare. I use Beyond compare and when the compare start it lists the left and right side. So I changed the left side to point to the local folder and I could see the outcome you are looking for.

Related

Searching for a Blame

I'm trying to find some changes I made to some code within a project. This is a team project having multiple contributors.
Is it possible to search for a particular blame within Xcode?
It would be easier for me to search via blame than to remember a particular file and line number.
Inside Xcode, open the left side menu and navigate to Source Control Navigator. You can also do this using the keyboard shortcut cmd2
In there, select the branch you're working on.
In the text box in the top right corner, start typing your version control username and press:
Author:{your-username}
This will show you all commits you have pushed to the repository. You can select a commit to see which files were changed and access the respective files directly from there.

What is the best way to know in which commit a particular line was added to TFS

Context
I am using VS 2015 and TFS as my version control. I do know how to get a history for a particular source file, and also know how to see in editor the picked version of that file.
Question
In the current version of a particular file I read a comment say
// This is a comment
I would like to find in which commit was that line committed. The obviuos solution is opening history, then the different versions of that file starting from initial commit, and searching for the text in the editor window until a looked text is found.
Is there any convenient solution for that?
Right-click inside the open file in Visual Studio, on the interesting line, and choose Source Control (bottommost menu) and then Annotate.
You'll see the file with changeset information along the left edge.
Note that this will only easily give you access to how the current file came to be, if you wish to dig through annotated historical versions it becomes a bit more cumbersome.

Identifying Visual Studio Branches

I'm working on a project where I need to have a few branches of the same source code open at the same time. Is there an easy way to tell at-a-glance what branch I'm looking at on visual studio. At the moment I'm inspecting the properties of a source file to view the path in order to identify the branch.
There must be a better way - how can I tell at a glance what branch I'm looking at?
Try the VsCommands extension. It shows the current branch in the solution badge in the taskbar, and the title bar. I am using mercurial and it seems to work well with that.
Use the free Branch Info TE Extension (BITE) for VS2013:
https://visualstudiogallery.msdn.microsoft.com/33a5274b-271b-45dd-8dc5-734d927a19dd?SRC=VSIDE
If it's exactly the same code - what's the point in it?
If it's not, maybe use different named projects inside the same solution?
BTW, you don't have to change default namespace with the project name, so it should be relatively easy to do.
Then there's another way - hover your mouse pointer over the file tab, you'll see the file path almost immediately. I do that every time I work on new version, but checking something from the old version.
If there are only 2 versions - you can use 2 monitors. I put the old (less used) version on "side" display, and current (most changed) on "front" one.

Is it possible to compare two revisions of a file inTFS?

I'm a bit new to TFS. One common operation which is very easy with every other source control I've used is comparing two different revisions. Say you have 3 revisions. Revision 3 is my current local copy. There was some regression introduced with revision 2(or whatever). So, I need to see what was changed from revision 1 to revision 2. I'm not concerned about what was changed in revision 3.
How do I do this in TFS?
If you use the source explorer to 'View history" on a file, you will see a list of the verions in TFS. Then you can select two versions. Then right-click to compare the two versions.
You can right click on the File and click "Compare...".
There you can set the same Server Path (e.g. "$/Project/Main/File.cs") and use the Changeset "Type:" and set a Changeset Id on the Source and Target.
Actually, one of the things I absolutely love about TFS is the flexibility to compare various versions of files (I'll admit, I love the flexibility but the actual compare tool? Not so much).
You'll have to forgive any mistakes, it has been a while since I've used TFS but I still remember the general idea.
In the solution explorer if you right click the file and click compare, you will be presented with compare dialog. From here you select the two files you want to compare. Make sure both of them point to the server version path.
Under the "Source Version:" in the Type: dropdown, select "Changeset" (or "Date" if you feel confident enough). You should see an elipses that allows you to search for the changeset. You will now be able to select your changeset from history (you may need to press a "Find" button or something, I can't remember by heart). Select Your revision 1 (whatever changeset id that is) and "ok" out of the changeset selection.
The "Target Version" frame will be disabled if the Target Path is pointing to a local file (likewise for the "Source Version" and "Source Path"). So make sure your paths are all pointing to the server versions.
Under "Target Version:" in the Type: dropdown, also select "Changeset". Now using the same steps as above, select the revision 2 changeset.
Finally click "Compare" and enjoy!
If you are using Team Explorer inside Visual Studio, you can go to the Source Control Explorer window and select a file, then view history. Choose 2 versions and right-click to compare.

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.

Resources