diff --git a/kallithea/lib/vcs/backends/hg/repository.py b/kallithea/lib/vcs/backends/hg/repository.py --- a/kallithea/lib/vcs/backends/hg/repository.py +++ b/kallithea/lib/vcs/backends/hg/repository.py @@ -540,14 +540,13 @@ class MercurialRepository(BaseRepository if branch_name: filter_.append('branch("%s")' % (branch_name)) - if start_date and not end_date: + if start_date: filter_.append('date(">%s")' % start_date) - if end_date and not start_date: + if end_date: filter_.append('date("<%s")' % end_date) - if start_date and end_date: - filter_.append('date(">%s") and date("<%s")' % (start_date, end_date)) if filter_: - revisions = scmutil.revrange(self._repo, filter_) + revspec = ' and '.join(filter_) + revisions = scmutil.revrange(self._repo, [revspec]) else: revisions = self.revisions diff --git a/kallithea/tests/api/api_base.py b/kallithea/tests/api/api_base.py --- a/kallithea/tests/api/api_base.py +++ b/kallithea/tests/api/api_base.py @@ -21,6 +21,8 @@ import random import mock import re +import pytest + from kallithea.tests.base import * from kallithea.tests.fixture import Fixture from kallithea.lib.compat import json @@ -2501,6 +2503,19 @@ class _BaseTestApi(object): assert 'message' in result[0] assert 'added' not in result[0] + def test_api_get_changesets_with_branch(self): + if self.REPO == 'vcs_test_hg': + branch = 'stable' + else: + pytest.skip("skipping due to missing branches in git test repo") + id_, params = _build_data(self.apikey, 'get_changesets', + repoid=self.REPO, branch_name=branch, start_date="2011-02-24T00:00:00") + response = api_call(self, params) + result = json.loads(response.body)["result"] + assert len(result) == 5 + assert 'message' in result[0] + assert 'added' not in result[0] + def test_api_get_changesets_with_file_list(self): id_, params = _build_data(self.apikey, 'get_changesets', repoid=self.REPO, start_date="2010-04-07T23:30:30", end_date="2010-04-08T00:31:14", with_file_list=True)