Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
e04209e1
Kaydet (Commit)
e04209e1
authored
Şub 24, 2019
tarafından
Matthias Kestenholz
Kaydeden (comit)
Tim Graham
Şub 25, 2019
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refs #30179 -- Moved topological sort functions to django.utils.
üst
50f09264
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
3 deletions
+30
-3
autodetector.py
django/db/migrations/autodetector.py
+1
-2
topological_sort.py
django/utils/topological_sort.py
+5
-1
test_topological_sort.py
tests/utils_tests/test_topological_sort.py
+24
-0
No files found.
django/db/migrations/autodetector.py
Dosyayı görüntüle @
e04209e1
...
...
@@ -12,8 +12,7 @@ from django.db.migrations.questioner import MigrationQuestioner
from
django.db.migrations.utils
import
(
COMPILED_REGEX_TYPE
,
RegexObject
,
get_migration_name_timestamp
,
)
from
.topological_sort
import
stable_topological_sort
from
django.utils.topological_sort
import
stable_topological_sort
class
MigrationAutodetector
:
...
...
django/
db/migration
s/topological_sort.py
→
django/
util
s/topological_sort.py
Dosyayı görüntüle @
e04209e1
class
CyclicDependencyError
(
ValueError
):
pass
def
topological_sort_as_sets
(
dependency_graph
):
"""
Variation of Kahn's algorithm (1962) that returns sets.
...
...
@@ -13,7 +17,7 @@ def topological_sort_as_sets(dependency_graph):
current
=
{
node
for
node
,
deps
in
todo
.
items
()
if
not
deps
}
if
not
current
:
raise
Value
Error
(
'Cyclic dependency in graph: {}'
.
format
(
raise
CyclicDependency
Error
(
'Cyclic dependency in graph: {}'
.
format
(
', '
.
join
(
repr
(
x
)
for
x
in
todo
.
items
())))
yield
current
...
...
tests/utils_tests/test_topological_sort.py
0 → 100644
Dosyayı görüntüle @
e04209e1
from
django.test
import
SimpleTestCase
from
django.utils.topological_sort
import
(
CyclicDependencyError
,
stable_topological_sort
,
topological_sort_as_sets
,
)
class
TopologicalSortTests
(
SimpleTestCase
):
def
test_basic
(
self
):
dependency_graph
=
{
1
:
{
2
,
3
},
2
:
set
(),
3
:
set
(),
4
:
{
5
,
6
},
5
:
set
(),
6
:
{
5
},
}
self
.
assertEqual
(
list
(
topological_sort_as_sets
(
dependency_graph
)),
[{
2
,
3
,
5
},
{
1
,
6
},
{
4
}])
self
.
assertEqual
(
stable_topological_sort
([
1
,
2
,
3
,
4
,
5
,
6
],
dependency_graph
),
[
2
,
3
,
5
,
1
,
6
,
4
])
def
test_cyclic_dependency
(
self
):
msg
=
'Cyclic dependency in graph: (1, {2}), (2, {1})'
with
self
.
assertRaisesMessage
(
CyclicDependencyError
,
msg
):
list
(
topological_sort_as_sets
({
1
:
{
2
},
2
:
{
1
}}))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment