importEvents function
Import a branch: events in chain order (oldest first), optionally windowed by sequence number and narrowed by a tag filter (same containment semantics as Subscribe). A missing branch imports as an empty log.
Implementation
Future<List<Event>> importEvents(String repo,
{String branch = eventLogBranch,
int fromSeq = 0,
int? toSeq,
List<TagValue>? filterTags}) async {
if (await branchHead(repo, branch) == null) return [];
final events = <Event>[];
final shas = (await gitText(repo, ['rev-list', '--reverse', branch]))
.split('\n');
for (final sha in shas) {
if (sha.isEmpty) continue;
final data = await gitBytes(repo, ['cat-file', '-p', '$sha:$gitBlobPath']);
final event = Event();
event.unmarshalDc(data);
if (event.seq <= fromSeq) continue;
if (toSeq != null && event.seq > toSeq) continue;
if (filterTags != null && !tagsMatch(event.tags, filterTags)) continue;
events.add(event);
}
return events;
}