Firstly, please remember that the internal Mercurial API is not stable. You should seriously consider using Mercurial's command-line directly if at all possible. Remember that there are XML templates (by passing --style=xml
) if you find parsing the default output too annoying.
That said, this is most easily done with revsets, just as you would do at the command line:
from mercurial import ui, hg
repo = hg.repository(ui.ui(), '/some/path/to/repo')
changesets = repo.revs("date('>1999-01-01') and date('<2000-12-31')")
As a bonus, this will go through Mercurial's internal revset optimizer.