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 @@ -265,7 +265,7 @@ class MercurialRepository(BaseRepository self.get_changeset(rev1) self.get_changeset(rev2) if path: - file_filter = match(self.path, '', [path]) + file_filter = match(self.path, '', [path], exact=True) else: file_filter = None diff --git a/kallithea/tests/vcs/test_repository.py b/kallithea/tests/vcs/test_repository.py --- a/kallithea/tests/vcs/test_repository.py +++ b/kallithea/tests/vcs/test_repository.py @@ -79,6 +79,14 @@ class RepositoryGetDiffTest(_BackendTest ], 'removed': [FileNode('foobar')], }, + { + 'message': u'Commit that contains glob pattern in filename', + 'author': 'Jane Doe ', + 'date': datetime.datetime(2010, 1, 1, 22), + 'added': [ + FileNode('README{', content='Strangely-named README file'), + ], + }, ] return commits @@ -86,6 +94,11 @@ class RepositoryGetDiffTest(_BackendTest with self.assertRaises(ChangesetDoesNotExistError): self.repo.get_diff('a' * 40, 'b' * 40) + def test_glob_patterns_in_filename_do_not_raise_exception(self): + revs = self.repo.revisions + + diff = self.repo.get_diff(revs[2], revs[3], path='README{') # should not raise + class GitRepositoryGetDiffTest(RepositoryGetDiffTest, unittest.TestCase): backend_alias = 'git' @@ -153,6 +166,18 @@ index c11c37d41d33fb47741cff93fa5f9d798c +FOOBAR ''') + def test_fourth_changeset_diff(self): + revs = self.repo.revisions + self.assertEqual(self.repo.get_diff(revs[2], revs[3]), '''diff --git a/README{ b/README{ +new file mode 100644 +index 0000000000000000000000000000000000000000..cdc0c1b5d234feedb37bbac19cd1b6442061102d +--- /dev/null ++++ b/README{ +@@ -0,0 +1 @@ ++Strangely-named README file +\ No newline at end of file +''') + class HgRepositoryGetDiffTest(RepositoryGetDiffTest, unittest.TestCase): backend_alias = 'hg' @@ -214,6 +239,17 @@ diff --git a/foobar3 b/foobar3 +FOOBAR ''') + def test_fourth_changeset_diff(self): + revs = self.repo.revisions + self.assertEqual(self.repo.get_diff(revs[2], revs[3]), '''diff --git a/README{ b/README{ +new file mode 100644 +--- /dev/null ++++ b/README{ +@@ -0,0 +1,1 @@ ++Strangely-named README file +\ No newline at end of file +''') + # For each backend create test case class for alias in SCM_TESTS: