neutron-db-manage: expose alembic 'heads' command

This command shows current heads in all alembic branches. Even without
the command, we *can* get the heads values by looking into *_HEAD files
in tree. Still, those files may be missing; and the command is a tiny
bit more easy to use. Also, it gives access to more details on head
revisions if used with --verbose.

Change-Id: I6e7b7b5cd6f704d5d4bb4d845bf5098d4045924a
This commit is contained in:
Ihar Hrachyshka 2015-11-20 17:35:10 +01:00
parent 2c3496db90
commit 80ec365803
2 changed files with 13 additions and 23 deletions

View File

@ -431,7 +431,7 @@ def update_head_file(config):
def add_command_parsers(subparsers):
for name in ['current', 'history', 'branches']:
for name in ['current', 'history', 'branches', 'heads']:
parser = add_alembic_subparser(subparsers, name)
parser.set_defaults(func=do_generic_show)
parser.add_argument('--verbose',

View File

@ -173,38 +173,28 @@ class TestCli(base.BaseTestCase):
[{'revision': 'foo', 'sql': True}]
)
def test_branches(self):
def _validate_cmd(self, cmd):
self._main_test_helper(
['prog', 'branches'],
'branches',
['prog', cmd],
cmd,
[{'verbose': False}])
self._main_test_helper(
['prog', 'branches', '--verbose'],
'branches',
['prog', cmd, '--verbose'],
cmd,
[{'verbose': True}])
def test_branches(self):
self._validate_cmd('branches')
def test_current(self):
self._main_test_helper(
['prog', 'current'],
'current',
[{'verbose': False}])
self._main_test_helper(
['prog', 'current', '--verbose'],
'current',
[{'verbose': True}])
self._validate_cmd('current')
def test_history(self):
self._main_test_helper(
['prog', 'history'],
'history',
[{'verbose': False}])
self._validate_cmd('history')
self._main_test_helper(
['prog', 'history', '--verbose'],
'history',
[{'verbose': True}])
def test_heads(self):
self._validate_cmd('heads')
def test_check_migration(self):
with mock.patch.object(cli, 'validate_head_file') as validate: