<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_changesets(self, repo, **options):
 """ Returns generator of changesets from given ``repo`` for given ``options``. :param repo: repository instance. Same as ``self.repo``. **Available options** * ``start_date``: only changesets not older than this parameter would be generated * ``end_date``: only changesets not younger than this parameter would be generated * ``start``: changeset's ID from which changesets would be generated * ``end``: changeset's ID to which changesets would be generated * ``branch``: branch for which changesets would be generated. If ``all`` flag is specified, this option would be ignored. By default, branch would by tried to retrieved from working directory. * ``all``: return changesets from all branches * ``reversed``: by default changesets are returned in date order. If this flag is set to ``True``, reverse order would be applied. * ``limit``: if specified, show no more changesets than this value. Default is ``None``. """

        branch_name = None
        if not options.get('all', None):
            branch_name = options.get('branch') or repo.workdir.get_branch()
        if options.get('start_date'):
            options['start_date'] = parse_datetime(options['start_date'])
        if options.get('end_date'):
            options['end_date'] = parse_datetime(options['end_date'])
        changesets = repo.get_changesets(
            start=options.get('start'),
            end=options.get('end', options.get('main')),
            start_date=options.get('start_date'),
            end_date=options.get('end_date'),
            branch_name=branch_name,
            reverse=not options.get('reversed', False),
        )
        try:
            limit = int(options.get('limit'))
        except (ValueError, TypeError):
            limit = None

        count = 0
        for changeset in changesets:
            if self.show_changeset(changeset, **options):
                yield changeset
                count += 1
                if count == limit:
                    break