Mercurial > hgsubversion
comparison tests/test_template_keywords.py @ 687:d424bd1ac647
templatekw: restore compatibility with hg < 1.5
The templatekw module was new in 1.5 - it looks nontrivial to extend the
templater in 1.4.x and earlier, so just disable this feature on those
versions.
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Mon, 06 Sep 2010 17:08:11 -0500 |
parents | 8687c5aa4f35 |
children | cb32d90f915e |
comparison
equal
deleted
inserted
replaced
686:0c67d97f54be | 687:d424bd1ac647 |
---|---|
2 | 2 |
3 import unittest | 3 import unittest |
4 | 4 |
5 from mercurial import commands | 5 from mercurial import commands |
6 from mercurial import ui | 6 from mercurial import ui |
7 try: | |
8 from mercurial import templatekw | |
9 templatekw.keywords | |
10 except ImportError: | |
11 templatekw = None | |
7 | 12 |
8 | 13 |
9 class CapturingUI(ui.ui): | 14 class CapturingUI(ui.ui): |
10 | 15 |
11 def __init__(self, *args, **kwds): | 16 def __init__(self, *args, **kwds): |
13 self._output = "" | 18 self._output = "" |
14 | 19 |
15 def write(self, msg, *args, **kwds): | 20 def write(self, msg, *args, **kwds): |
16 self._output += msg | 21 self._output += msg |
17 | 22 |
23 if templatekw: | |
24 class TestLogKeywords(test_util.TestBase): | |
18 | 25 |
19 class TestLogKeywords(test_util.TestBase): | 26 def test_svn_keywords(self): |
20 | 27 defaults = {'date': None, 'rev': None, 'user': None} |
21 def test_svn_keywords(self): | 28 repo = self._load_fixture_and_fetch('two_revs.svndump') |
22 defaults = {'date': None, 'rev': None, 'user': None} | 29 ui = CapturingUI() |
23 repo = self._load_fixture_and_fetch('two_revs.svndump') | 30 commands.log(ui, repo, template='{rev}:{svnrev} ', **defaults) |
24 ui = CapturingUI() | 31 self.assertEqual(ui._output, '0:2 1:3 ') |
25 commands.log(ui, repo, template='{rev}:{svnrev} ', **defaults) | 32 ui = CapturingUI() |
26 self.assertEqual(ui._output, '0:2 1:3 ') | 33 commands.log(ui, repo, template='{rev}:{svnpath} ', **defaults) |
27 ui = CapturingUI() | 34 self.assertEqual(ui._output, '0:/trunk 1:/trunk ') |
28 commands.log(ui, repo, template='{rev}:{svnpath} ', **defaults) | 35 ui = CapturingUI() |
29 self.assertEqual(ui._output, '0:/trunk 1:/trunk ') | 36 commands.log(ui, repo, template='{rev}:{svnuuid} ', **defaults) |
30 ui = CapturingUI() | 37 self.assertEqual(ui._output, |
31 commands.log(ui, repo, template='{rev}:{svnuuid} ', **defaults) | 38 ('0:df2126f7-00ab-4d49-b42c-7e981dde0bcf ' |
32 self.assertEqual(ui._output, | 39 '1:df2126f7-00ab-4d49-b42c-7e981dde0bcf ')) |
33 ('0:df2126f7-00ab-4d49-b42c-7e981dde0bcf ' | |
34 '1:df2126f7-00ab-4d49-b42c-7e981dde0bcf ')) | |
35 | 40 |
36 | 41 |
37 def suite(): | 42 def suite(): |
38 all = [unittest.TestLoader().loadTestsFromTestCase(TestLogKeywords),] | 43 all = [unittest.TestLoader().loadTestsFromTestCase(TestLogKeywords),] |
39 return unittest.TestSuite(all) | 44 return unittest.TestSuite(all) |
45 else: | |
46 def suite(): | |
47 return unittest.TestSuite([]) |