Highlight changes in code since last commit in Android Studio - android-studio

Is there any way I can show changes that I made since the last commit in the code editor?

Use the Version Control tab. Under Log, you can select the first two changes, and use CTRL + D or Command + D to produce a diff between the two.
Note that this approach works best with code under source control that's registered with Android Studio. If you're not using any source control, you can still get a partial history of changes by navigating to VCS > Local History > Show Local History and selecting the root directory in your project. Note that this is subject to the Local History log length, which is nominally limited to 1,000 entries.

If you are using subversion Git then :
VCS->Git->Compare with the Same Repository Version

On the left side of IDE open "Project" bar and select "Changed Files"

In the menu:
VCS -> Subversion -> Compare with lastest repository version

Related

How to use WinMerge instead of TortoiseMerge when comparing a revision with the working copy

I like using WinMerge instead of TortoiseMerge with TortoiseSVN for comparing changes between separate revisions of a file. I can configure this for most things in the TortoiseSVN settings (context menu > "TortoiseSVN" > "Settings" > "Diff Viewer"):
However, when I want to compare files in a particular revision against the those in the working copy, it uses TortoiseMerge. To see what I mean, go to the TortoiseSVN log viewer from the working copy: right-click in the working copy folder, select "TortoiseSVN" > "Show log", right-click on a prior revision, and select "Compare with working copy". Then, double-click the file of interest in the list of "file patches" that appears.
Is there any way to get it to use WinMerge instead of TortoiseMerge for these cases?
Sorry, no. Because WinMerge is not able to apply patch files.
When you do a "Compare with working copy", TortoiseSVN creates a unified diff (also known as a patch) between the selected revision and the working copy. Then it starts TortoiseMerge, telling it to apply that patch to the working copy. That's why in this case TortoiseMerge is started, not WinMerge: it's not really a diff that is done but a merge.

How to show gutter for git diff?

In IntelliJ there is a gutter to the left of the text editing area that can show git diffs. I would like to have the same thing in android studio. Is there a way to make this appear?
I've run into this issue a couple times using Android Studio there are two reasons I've seen Git diffs not show in the gutter.
The Git VCS path for the project isn't set. You can typically set this in your project by going to:
System Preferences > VCS
Then hitting the + button and adding your Git root directory.
The project xml is borked. Sometimes a corruption exists some where in the code directory. Unfortunately, after hours of searching through XML in the .idea directory and other files and directories I was never able to find the culprit. However, simply deleting the project, pulling it down from source control and re-importing it into Android Studio re-enabled the git diffing in the sidebar.
If you already have the git-repository associated with project. And you just need to enable VCS, to be able to perform operations (pull, push, etc.). You need to select : VCS >> enable VCS. Then after, it is automatically able to understand the source-control associated with the project. You can validate, by selecting : VCS >> Git >> Branches.
NOTE : I had been using git for version-controling, hence it shows "Git" option in the VCS menu list. This may differ based on your tool.

Shortcut to Compare to Latest Version in Solution Explorer - Visual Studio 2012

In Visual Studio 2012, in the Solution Explorer (not Pending Changes), is there any way to create a keyboard shortcut, right click context menu item, or menu bar button that does a TFS Compare to Latest Version?
Alternatively, on the general Compare dialog, is there any way to change the default selection of Type: Workspace Version to Type: Latest Version?
Basically I am looking for the easiest way to get to Compare to Latest using the fewest clicks, from the Solution Explorer.
Does setting a Tools/Options/Keyboard shortcut for TfsCompare help?
For me, this worked:
VS > Tools > Options > Environment > Keyboard > Show Commands Containing: Team.Git.CompareWithUnmodified
By assigning a shortcut key Ctrl+\, Ctrl+\ to this command ( Team.Git.CompareWithUnmodified) I can now compare my current file (the file that is open in the editor) to the previous version of the file by pressing the shortcut key Ctrl+\, Ctrl+\; no need to find the file in solution explorer, then right-click the file then select Compare.
(you can choose your own shortcut key of course)
Just a note on different behaviour:
Team.Git.CompareWithUnmodified works for me because I am using TeamExplorer in VisualStudio but I use GIT as the underlying source code repository.
Tfs.FileCompare could also work in other scenarios (i.e. if you don't use Git, but use VSTS or TFS as your source control provider).

Subclipse (1.8.5) requires cleanup / refresh cycle to detect changes made with TortoiseSVN (1.7.4)

My problem:
Subclipse does not update locked status overlay icons in eclipse after I lock/unlock some files with TortoiseSVN in windows explorer (and vice versa).
Is this expected behaviour or am I missing a setting?
The files have the svn property "svn:needs-lock" set.
I can sync Subclipse again by first clicking "Team - Refresh/Cleanup" and then "Refresh F5".
I am not a 100% sure but I think with Subclipse 1.6.x and TortoiseSVN 1.6.x I was able to just hit F5 in eclipse, and the status was refreshed correctly.
Thank you for your time.
I do not think you should have to do the second F5, but we added the Team > Refresh/Cleanup option for this reason.
With pre-SVN 1.7.x releases any change in the working copy caused files in all of the hidden .svn folders to be modified. When you hit F5 in Eclipse, it would see these changed files and fire off notifications that Subclipse would see and use that to refresh decorations.
With SVN 1.7, all this information is consolidated in a single location, and it sounds like it probably does not even live inside your Eclipse project folder. So F5 in Eclipse effectively does nothing because no files on the filesystem that Eclipse can see has been modified. Eclipse does not send out any notifications.
The Team > Refresh/Cleanup option calls the same Eclipse action as F5, but it also triggers an explicit refresh of SVN cached information regardless of whether Eclipse sees any changes.
Just to explain in more detail how to create the keyboard shortcut:
I was once pretty desperate to get this keyboard binding to work and after a lot of head banging found out that I also had to enable the "SVN Command Group" in my eclipse perspective (as explained here: SVN key bindings not working in Eclipse):
You can bind the F5 key to the "Cleanup/refresh" option of the SVN menu.
First,you must go to Window dropdown menu > Customize Perspective > Command Groups Availability and there check the SVN box.
With this option you will get a dropdown menu called SVN with all the relevant commands.
Then you go to Settings > General > Keys :
unbind the F5 key if you want to use this key
bind the command %CleanupAction.label to F5 or any key you may find useful (like Shift+F5 if you don't want the F5 key to be unbind.)

How do I create a patch from diff between revisions using TortoiseSVN?

I'm working on a project where Subversion is used to maintain version control. I use TortoiseSVN to access the project repository.
Some changes were made between two revisions on a project (let's call them rev1 and rev2), and I want to be able to apply these changes to a working copy somewhere that temporarily does not have access to the repository.
I right-clicked on a project folder, clicked 'SVN show log', selected the two revisions and selected 'Show changes as unified diff'.
This causes a window to be shown, displaying output that very much looks like a patch file that I could save. Unfortunately, I find that there is no option in the window that lets me save this as a patch file.
How can I create the patch file?
The next version of TortoiseSVN (1.7.x) will have that save option. In the meantime, you can configure a plain text editor as your unified diff viewer:
Settings dialog->External Programs->Unified Diff Viewer
There you could, for example, specify notepad.exe as your diff viewer.
One way to achieve you goal is to right click on the revision in the TortoiseSVN log and choose "Merge revision to...". Then you select you local working project and click OK.

Resources