irmin: discard stale events
irmin: discard stale events

There are two different ways to produce events (which are then consumed by watchers):
- every update to the reference store will call notify, which will notify watcher
  connected to the same repository in that process
- there is a background thread, using irmin-watcher (with either polling mode,
  inotify or fsevents), which check for filesystem changes, and call notify
  whenever a reference change.

It is necessary that the events are delivered in (commit) order, as the API
is exposing diffs and it would be confusing if the events go back in time.

There is a small race right now between these two mechanism: the background
thread could read a new reference value, be interrupted, and then call notify.
During that interuption, the store can change and events be delivered. If
that's the case, we want to discard the current event and try again.

mirage/irmin,mirage/irmin