Sublime Forum

ST3: EasyDiff

#1

Thought I would post this if anyone was interested. This is not on Package Control; I am only feeling out interest (if any). Though the core code is pretty stable, some of the new version control features can be considered beta.

There are a number of diff plugins available, so if there is no interest here, that is fine. I have been using the plugin for personal use for a while (though it is still evolving), and recently, after adding some new features, I thought I would offer it in its own repo to see if anyone other than myself would like to use this.

I have used a number of diff plugins (some very good), but all lacked what I wanted for the way I work…so, I wrote my own. This is not meant to allow merging, nor will it moving forward; just diffing. So let’s get to the plugin:

EasyDiff is a plugin driven from the context menu (I found this more intuitive for the way I work). I wanted to quickly diff selections, multi-selection, clipboard comments, and files. Then overtime, I wanted to quickly diff files in my SVN repos and Git repos without having to go back to explorer or finder etc. I found the command palette too cumbersome, so I wanted to use the context menu. But when I selected something for the left side compare, I wanted to visually be able to see what was on the left side in case I got distracted and forgot. So EasyDiff solves this by creating a dynamic context menu in your user folder. When you pick a file for left side compare, the file name shows up in the context menu. Same with selections and clipboard.

Version control was a recent addition. I wanted to be able to see my current changes to be committed, or look at the diff of the last revision. And I wanted to be able to do this on the Git and SVN since I use them both. So EasyDiff has a wrapper around the git binary, and the svn binary (by default it assumes git and svn are in the PATH; you can point EasyDiff at the binary if you need to). I am sure someone will probably discover some small detail I have overlooked, but so far, they seem to work fine. If you don’t use Git or SVN or either, you can selectively disable the menu items in the settings file. I will probably add Mercurial down the line; I just don’t use it much.

  • Allows comparing views, selections, multi-selections, and clipboard combinations.

  • Dynamic context menus for selecting left side and right side compare. Dynamic menus show what file is on left
    side.

  • Compares current working copy against last committed revision in git and svn (must configure binary paths)

  • Shows diff of last commit in git and svn

  • Shows diff of staged commits for git

  • View diffs in a view buffer or output panel

  • You can selectively disable version control menus if you don’t want to see them.

repo: https://github.com/facelessuser/EasyDiff

Feel free to tell me you like it, hate it, won’t use it, make suggestions, or simply let this thread sink to the bottom of the feed.

0 Likes

#2

-Fixed an SVN issue
-Added Mercurial support
-Redesigned how all of the version control options are shown
-Can now hide version control menu entries or disable the commands completely via the settings file.

That is it for now. This will probably be my last post in this thread unless there is some interest.

0 Likes

#3

Thanks for plugin, I like the use of context menu ala Beyond Compare.

My only issue is with Git. I have a rather large repository and when I right click on a view to open the context menu it takes seconds to be showed.

Didn’t look at the code but I suppose there must be a is_enabled() on menu item that call GIT.
Maybe a setting to disable this code replaced by a status bar message when there’s nothing to do could make the trick.

0 Likes

#4

No problem. You hit the nail on the head; Beyond Compare was the inspiration. It made a big difference in usability for me.

Specifically on large Git repos, or on all repos?

[quote=“bizoo”]Didn’t look at the code but I suppose there must be a is_enabled() on menu item that call GIT.
Maybe a setting to disable this code replaced by a status bar message when there’s nothing to do could make the trick.[/quote]

Yeah, is_enabled. I use to determine when to show “selection” and "view’ options, but I also use to determine if the current view is versioned control under svn, git, or mercurial (if they are enabled). With git, I have to hunt around for the “.git” folder to feed the git command before I execute the version command…I wonder if that is what takes so long, or if the version check in general takes too long because of the big repo (even though I am only polling for the single file’s status). Regardless, I can probably optionally skip the version check to speed things up.

0 Likes

#5

@bizoo I added your request

[pre=#2A2A2A] // Do not perform a version check on files
// when evaluating whether version control
// commands are enabled. May avoid slowing
// down context menu draw in large version
// controlled projects.
“skip_version_check_on_is_enabled”: false,[/pre]

This will avoid graying out version control items dynamically when showing the context menu, but hopefully speed up menu display. The commands, if run when the file is not versioned controled (vc) under the selected vc system, will display a message in the status bar. The only downside is that you won’t be guided to the appropriate menu items, but I think a slow menu would be a greater inconvenience.

0 Likes

#6

I made a slight modification in the logic to “diff last revision” in git. It just wasn’t working how I had intended. It was diffing the last commit for the repo. Now, it diffs the last revisions where the file in question was modified. This is now in line with how the other Version Control system’s commands are implemented, and how i think most would expect it to work.

0 Likes

#7

[quote=“facelessuser”]@bizoo I added your request

[pre=#2A2A2A] // Do not perform a version check on files
// when evaluating whether version control
// commands are enabled. May avoid slowing
// down context menu draw in large version
// controlled projects.
“skip_version_check_on_is_enabled”: false,[/pre]

This will avoid graying out version control items dynamically when showing the context menu, but hopefully speed up menu display. The commands, if run when the file is not versioned controled (vc) under the selected vc system, will display a message in the status bar. The only downside is that you won’t be guided to the appropriate menu items, but I think a slow menu would be a greater inconvenience.[/quote]

Works great, thanks.

[quote=“facelessuser”] bizoo wrote:My only issue is with Git. I have a rather large repository and when I right click on a view to open the context menu it takes seconds to be showed.

Specifically on large Git repos, or on all repos?[/quote]

There’s a very small delay (insignificant) for small repositories, but for a somewhat large repository (~60000 files) it takes 2-3 seconds.
startup, version: 3054 windows x64 channel: dev

Great, I was thinking about adding an external program for the diff (Beyond Compare actually). Sometimes viewing large diff in ST is not very useable.
I’ll look at it when I’ve some times.

0 Likes

#8

[quote=“bizoo”]Great, I was thinking about adding an external program for the diff (Beyond Compare actually). Sometimes viewing large diff in ST is not very useable.
I’ll look at it when I’ve some times.[/quote]

Yeah, I have considered it too. I know roughly how I would do it all behind the scenes; I should be able to even incorporate the version control diffs as well. Just not sure how I would display it in the menus yet. If I you get to it before me that is cool too :smile:.

0 Likes

#9

@bizoo, I should have some external diffing for everything but version control late tonight. I worked out what I need to do over lunch today. I code it up and commit tonight. I will get version control up and running hopefully in the next number of days. You should be able to enable/disable external diffing or internal diffing options in the settings file.

0 Likes

#10

External diff is in for left and right compare of views, selections, and clipboard. When I get time, I will get external support for version control in, but that might take me a couple of days.

Just set “show_external” to true in the settings file.
And give the absolute path to your compare tool in the “external_diff” setting.

If your compare tool uses arguments more complex than “compare_tool file1 file2”, you make have to wrap the call in a batch file or shell script depending on your system. If it is really a problem, I can make the “external diff” setting more flexible, but for the most part, I hope this isn’t a problem. On OSX, I had to wrap my call in a shell script for my diff tool, but Beyond Compare on windows just takes the files.

You can also turn off the internal sublime diff options via the “show_internal” option int he settings file if you decide you only want to use the external tool.

0 Likes

#11

Wow, was quick !
Everything works great, thanks for another useful plugin.

0 Likes

#12

No problem. I think I am on a coding kick right now…I will probably be burned out by December :smile:.

I will let you know when I finish the external version control options. Maybe I will throw it up on Package Control when I finish.

0 Likes

#13

Fixed a lot of my confusion with the version control stuff, and I enabled external version control. Hopefully all is still working and makes better sense now:

-Fix version control: “diff last revision” should be “diff with previous revision”
-Ensure svn, git, and mercurial “diff with previous revision” all behave like the name suggests (this is what I thought everything was doing the first time, but only svn behaved like this)
-When doing external diffs, copy files into temp folder to allow for more sane names for files
-Git remove “staged diff” in favor of a single diff which will show staged and unstaged against the base (this is what I wanted from the beginning)
-Add external version control options

That is it, I am done for now…unless I, or someone else, finds some bugs. I am going to give it a bit to ensure everything is stable, and if so, I think I will submit to package control.

I didn’t actually think I was going to add this much, but I think it has turned into a pretty useful plugin now.

0 Likes

#14

Any chance to support CVS? Unfortunately I’m stuck in the stone age at work with regards to version control :smile:

0 Likes

#15

I remember using CVS at my internship :smile:.

I am not sure if I will support CVS or not. I briefly thought about it. If I am able to setup a free CVS repo somewhere so I can test out client side functionality and figure out how to replicate the same features the other version control systems use for this plugin, then there is a good chance. If I am having to setup my own CVS server just so I can test out client side functionality, it just isn’t going to happen. If the interfacing with the CVS binary can’t give me what I need, it probably won’t happen either (but I this is less likely to be a sticking point).

CVS would probably be the only other system I would consider supporting.

0 Likes

#16

This should be in Package Control now.

I will be officially enabling a version control revert option as well probably tomorrow. I have tested git and mercurial, but I won’t enable it until I confirm svn revert is setup right.

That should finish up all the features I currently had planned.

0 Likes

#17

Revert is in.

0 Likes

#18

Hi,
I know this is a noob question, but how can I diff 2 tabs or files, and only select the differences?

IE: I have 2 files with a list computer names, I want to find only the systems missing from 1 file and select the missing systems so that I can put them into a new file.

Thx!!
Sully

0 Likes

#19

[quote=“virtuallynothere”]Hi,
I know this is a noob question, but how can I diff 2 tabs or files, and only select the differences?

IE: I have 2 files with a list computer names, I want to find only the systems missing from 1 file and select the missing systems so that I can put them into a new file.

Thx!!
Sully[/quote]

If I understand correctly what you are asking, you probably want to use the external option by linking easydiff to a 3rd party merge tool. The internal diff functionality is great for quickly seeing the difference. But for merging, I use EasyDiff’s external option and merge in an actual merge utility.

If you want to merge inside Sublime, then take a look at Sublimerge sublimerge.com/. I, personally, have a hard time paying for a merge tool that only works with Sublime, which is why I use EasyDiff connected to a good external merge tool when I actually need to merge.

0 Likes

#20

Easy Diff will now show the diff options in the Sidebar, Tab Context, and View Context for convenience (Sidebar will not show the selections option for obvious reasons).

Wait, but what if I don’t want to have EasyDiff show up in all of those menus?
Glad you asked! This can be controlled with the following setting, just remove the menu you don’t want to show up:

[pre=#232628] // Menus to show (view|tab|sidebar)
“menu_types”: “view”, “tab”, “sidebar”],[/pre]

Hopefully nothing broke in the process of adding this feature. I tested it well enough, but a lot of stuff changed internally.

0 Likes