fourier / ztree

Directory tree comparison mode for Emacs
http://www.emacswiki.org/emacs/ZtreeDiff
GNU General Public License v3.0
239 stars 21 forks source link

Add a "fast" mode that leverages modification times #84

Open JohnC32 opened 1 year ago

JohnC32 commented 1 year ago

ztree-diff is quite slow and not really usable on any sizable directory. Try running ztree-diff on a directory trees containing 100k files. A solution to this is to add a "fast" mode that relies on modification times and file modes. If the modification times differ or the file modes differ, then the file is different.

If you walk the directory tree an note the file modification times (mtimes), you can then compare the mtimes to see if the files differ. Also record the file modes and record if they differ. This information can then be used to generate the tree in emacs. When you expand a node that is different, you'd then run the true diff.

Also, when constructing the directory tree, for subdirectories that have no modifications, don't embed the contents in the emacs buffer. Rather show the subdirectory unexpanded and when you tab to expand the subdirectory, read the contents from the disk.

This mode needs to be opted in because this mtimes / modes check is not 100% robust. For example, one can write a small program that swaps bytes in a file and rests the file mtime. However, all "normal" development tools such as emacs, when they write a file update the mtime.

If you add this feature, I suspect many will be quite happy because it will make ztree faster than any alternative in emacs or outside of emacs that I'm aware of.