diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2015-07-30 13:43:05 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2015-07-30 13:43:05 -0400 |
commit | d4da2e156c7eec4d9ac5744ec39b263a801e9523 (patch) | |
tree | 4e8ed6469247453b6204137b7d77147e77273e04 /alembic/command.py | |
parent | ab4691fa5c98336a7b1d4085cfa2602d352c1b1a (diff) | |
parent | ef7183e5358f2bdb7368c468b672ccc49647a2dd (diff) | |
download | alembic-d4da2e156c7eec4d9ac5744ec39b263a801e9523.tar.gz |
Merge branch 'edit-latest' of https://bitbucket.org/exhuma/alembic into pr46
Diffstat (limited to 'alembic/command.py')
-rw-r--r-- | alembic/command.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/alembic/command.py b/alembic/command.py index aab5cc2..13d8a57 100644 --- a/alembic/command.py +++ b/alembic/command.py @@ -5,6 +5,8 @@ from .runtime.environment import EnvironmentContext from . import util from . import autogenerate as autogen +import editor + def list_templates(config): """List available templates""" @@ -353,3 +355,16 @@ def stamp(config, revision, sql=False, tag=None): tag=tag ): script.run_env() + + +def edit(config): + """Edit the latest ervision""" + + script = ScriptDirectory.from_config(config) + revisions = script.walk_revisions() + head = next(revisions) + + try: + editor.edit(head.path) + except Exception as exc: + raise util.CommandError('Error executing editor (%s)' % (exc,)) |