Commits

Lukasz Balcerzak  committed d087d25

Updated parameter name for get_scm at cli. Fixes #109

  • Participants
  • Parent commits 57df162

Comments (0)

Files changed (3)

         if repo is None:
             curdir = abspath(os.curdir)
             try:
-                scm, path = get_scm(curdir, search_recursively=True)
+                scm, path = get_scm(curdir, search_up=True)
                 self.repo = vcs.get_repo(path, scm)
             except VCSError:
                 raise CommandError('Repository not found')

File vcs/commands/log.py

-from string import Template
+import string
 from vcs.nodes import FileNode
 from vcs.cli import ChangesetCommand
 from vcs.cli import make_option
 
 
 class LogCommand(ChangesetCommand):
-    TEMPLATE = Template(u'$raw_id | $date | $message')
+    TEMPLATE = u'$raw_id | $date | $message'
 
     option_list = ChangesetCommand.option_list + (
         make_option('-t', '--template', action='store', dest='template',
         return repo.get_changeset(cid)
 
     def get_template(self, **options):
-            return options.get('template', self.TEMPLATE)
+            return string.Template(options.get('template', self.TEMPLATE))
 
     def handle_changeset(self, changeset, **options):
         template = self.get_template(**options)

File vcs/tests/test_cli.py

 from __future__ import with_statement
 
-import inspect
+import datetime
 import mock
 import sys
+import subprocess
 import vcs
 import vcs.cli
 from contextlib import nested
 from StringIO import StringIO
-from vcs.utils.compat import unittest
-from vcs.cli import make_option
 from vcs.cli import BaseCommand
 from vcs.cli import ExecutionManager
+from vcs.cli import make_option
+from vcs.nodes import FileNode
+from vcs.tests.base import BackendTestMixin
+from vcs.tests.conf import SCM_TESTS
+from vcs.utils.compat import unittest
 
 
 class DummyExecutionManager(ExecutionManager):
         command.handle.assert_called_once_with(*args, **kwargs)
 
 
+class RealCliMixin(BackendTestMixin):
+
+    @classmethod
+    def _get_commits(cls):
+        commits = [
+            {
+                'message': u'Initial commit',
+                'author': u'Joe Doe <joe.doe@example.com>',
+                'date': datetime.datetime(2010, 1, 1, 20),
+                'added': [FileNode('file1', content='Foobar')],
+            },
+            {
+                'message': u'Added a file',
+                'author': u'Joe Doe <joe.doe@example.com>',
+                'date': datetime.datetime(2010, 1, 1, 20),
+                'added': [FileNode('file2', content='Foobar')],
+            },
+        ]
+        return commits
+
+    def test_log_command(self):
+        cmd = 'vcs log --template "\$message"'
+        process = subprocess.Popen(cmd, cwd=self.repo.path, shell=True,
+            stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+        so, se = process.communicate()
+        self.assertEqual(process.returncode, 0)
+        self.assertEqual(so.splitlines(), [
+            'Added a file',
+            'Initial commit',
+        ])
+
+
+# For each backend create test case class
+for alias in SCM_TESTS:
+    attrs = {
+        'backend_alias': alias,
+    }
+    cls_name = ''.join(('%s real cli' % alias).title().split())
+    bases = (RealCliMixin, unittest.TestCase)
+    globals()[cls_name] = type(cls_name, bases, attrs)
+
 
 if __name__ == '__main__':
     unittest.main()