[darcs-devel] [issue642] Automatic detection of file renames

Alexander Staubo alex at purefiction.net
Mon Feb 4 18:30:33 UTC 2008


On Feb 4, 2008 5:17 PM, David Roundy <bugs at darcs.net> wrote:
> You're right, directory renames are trickier, but even there, we've got
> diff code for directories, so we can quantify relatively easily how much
> they've changed.  For complicated reorganizations (e.g. filenames change
> and file contents get intermingled) it'd still be possible to do something
> reasonable, I suspect.

I would love to see someone use kernel facilities such as FSEvents [1]
on OS X and inotify [2] on Linux to accomplish this. (There are also
others such as fam [3], and Windows has its own easy-to-use API.)

These mechanisms provide low-overhead notifications about file changes
that alleviates the need to explicitly check file contents -- instead
of these expensive brute-force checks and imprecise heuristics, the
kernel does the work and gives you semi-real-time callbacks whenever
something actually changes.

FSEvents has the advantage that the listening process need not be
running in order to subscribe to events -- FSEvents has a persistent
mode where events are logged to disk and survive reboots. It's this
engine serves as the underpinnings of Leopard's Time Machine backup
system.

For the other APIs, a helper daemon running in the background would be
needed to receive notifications; it would be as simple as logging the
events sequentially to a text file in _darcs, which the Darcs
command-line tool could then read and process.

Depending on such an external tool wouldn't be a big deal because
people are surviving just fine today without such clever change
detection. It would purely be a convenience for those willing to run
the tool. And it could be fairly transparent: If Darcs finds stuff in
_darcs/events, then it can use it to glean structural repo changes; if
this file is not available, it needs to rely on the old behaviour --
namely "darcs mv" and "--look-for-adds".

I imagine you would have a config file ~/.darcs/monitor.conf listing
monitored repos, and a support command in Darcs itself:

$ darcs monitor --enable
Change monitor not running. Starting.
Enabled monitoring of /home/alex/work/importantproject.
$ darcs monitor --disable
Disabled monitoring of /home/alex/work/importantproject.

[1] http://developer.apple.com/documentation/Darwin/Conceptual/FSEvents_ProgGuide/TechnologyOverview/chapter_3_section_1.html
[2] http://en.wikipedia.org/wiki/Inotify
[3] http://en.wikipedia.org/wiki/File_alteration_monitor

Alexander.


More information about the darcs-devel mailing list