Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_iterate_related_revisions gets stuck with duplicate revisions #310

Closed
sqlalchemy-bot opened this issue Jul 22, 2015 · 3 comments
Closed
Labels
bug Something isn't working versioning model
Milestone

Comments

@sqlalchemy-bot
Copy link

Migrated issue, originally created by Michael Bayer (@zzzeek)

attached test illustrates a complex revision tree, where the _iterate_related_revisions() gets bogged down doing the same nodes over and over again. As only needs to emit unique nodes we need to put a seen set into it:

index e9958b1..40cfbb2 100644
--- a/alembic/script/revision.py
+++ b/alembic/script/revision.py
@@ -544,17 +544,24 @@ class RevisionMap(object):
         if map_ is None:
             map_ = self._revision_map
 
+        seen = set()
         todo = collections.deque()
         for target in targets:
+
             todo.append(target)
             if check:
                 per_target = set()
+
             while todo:
                 rev = todo.pop()
-                todo.extend(
-                    map_[rev_id] for rev_id in fn(rev))
                 if check:
                     per_target.add(rev)
+
+                if rev in seen:
+                    continue
+                seen.add(rev)
+                todo.extend(
+                    map_[rev_id] for rev_id in fn(rev))
                 yield rev
             if check and per_target.intersection(targets).difference([target]):
                 raise RevisionError(

Attachments: runtest.py

@sqlalchemy-bot
Copy link
Author

Michael Bayer (@zzzeek) wrote:

dad4be3

@sqlalchemy-bot
Copy link
Author

Michael Bayer (@zzzeek) wrote:

61183b7

@sqlalchemy-bot
Copy link
Author

Changes by Michael Bayer (@zzzeek):

  • changed status to closed

@sqlalchemy-bot sqlalchemy-bot added versioning model bug Something isn't working labels Nov 27, 2018
@sqlalchemy-bot sqlalchemy-bot added this to the fasttrack milestone Nov 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working versioning model
Projects
None yet
Development

No branches or pull requests

1 participant