Adds a flag to retain a fixed number of backups.

Doesn't implement the behavior for this flag, though.
Rename delete_if_qualifies -> delete_if_before.
Fixes dead variables in delete_if_before.
Pulls out groupdict_to_segment_number and delete_if_before.
Pulls out a helper function that deletes WAL segments before a cutoff.
Implements "delete but retain N backups" functionality.

- Pulls out a helper function to delete base backups before a
  fixed segment number.
- Implements "delete with retention" using this helper.
Fixes references to storage.base.SegmentNumber.

These seem to have been broken by e90973ae83b56197851caa1c5247fab255b25f40.