From: Atsushi Odagiri Date: Sun, 14 Apr 2013 03:24:32 +0000 (+0900) Subject: add option, after-current, to history subcommand X-Git-Tag: rel_0_6_0~19^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a69e1465ab6b4413823529703fe16adc567be4b3;p=thirdparty%2Fsqlalchemy%2Falembic.git add option, after-current, to history subcommand --- diff --git a/alembic/command.py b/alembic/command.py index ddaf00a9..731f36c0 100644 --- a/alembic/command.py +++ b/alembic/command.py @@ -149,14 +149,34 @@ def downgrade(config, revision, sql=False, tag=None): ): script.run_env() -def history(config): +def history(config, after_current=False): """List changeset scripts in chronological order.""" script = ScriptDirectory.from_config(config) - for sc in script.walk_revisions(): - if sc.is_head: - config.print_stdout("") - config.print_stdout(sc) + def display_history(current=None): + for sc in script.walk_revisions(): + if sc.is_head: + config.print_stdout("") + config.print_stdout(sc) + if sc == current: + break + + def display_history_after_curreont(rev, context): + current = script.get_revision(rev) + display_history(current=current) + return [] + + if not after_current: + return display_history() + + + with EnvironmentContext( + config, + script, + fn=display_history_after_curreont + ): + script.run_env() + def branches(config): """Show current un-spliced branch points""" diff --git a/alembic/config.py b/alembic/config.py index 5658e960..3fa8af7c 100644 --- a/alembic/config.py +++ b/alembic/config.py @@ -200,6 +200,12 @@ class CommandLine(object): help="Only show current version and " "whether or not this is the head revision.") + if 'after_current' in kwargs: + parser.add_argument("--after-current", + action="store_true", + help="Only show after current revisions and current revision.") + + positional_help = { 'directory': "location of scripts directory", 'revision': "revision identifier"