]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
add option, after-current, to history subcommand
authorAtsushi Odagiri <aodagx@gmail.com>
Sun, 14 Apr 2013 03:24:32 +0000 (12:24 +0900)
committerAtsushi Odagiri <aodagx@gmail.com>
Sun, 14 Apr 2013 03:24:32 +0000 (12:24 +0900)
alembic/command.py
alembic/config.py

index ddaf00a9464b80a68d17385bd4561c09d42d9c0c..731f36c0b5411e1be24ecac0e7734d5d2e9d6025 100644 (file)
@@ -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"""
index 5658e960b9bc83c1997b43d4c3f434b20754fd72..3fa8af7c3baef115956b52177fdec5e435dd7e3e 100644 (file)
@@ -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"