comparison tests/test_template_keywords.py @ 722:aa24148a7454

uisetup: add fromsvn() and svnrev() revsets.
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Tue, 05 Oct 2010 16:26:19 +0200
parents af817963897e
children 4baa41e0f8ad
comparison
equal deleted inserted replaced
721:af817963897e 722:aa24148a7454
1 import test_util 1 import test_util
2 2
3 import unittest 3 import unittest
4 4
5 from mercurial import commands 5 from mercurial import commands
6 from mercurial import error
6 from mercurial import ui 7 from mercurial import ui
7 try: 8 try:
8 from mercurial import templatekw 9 from mercurial import templatekw
9 templatekw.keywords 10 templatekw.keywords
10 except ImportError: 11 except ImportError:
11 templatekw = None 12 templatekw = None
12 13
14 try:
15 from mercurial import revset
16 revset.methods
17 except ImportError:
18 revset = None
13 19
14 class CapturingUI(ui.ui): 20 class CapturingUI(ui.ui):
15 21
16 def __init__(self, *args, **kwds): 22 def __init__(self, *args, **kwds):
17 super(CapturingUI, self).__init__(*args, **kwds) 23 super(CapturingUI, self).__init__(*args, **kwds)
41 self.assertEqual(ui._output, 47 self.assertEqual(ui._output,
42 ('0:df2126f7-00ab-4d49-b42c-7e981dde0bcf ' 48 ('0:df2126f7-00ab-4d49-b42c-7e981dde0bcf '
43 '1:df2126f7-00ab-4d49-b42c-7e981dde0bcf ' 49 '1:df2126f7-00ab-4d49-b42c-7e981dde0bcf '
44 '2: ')) 50 '2: '))
45 51
52 if templatekw and revset:
53 def test_svn_revsets(self):
54 repo = self._load_fixture_and_fetch('two_revs.svndump')
55
56 # we want one commit that isn't from Subversion
57 self.commitchanges([('foo', 'foo', 'frobnicate\n')])
58
59 defaults = {'date': None, 'rev': ['fromsvn()'], 'user': None}
60
61 ui = CapturingUI()
62 commands.log(ui, repo, template='{rev}:{svnrev} ', **defaults)
63 self.assertEqual(ui._output, '0:2 1:3 ')
64
65 defaults = {'date': None, 'rev': ['svnrev(2)'], 'user': None}
66
67 ui = CapturingUI()
68 commands.log(ui, repo, template='{rev}:{svnrev} ', **defaults)
69 self.assertEqual(ui._output, '0:2 ')
70
71 defaults = {'date': None, 'rev': ['fromsvn(1)'], 'user': None}
72
73 self.assertRaises(error.ParseError,
74 commands.log, self.ui(), repo,
75 template='{rev}:{svnrev} ', **defaults)
76
77 defaults = {'date': None, 'rev': ['svnrev(1, 2)'], 'user': None}
78
79 self.assertRaises(error.ParseError,
80 commands.log, self.ui(), repo,
81 template='{rev}:{svnrev} ', **defaults)
46 82
47 def suite(): 83 def suite():
48 all = [unittest.TestLoader().loadTestsFromTestCase(TestLogKeywords),] 84 all = [unittest.TestLoader().loadTestsFromTestCase(TestLogKeywords),]
49 return unittest.TestSuite(all) 85 return unittest.TestSuite(all)